48 lines
1.8 KiB
Text
48 lines
1.8 KiB
Text
.lf evenodd6502.lst
|
|
.cr 6502
|
|
.tf evenodd6502.obj,ap1
|
|
;------------------------------------------------------
|
|
; Even or Odd for the 6502 by barrym95838 2014.12.10
|
|
; Thanks to sbprojects.com for a very nice assembler!
|
|
; The target for this assembly is an Apple II with
|
|
; mixed-case output capabilities. Apple IIs like to
|
|
; work in '+128' ascii, and this version is tailored
|
|
; to that preference.
|
|
; Tested and verified on AppleWin 1.20.0.0
|
|
;------------------------------------------------------
|
|
; Constant Section
|
|
;
|
|
CharIn = $fd0c ;Specific to the Apple II
|
|
CharOut = $fded ;Specific to the Apple II
|
|
;------------------------------------------------------
|
|
; The main program
|
|
;
|
|
main ldy #sIntro-sbase
|
|
jsr puts ;Print Intro
|
|
loop jsr CharIn ;Get a char from stdin
|
|
cmp #$83 ;Ctrl-C?
|
|
beq done ; yes: end program
|
|
jsr CharOut ;Echo char
|
|
ldy #sOdd-sbase ;Pre-load odd string
|
|
lsr ;LSB of char to carry flag
|
|
bcs isodd
|
|
ldy #sEven-sbase
|
|
isodd jsr puts ;Print appropriate response
|
|
beq loop ;Always taken
|
|
; Output NUL-terminated string @ offset Y
|
|
;
|
|
puts lda sbase,y ;Get string char
|
|
beq done ;Done if NUL
|
|
jsr CharOut ;Output the char
|
|
iny ;Point to next char
|
|
bne puts ;Loop up to 255 times
|
|
done rts ;Return to caller
|
|
;------------------------------------------------------
|
|
; String Constants (in '+128' ascii, Apple II style)
|
|
;
|
|
sbase: ;String base address
|
|
sIntro .az -"Hit any key (Ctrl-C to quit):",-#13
|
|
sEven .az -" is even.",-#13
|
|
sOdd .az -" is odd.",-#13
|
|
;------------------------------------------------------
|
|
.en
|