Joined: Tue Mar 02, 2004 8:55 am Posts: 996 Location: Berkshire, UK
|
As you only have to support numbers upto 9 its rather easy. Convert your number to an ASCII character by adding $30 (ASCII for '0') and then store it in the memory location that the simulator uses for character output.
If you want to support bigger numbers then you need to convert the binary value into a series of decimal values representing 100's, 10's and ones. There are several techniques for this: iteratively subtracting 100's, then 10's until just 1's are left; dividing by ten to get the last digit as the remainder; converting from binary to BCD the printing the nybbles.
_________________ Andrew Jacobs6502 & PIC Stuff - http://www.obelisk.me.uk/Cross-Platform 6502/65C02/65816 Macro Assembler - http://www.obelisk.me.uk/dev65/Open Source Projects - https://github.com/andrew-jacobs
|
|