Personal Computer News
22nd September 1984
Published in Personal Computer News #079
Ups And Downs Of Machine Code
Q. I am learning machine code and I would like to move characters both vertically and horizontally on the screen. I have managed to move graphics smoothly from left to right but I am having trouble moving them up and down because of the way the screen is laid out.
I would be very grateful if you could print a formula for printing on the screen.
Simon Trigg
Baldock, Herts
A. Since you don't say which machine you are using it is tricky to be of help (How long, Lord...?)
But, undaunted, let us see how far we can get.
In machine code there are generally two ways to display characters on screen - memory maps and normal print routines. Which you use depends very much on the machines and the application. If you have managed side-to-side motion you're already more than halfway.
Our best guess is that you're using a screen location then INCrementing or DECrementing the required value for right and left movement respectively.
The trick with moving up and down in a similar fashion is that every micro uses a different mapping system - some have the lowest value in the top-left corner, others in bottom-left. Generally you'll find that top-left is the screen origin, in which case you need to add one line-length to the origin to move a character to the start of the second screen line, or subtract a line length for upwards motion.
That's memory mapping. Generally, using ROM routines is easier where they are available. For example, on the Commodore 64 you can call a Kernel routine which will print a character at the position specified by the contents of two of the processor's registers.
Your best bet is to buy a book dedicated to machine code on your micro, or write to us again telling us what machine you're using.
After all, we're not telepaths, dammit.