[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

16-Bit Math on 8-Bit Numbers (HPLOT in Machine Language, Part II)



OK, remember my question about what variables to set up for Applesoft's
HPLOT routine in machine language? Forget it! It's solved, and now I'm
changing my question.

I need a machine language routine that will:

* take a number from 0 to 34 at zero page address $EB, multiply it by 8,
and put the 16-bit result in $FA/$FB, low byte first
* take a number from 0 to 23 at zero page address $EC, multiply it by 8,
and put the 8-bit result in $FC
* take a number from 0 to 511 at zero page addresses $ED/$EE (low byte
first), multiply it by 8, add 20480 to the product, and put the 16-bit
result in $FD/$FE, low byte first

I tried this a couple of times using ROL and ADC instructions but my whole
routine crashed.

By the way, this is for a 8-bit 6502, so I can't use the Apple IIgs's
16-bit instructions. If this was only going to be for IIgs, I would do
that, but I want this routine to work for all of the Apple II computers.

For those on comp.sys.apple2 who can read this, please send responses to
my e-mail address because I can't get any messages from that newsgroup.

Anybody care to know what this is for? I'll tell you. I'm making a 9-bit
text system called Sabine. Each character in Sabine's font is 8x8
(actually 7x7 with 1-pixel spacing), and there are 512 characters in all
(the last 8 of them are user defined). I have successfully written a
routine that plots eight bytes of bitmap data onto the high resolution
graphics screen at a specific coordinate, but I need the routine to
translate character numbers into memory addresses and coordinates on a
35x24 resolution screen (you can fit 24 rows of 35 of Sabine's characters
into the screen) to coordinates on a 280x192 resolution screen (the
standard high resolution screen). That is what the multiplication and
addition are for.

After I get the math routine done, I can write a custom character output
routine that can print strings of Sabine characters onto the screen and/or
add text support to my ColorDraw program.

I can't wait to write a word processing program and call it Sabine's
Notebook :)  (that's just a coincidence, by the way).

-- 
/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
jonrelay@napanet.net                        dimension18.cjb.net
"Remember, if it's not a secure web server, it's an _insecure_
web server!"                                              -- Me

 *_     Syntax Error: an error on a criminal's tax record.
   |    Bad Subscript: a criminal reading a book on a subway.
  ---   Unimplemented Trap: when a bear trap isn't set up 
 |' ,|  properly and thus does not work.
  ---   Overflow: too many ice cubes.      <Can't Restart>

Figure 1.1: Most Applications Crash - If Not, The Operating
            System Hangs

       I just got a Sony PlayStation for my birthday!
          Don't forget: Tammy Day on February 15th!
Please remove capital letters from my e-mail address to respond.