Created
June 29, 2025 12:42
-
-
Save greg76/55866c6bfc1f8140bd09b20f00e02e07 to your computer and use it in GitHub Desktop.
C64 assembly hello world
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ; | |
| ; assembly example to write a message on the Commodore 64 screen | |
| ; | |
| ; address of the basic loader. the RUN command is looking for the first instruction here. | |
| ; the assembly code should be compiled to start here as well, so it can be run with a sys command | |
| *=$0801 | |
| ; this is the basic loader, this is mimicing of jumping in to the assembly code with a sys command | |
| !byte $0c,$08,$b5,$07,$9e,$20,$32,$30,$36,$32,$00,$00,$00 | |
| jmp main | |
| ; this is a "data segment" where we define our variables, strings, tables, any data your program needs | |
| .hellotext | |
| !scr "greetings to csillik rasterbar laszlo!",0 | |
| !set ofs = 1 ; this is just an offset of how much the message should be shifted to the right. | |
| ; this is the actual code part that gets executed | |
| main | |
| ldy #0 ; y is one of the registers of the CPU we will use it to iterate over our message | |
| hello | |
| lda .hellotext,y ; the y-th chacter of our message is loaded into the A register | |
| beq + ; branch on result zero (the message is zero padded, when A contains zero we should terminate | |
| sta $400+ofs,y ; default display memory address (we store the character stored in reg. A on ofs+y -th position) | |
| lda #1 ; color code of white (1) is loaded into reg. A (https://www.c64-wiki.com/wiki/Color) | |
| sta $d800+ofs,y ; color ram (the color code has to be written to the color ram, offsetted with the same value) | |
| iny ; increment Y so we can read the next character and write it to the next location | |
| jmp hello | |
| + | |
| rts |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment