{"id":18887063,"url":"https://github.com/lostjared/atarivm","last_synced_at":"2026-02-24T03:30:15.811Z","repository":{"id":110400307,"uuid":"57027138","full_name":"lostjared/AtariVM","owner":"lostjared","description":"A virtual machine for an Assembly language based on Atari 800 Assembly Language.","archived":false,"fork":false,"pushed_at":"2017-01-14T18:47:06.000Z","size":213,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-31T05:18:51.818Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lostjared.png","metadata":{"files":{"readme":"README","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-04-25T09:00:41.000Z","updated_at":"2017-01-14T23:18:52.000Z","dependencies_parsed_at":null,"dependency_job_id":"31de4bcd-bef8-4a03-b8d7-f31ec97c7e38","html_url":"https://github.com/lostjared/AtariVM","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lostjared%2FAtariVM","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lostjared%2FAtariVM/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lostjared%2FAtariVM/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lostjared%2FAtariVM/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lostjared","download_url":"https://codeload.github.com/lostjared/AtariVM/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239859563,"owners_count":19708863,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-08T07:33:37.982Z","updated_at":"2026-02-24T03:30:15.768Z","avatar_url":"https://github.com/lostjared.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"What exactly is this program?\n\nIts a Virtual Machine, NOT a Emulator.. It interprets A  Atari 800 Like Assembly Language\nIt contains extra instructions for modern computers\nThis is meant to help me learn how to write a interpreter/virtual machine\nSo how did this project get started?\nWell its a long story actually, but here goes:\n\nI got a book from my friend a long time ago\nit was called  The Atari Assembler by Don Inman and Kurt Inman\nIt was written in 1981 and explains about the atari 400 and 800 (6502 Instructions)\nI wanted to use the language, so I decided to write a interpreter that would\npreform the same tasks as the old assembly language..I always have been interested\nin compilers / interpreters / assemblers, so I thought writing something like this\nwould help me Understand. Plus ive always wanted to write a program which interprets a \nolder systems way of operating kind of like a emulator.\nThrough doing this:\nLearning the instructions and there opcodes, I began to have a firmer grasp\non my C and C++ programming .. This language is still very basic but i plan on making it\ninto a full virtual machine.. with special instructions that were not avialable back than\nbut still keeping the same look and feel of the old assembly language.\n\nWhat this program contains:\n\nThe ability to output debug information in HTML instead of atari machine language\n so you can look at what the\nassembly code would be translated to, which mnemoics stand for which machine instructions\netc..\n\nThe ability to produce debug output into the stdout so you can see what is going\non after the program finishes execution.. like what memory locations it changes..\nand the status of the registers and flags\n\nnew additions to the language:\nAbility to use a Register as a variable on the instructions\nInterupt Instruction to have the program be able to preform\nspecial operations via a interupt system call which can point to addresses\nof functions written in C.\n\n\nWhy use this program?\nTo help understand the foundations of current programming languages\n\n\n--------------------------------------------\nCommand Line Arguments:\n\n\n--debug \n\tprint debug to the stdout and a html file\n\tnow this mode should only be used if your applications dosent enter graphics mode\n\tbecause it prints out to the stdout every instruction and the status of the registers\n\tif your using a graphics mode application, than use the following \n\n--debug=gfx\n\tthis will print the status of the current instruction pointer, and the status\n        of the registers to window its running in\n\tthis can be usefull for finding bugs\n\n\tthe first argument is the name of the script file\n\texample\n\tatari-vm script.ats \n        or\n        atari-vm script.ats --debug\n        of\n        atari-vm script.ats --debug=gfx\n\n\nSection A:\n--------------------------------------------\n\n\nNotes on the language:\n\n $ stands for Hexadecimal Address\n # stands for decimal constant \n #$ stands for Hexadecimal Constant\n\n\tThe Flags\n\n\t0 = Negative Result Flag\n\t1 = Overflow Flag\n\t2 = Expansion Flag (Not Labeled)\n\t3 = Break Command Flag\n\t4 = Decimal Mode Flag\n\t5 = Intereupt disable flag\n\t6 = Zero result flag\n\t7 = Carry Flag\n\t\n\nInstructions:\n\nADC - Add Memory to Accumulator with Carry\nAND - And Memory to Accumulator with Carry\nASL - Shift Left One Bit (memory or accumulator)\nBCC - Branch if Carry Flag is clear\nBCS - Branch if Carry Flag is set\nBEQ - Branch on result Zero\nBIT - Test bits in accumulator with memory\nBMI - Branch on result minus\nBNE - Branch if result not zero\nBPL - Branch on result plus\nBRK - Unconditional break\nBVC - Branch on overflow clear\nBVS - Branch on overflow set\nCLC - Clear Carry Flag\nCLD - Clear Decimal Flag\nCLI - Clear Interupt Flag\nCLV - Clear overflow Flag\nCMP - Compare memory and accumulator\nCPX - Compare Memory and Register X\nCPY - Compare Memory and Reigster Y\nDEC - Decrement Memory or accumulator\nDEX - Decrement X Register\nDEY - Decrement Y Register\nEOR - Exculsive Or memory or accumulator\nINC - Incrmeent Memory or accumulator\n* INT - New Instruction: Interupt  ( See Section B )\nINX - Increment register X\nINY - Increment register Y\nJMP - Unconditonal Jump to Code label or address\nJSR - Jump To Subroutine\nLDA - Load accumulator with constant or memory\n* LDM - New Instruction: Load Memory from at X register with constant string\nLDX - Load X register with constant or memory\nLDY - Load Y register with constant or memory\nLSR - Shift right one bit\nNOP - No operation \nORA - Or accumulator with constant or memory\nPHA - Push accumulator onto the stack\nPHP - Push proccesscor flags onto the stack\nPLA - Pull (pop) accumulator from the stack\nPLP - Pull (pop) proccesscor flags from the stack\nROL - Rotate bits one left\nROR - Rotate bits one right\nRTI - Return from interupt\nRTS - Return from subroutine\nSBC - Subtract memory and borrow from accum\nSEC - Set carry flag\nSED - Set decimal flag\nSEI - Set interupt flag\nSTA - Store accumulator in memory\nSTX - Store register X in memory\nSTY - Store register Y in memory\nTAX - Transfer accumulator to X register\nTAY - Transfer accumulator to Y register\nTSX - Transfer stack pointer to Index X\nTXA - Transfer register X to accumulator\nTYA - Transfer register Y to accumulator\n\n------------------------------------------\nSection B:\n\nNew interupts:\nThe interupt instruction is followed by a constant\nto stand for what will be called.. It manipulates the X,Y,A registers\nand takes them for information for the specific interupt.\n\nCurrent Supported New interupts\n\n0x1 \n------\n\nSyntax:\n\nINT #01 - Print to the Screen\n\n- Registers Effected\nX contains the value of where to start to print the data to the stdout\nY register contains the value of where to stop printing the data to the stdout\n\n\nINT #02 - Read From stdin\n- Registers Effected\nX contains the value of where to start to store data typed to the stdout\nY contains the value of where the input stops (length of the inputed string)\n\nExamples:\n\n------ Begin Code Snipit ---------------\n\n*= $1000\n ; simple echo of what the person types\nSTART ; code label\nLDX #100 ; load X register with constant (#) value 100\nINT $02 ; Interupt (*New*) 0x2 in Hex ($)\nINT $01 ; Interupt (*New*) 0x1 in Hex ($)\nEND ; end code label \n\n----------------------------------------\n\nWhat this code does is Load the Register X with constant variable 0x100\nthan calls the interupt to 0x02 which asks the user for input\nthen calls the interupt with value 0x1 which prints to the screen\n\nSo how did it know where to stop printing?\nthe length of the string was stored in the Y register \nand the start was stored in the X register\nso when we call INT $01 it automaticly knows where to print \nthe data the user typed..\n\n-----------------------------------------------\n\nINT #03 - Read a decimal value\n- Registers Effected\nX contains the value of the variable read in from the stdin\n\nINT #04 - Read a  Hexadecimal value\n- Registers Effected\nX contains the value of the variable read in from the stdin\n\n\nINT #$13 - Set the Video Mode\n- Registerse Effected\nX contains the value of the video mode being successfully set\n\nINT #$14 - Proccess Events\n- Registers Effected\nX contains 1 if the program is going to end\n- Keyboard Input\nthe keyboard offset is 0xFFFF\nso the keys when there pressed are there regular values + 0xFFFF\nnotice you must use the full hexadecimal value to grap input from the keyboard\n\nINT #$15 - Update Screen\n- This will swap the current screen with the buffer stored in memory\nso you plot the pixels, than swap the data in memory to the data in video memory\n\nINT #$16 - Plot a Pixel\n- Registers Effected \nX contains the value of the X cordinate of the screen\nY contains the value of the Y cordinate of the screen\nA contains the value of the pixel to be set\n\n\nNotice were working in 8 bit mode since the accumulator is 1 byte \nSo $FF is white and $00 is black\n\n\nINT #$17 - Fill Accumulator with Random value\nA Contains a random number 0x0 - 0xFF\n\nINT #$18 - FIll accumulator with random value range\nX contains start of random value range\nY contains end of random value range\n\nINT #$19 - Test key value from Register Y and put state in Register X\nX contains the value of whether the key is pressed\nY contains the key to test\n\nINT #$056 - Print String to Video Buffer\nUse the special Instruction LDM  with a string (allows backslash escape character sequence)\nExample:\n\nLDA #100\nLDM \"Test\\n\"\n\nwill load Test\\n into Memory location 100 (decimal)\nand store the end point of the memory in register Y\n\n$56 has special memory locations that you should be aware of\n$FFE13\nand $FFE14 contain the X,Y cordinate for printing of the screen\nhow to use:\n; ------------------------ begin code snipit ------------------------------\nLDA #$0\nLDM \"Score:  \\n\"\nSTA $1FE11\nSTY $1FE12\nINT #$13\nLDA #$25\nSTA $FFFF25\nLDA #255\nSTA $FFE13\nLDA #0\nSTA $FFE14\nLDA #$FF\nSTA $1299\nGAME\nLDA $1FE11\nLDY $1FE12\nINT #$56\nLDA $FFE19\nSTA $FFE17\nLDX #$FF\nSTX $FFE15\nLDA #270\nLDX #55\nLDY #0\nINT #$58\nJSR DRAWSCREEN\nINT #$15\n; test if escape key was pressed\nLDY #$1B\nINT #$19\nCPY #0\nBNE END\n\n\n; test for now\nJSR ADDSCORE\n\n; fill the screen with black\nLDX #0\nINT #$57\n\nJMP GAME ; loop back up to the start of the game loop\nEND\n\n; draw rectangle subroutine\n\nDRAWRECT ; takes X,Y, and accumulator \n; ------------------------------------------------------------------\nSTA $FFFF15\nSTX $FFFF11\nSTY $FFFF1\nLDA $FFFF25\nADC #5\nSTA $FFFF25\nMAJOR\nLDY $FFFF1\nMINI \nLDA $FFFF25\nINT #$16\nINY\nLDA $FFFF1\nADC #16\nSTA $FFFF15\nCPY $FFFF15\nBNE MINI\nINX\nLDA $FFFF11\nADC #32\nSTA $FFFF2\nCPX $FFFF2\nBNE MAJOR\nRTS\n\n; draw of the screen subroutine\n\nDRAWSCREEN\nINT #$14\nLDX #5\nLDY #5\nSTX $FFFF18\nSTY $FFFF19\n\nBIGLOOP\nLOOP\nLDA #$FF\nLDX $FFFF18\nLDY $FFFF19\nJSR DRAWRECT\nLDA $FFFF18\nADC #36\nSTA $FFFF18\nCMP #0\nBNE LOOP\nLDX #5\nSTX $FFFF18\nLDA $FFFF19\nADC #20\nSTA $FFFF19\nCMP #0\nBNE BIGLOOP\nRTS\n\n; Add to Score subroutine\nADDSCORE\nLDA $FFE19\nADC #1\nSTA $FFE19\nRTS\n\n\n; ---------------------------- end code snipit\n\nINT #$057 - System callback\nX contains the Address of the callback\n\n - Address #$0 is fill screen with black (fast)\n\n- more to be implemented soon or you can add your own callbacks\n\nINT #$058 - Print Decimal Value to the string\nX contains the screen X cordinate \nY contains the screen Y cordinate\nAccumulator contains the value\nMemory location: $FFE15 contains the color\n\nSection C:\n-- Tutorial on the Language \n\nOkay so why would we want to learn a very old assembly langauge?\nTo better understand the roots of current programming languages:\n\nFirst thing you need to learn about the VM's registers and what they do..\nThere are 3 general purpose registers, X,Y,and A (Accumulator)\nThere is also a special register called the flags register which contains\ninformation that the instructions act on.. For example\n\nLDA #0\nLOOP ADC #1\nCMP #$FF\nBNE LOOP\n\nIn the above statements first we use the LDA mnemoic (or Load Acumulator instruction)\nand give it the operand of $0001 hex or 1 Decimal \nThen we set a code label and name it loop . than we ADC ( Add with carry to acumulator )\nwith the operand of $0001 hex or 1 decimal\nNow heres the important instruction\nCMP $#FF compare the value FF with the value in the acumulator and set bit 0 of \nthe flags register with ethier 1 or 0 depending on the result of the compare\n\nMost of the instructions explain themselves...\n\nBut heres some examples anyway: They can be found in the demo scripts folder..\nIm workin on MasterPiece in the Atari Assembly Language, ill release it soon as i finish\n\n\nNotes for PSP\n-------------\nname your font term.mxf (use a MasterX Font)\nname your script default.ats\nplace default.ats in the same folder as EBOOT.PBP\nload the game as normal\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flostjared%2Fatarivm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flostjared%2Fatarivm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flostjared%2Fatarivm/lists"}