My First Assembler Trips

As you might have noticed (harhar) I typed in a lot of programs for the KIM-1 lately. And I got to a point where I can read and understand this programs. Yay.

Now the following problem occured: A prg in 'Best of Micro Vol. II' is Conways Game of Life for the KIM-1 equipped with a video expansion card. And hey, guess what, I do have a KIM-1 clone with a Graphics card. In this Program the vertical and horizontal coordinates are handed over in a hexadecimal number like this ESC=VH(Text) where V and H are positions in hexadecimal.

My PiGFX solution sadly wants a ascii streamed number as input, for example ESC[10,15f means Move to , The numer 10 here is transfered over the serial line as "$31$30" (ascii for 1 and 0 ... The numbers start in Ascii at $30)

But how do I translate a HEX number to a two byte ascii stream?

  1. how often can you subtract $A of your HEX number before it turns negative?
  2. add $30 and you have your first byte.
  3. the rest + $30 is the 2nd byte.

Here's an example:

2A 42 how often does $A fit ? Whats the Rest?
(4*A)+2 4 * 10 + 2 aahhh, 4 times, 2 rest ... Now add $30 to each result
byte1 and byte 2 in basic this would be
$34 and $32 52 and 50 chr$(52) + chr$(50)

Now you can stream $1B ('ESC') $5B ('[') $34 ('4') $32 ('2') $3B (';') $34 ('4') $32 ('2') $66 ('f') and the next letters will be printed at position 42,42

My brain is crippled now. more l8r