diff options
Diffstat (limited to 'hello.s')
-rw-r--r-- | hello.s | 87 |
1 files changed, 82 insertions, 5 deletions
@@ -17,10 +17,23 @@ .endif .org start_addr +print_addr: + jsr pa +pa: ; pull return address, print it (don't put it back on the stack) + pla + sec + sbc #2 ; pa-1 was pushed, we want to print print_addr + sta sptr ; lo byte + pla + sbc #0 + sta sptr+1 + jsr printhex + lda sptr + jmp printhex + rts + _main: - ldx #0 - stx COLCRS - inx + ldx #1 stx CRSINH lda #<str1 ldx #>str1 @@ -32,6 +45,33 @@ _main: jsr printstr lda #'.' jsr printa + lda #EOL + jsr printa + lda #<addr_str + ldx #>addr_str + jsr printstr + jsr print_addr + lda #EOL + jsr printa + lda #<end_str + ldx #>end_str + jsr printstr + lda #>(end_addr-1) + jsr printhex + lda #<(end_addr-1) + jsr printhex + lda #<memlo_str + ldx #>memlo_str + jsr printstr + lda MEMLO+1 + jsr printhex + lda MEMLO + jsr printhex + lda #<relax_str + ldx #>relax_str + jsr printstr + jsr junksub + cycle: lda RTCLOK+2 and #$f0 @@ -55,6 +95,30 @@ printchr: bne strloop rts + ; Subroutine: Print A register in hex. +printhex: + pha ; stash argument + lsr ; shift right 4 times, + lsr ; to get the first hex digit + lsr ; (aka nybble) into the bottom + lsr ; 4 bit positions. + jsr printxdig ; print the top nybble. + pla ; restore original value... + and #$0f ; mask off high nybble + ; fall through to print the 2nd digit. + + ; Subroutine: Print a nybble (A=0 to $0f) in hex. +printxdig: + ora #$30 ; 0-9 now ASCII... + cmp #$3a ; do we have A-F? + bcc xok ; if not, don't adjust it + adc #$26 ; A-F now ASCII: $3a + $26 + 1 (carry always set) = $61 (a) +xok: + ; fall through to print the digit. + + ; Subroutine: Print ATASCII character in A. + ; Assumes IOCB #0 is opened on the E: device, which is how the + ; Atari boots up. Uses "call-by-RTS" (weird looking but standard). printa: tax lda ICPTH ; the print-one-byte vector for IOCB 0. @@ -64,8 +128,21 @@ printa: txa rts -str1: .byte "Hello",0 -str2: .byte "World",0 +junksub: + .repeat 512 + nop + .endrep + lda #'O' + jsr printa + lda #'K' + jmp printa + +str1: .byte "Hello",0 +str2: .byte "World",0 +addr_str: .byte EOL, "I am currently located at $",0 +end_str: .byte "My code ends at $",0 +memlo_str: .byte EOL, "MEMLO is currently set to $",0 +relax_str: .byte EOL, EOL, "Watchen das blinkenlights...",EOL,0 .ifndef RAW end_addr: |