Classic Computer Magazine Archive COMPUTE! ISSUE 49 / JUNE 1984 / PAGE 102


Larry Isaacs

This month we'll take a look at part of a disassembly of the machine language drawing routines which were presented last month. For those who are learning 6502 machine language programming, there are a few items you may find interesting in the source listing for these routines. First of all, if you are new to interfacing machine language routines to BASIC, you can refer to the GETINT subroutine. This subroutine will evaluate an integer expression and return the resulting value. Typically, a machine language routine will need only integer arguments, assuming it needs arguments at all. One potential problem with using a routine like GETINT is that the integer is signed. Integer values greater than 32767 would have to be entered as <value> -65536 before they could be fetched by this routine.

Another thing you might note is how a multiplication by 320 was accomplished in the PIXADR subroutine. The code is based on the fact that multiplication and division by powers of two can be done with left and right shifts of the binary number in question. By converting the expression (320*Y) to (256*Y + 64*Y), the multiplication can be carried out by simple shifting. Multiplying by 256 is done by taking the one-byte Y value and storing it as the high byte of a two-byte number. The low byte would be set to zero. The term 64*Y was obtained by dividing the 256*Y term by 4 (that is, two right shifts). Adding the two terms together gives 320*Y.

I hope the comments in the source code provide enough information to understand what the program is doing. If you have an assembler at your disposal, you are certainly welcome to use any of the routines here for your own experiments.