DEV Community

gus
gus

Posted on

6502 Math and Strings Part I

This week I'm working on another assembly program for the 6502, with the conditions that the program:

  • Must work in the 6502 Emulator
  • Must output to the character screen as well as the graphics (bitmapped) screen.
  • Must accept user input from the keyboard in some form.
  • Must use some arithmetic/math instructions (to add, subtract, do bitwise operations, or rotate/shift)

Almost all of these are new to me in assembly, with the exception of having printed graphics to the bitmapped display, so this should be fun!

I'll start by breaking down the requirements and getting up to speed on each one so I can then apply them to my program. The first is a given as I'm writing the program directly in the 6502 emulator, so let's dive into the second requirement.

This requirement is twofold - output to the character screen as well as the graphics screen. I've already covered outputting colours to the bitmapped screen here, so the next thing to look into is outputting to the text screen. This can be accomplished in a few ways.

The first is to manually assign a decimal or hexadecimal value representing each ASCII character to an address.

Image description

The second is to use the DCB (Declare Constant Byte) mnemonic to define a string and then assign it to memory.

Image description

You can also use the CHROUT ROM Routine to output characters to the text screen, which works the same as the last way but without manually assigning and iterating memory locations.

In the my next post I'll go into the second two requirements and start writing my program.

Top comments (0)