A86: AsmComp


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

A86: AsmComp




On Thu, 9 Apr 1998, Trey Jazz wrote:

> btw does anyone have the compacted opcodes reference? not the hex opcodes
> but the codes that the ti86 compacts it to to save space?

The TI-86 character set is based on ASCII (American Standard Code for
Information Interchange), which anyone planning to do any programming
should take time to memorize.  At least know that the capital letters
start at $41, the lowercase letters start at $61, digits 0-9 are $30-$39,
and space is $20.  You can do some nifty stuff with this code:

1. To convert a number 0-9 to its ASCII character representation, add $30.
   To go the other way, subtract $30.
2. To capitalize letters, bitwise AND the ASCII values with $DF.  To go
   the other way, bitwise OR them with $20.

So, if you have the string "00C9" in your AsmPrgm, it is represented in
memory by $30,$30,$43,$39.  When you run it through AsmComp(), the calc
applies the following algorithm to each pair of characters (c1,c2):

	if ($30 <= c1 <= $39)		| if c1 represents a digit 0-9
		c1 = c1 - $30		|    c1 gets the proper value
	else if ($41 <= c1 <= $46)	| if c1 represents a letter A-F
		c1 = c1 - $41 + $0A;	|    c1 gets the proper value
	else
		syntax error

	if ($30 <= c2 <= $39)		| if c2 represents a digit 0-9
		c2 = c2 - $30		|    c2 gets the proper value
	else if ($41 <= c2 <= $46)	| if c2 represents a letter A-F
		c2 = c2 - $41 + $0A;	|    c2 gets the proper value
	else
		syntax error

	value = $10*c1 + c2;


In my example, this produces

	$10*($30-$30) + ($30-$30)	= $00
	$10*($43-$41+$0A) + ($39-$30)	= $C9

So, what was previously stored as a 4-byte ASCII representation of the
program is now just two bytes in the processor's internal format.

Now that I've spent all this time, I'm wondering whether or not I answered
the right question.  :-)

--------
Dan Eble (mailto:eble@cis.ohio-state.edu)
         (http://www.cis.ohio-state.edu/~eble)

"Behold, how great a matter a little fire kindleth!" -- James 3:5


References: