BigDumbDinosaur wrote:
Printing $41 via the BSOUT ($FFD2) kernel subroutine will display an 'A'.
Sounds like a good worked example. I'll use
easy6502 to assemble and to get a listing:
Code:
Address Hexdump Dissassembly
-------------------------------
$0600 a9 41 LDA #$41
$0602 20 d2 ff JSR $ffd2
$0605 60 RTS
To run this using SYS we'll need to convert the program to decimal bytes and POKE them in. (Easy6502 defaults to producing code at $600 and always disassembles from there, so I've left that as is. In this case the code isn't sensitive to where it's placed)
Code:
POKE 1536,169
POKE 1537,65
POKE 1538,32
POKE 1539,210
POKE 1540,255
POKE 1541,96
SYS 1536
and it works as expected:
Attachment:
File comment: Screenshot from http://www.thomasskibo.com/6502/pet2001/
PRINTA-PET.png [ 13.34 KiB | Viewed 1365 times ]
As an optimisation, which could easily be confusing for the beginner, you can always replace a sequence
Code:
JSR somewhere
RTS
with the shorter and faster alternative
Code:
JMP somewhere
To do that, we note that JMP is 4c in hex, or 76 decimal, so we need
Code:
POKE 1538,76
instead.