Created
February 28, 2015 17:23
-
-
Save reidrac/eb5ac9d453efe1fc7a63 to your computer and use it in GitHub Desktop.
This file contains 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
#include "d64.h" | |
int | |
main() | |
{ | |
cputs("Hello 6502 world from C!\n"); | |
return 0; | |
} |
This file contains 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
; | |
; File generated by cc65 v 2.14 - Git a0c4ca9 | |
; | |
.fopt compiler,"cc65 v 2.14 - Git a0c4ca9" | |
.setcpu "6502" | |
.smart on | |
.autoimport on | |
.case on | |
.debuginfo off | |
.importzp sp, sreg, regsave, regbank | |
.importzp tmp1, tmp2, tmp3, tmp4, ptr1, ptr2, ptr3, ptr4 | |
.macpack longbranch | |
.forceimport __STARTUP__ | |
.import _cputs | |
.export _main | |
.segment "RODATA" | |
L0003: | |
.byte $48,$65,$6C,$6C,$6F,$20,$36,$35,$30,$32,$20,$77,$6F,$72,$6C,$64 | |
.byte $20,$66,$72,$6F,$6D,$20,$43,$21,$0A,$00 | |
; --------------------------------------------------------------- | |
; int __near__ main (void) | |
; --------------------------------------------------------------- | |
.segment "CODE" | |
.proc _main: near | |
.segment "CODE" | |
lda #<(L0003) | |
ldx #>(L0003) | |
jsr _cputs | |
ldx #$00 | |
txa | |
rts | |
.endproc |
This file contains 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
; hello.s | |
; Hello World example using syscalls | |
; | |
.segment "CODE" | |
.macro sys ; syscall | |
.byte $02 | |
.endmacro | |
main: | |
tsx ; save the stack pointer | |
lda #<message | |
pha | |
lda #>message | |
pha | |
lda #$11 ; put string | |
sys | |
txs ; restore the stack | |
lda #$00 ; terminate program | |
pha ; also: success (0) | |
sys | |
jmp * ; never gets here | |
message: | |
.byte "Hello world from 6502!", $0a, 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment