RosettaCodeData/Task/Loops-Downward-for/6502-Assembly/loops-downward-for.6502
Ingy döt Net db842d013d A-M baby
2013-04-10 21:29:02 -07:00

38 lines
905 B
Text

;An OS/hardware specific routine that is setup to display the Ascii character
;value contained in the Accumulator
Send = $9000 ;routine not implemented here
PrintNewLine = $9050 ;routine not implemented here
*= $8000 ;set base address
Start PHA ;push Accumulator and Y register onto stack
TYA
PHA
LDY #10 ;set Y register to loop start value
TYA ;place loop value in the Accumulator
Loop JSR PrintTwoDigits
JSR PrintNewLine
DEY ;decrement loop value
BPL Loop ;continue loop if sign flag is clear
PLA ;pop Y register and Accumulator off of stack
TAY
PLA
RTS ;exit
;Print value in Accumulator as two hex digits
PrintTwoDigits
PHA
LSR
LSR
LSR
LSR
JSR PrintDigit
PLA
AND #$0F
JSR PrintDigit
RTS
;Convert value in Accumulator to an Ascii hex digit
PrintDigit
ORA #$30
JSR Send ;routine not implemented here
RTS