Hi! I'm continuing my blog about my SPO
classes. After a brief introduction in Assembly, we are good to hit Lab3. Our
instructor kindly let us choose one project out of five. And of course, we
decided to go with the easiest!
We had to do a two-digit numeric display
where the numbers are incremented or decremented by pressing plus and minus key
in the keyboard. Soon the challenges were reviled as we dive into how to code
it. Should we treat every digit separated or together? How to print them into
the display?
After a moment of reflection, we decided to
handle the digits independently to facilitate the printing display. Also, we
had to add a bit-map representation of the numbers because the 6502 chip
doesn’t know any font.
In this post, I’ll show you the code with
the logic to increment and decrement without displaying anything. You can
monitor the address $13 and $14 to make sure that it is working.
Let me explain how it works. When the
program starts, it will set $13 and $14 to zero, and then it will fall into the
infinite loop called “main.” This loop will know if one of the keys was pressed
and then jump to the proper function. Let’s say that you hit the plus key. It
will call the “incr_l” subroutine,
incrementing the low digit and checking if it is more than 9 (#$0A). If
so, it will call the “incr_h” that will increment the high digit and set the
low digit to zero. If the high digit gets more than 9, the counter resets to
zero. The same logic is applied to decrementing, but instead, it limits at zero
and reset it to 99.
In the next post, I’ll add the numeric
display. See you.
Comments
Post a Comment