Re: A85: questions


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

Re: A85: questions




>2)  what does the adding hl and de with the (programaddr) (or whatever)
>stuff do?  why is it necesary in Zshell, but nowhere else?  I fi'm porting
>a prog to the 86 say, what would some of the equivalent stuff be?
>thanx much
>

On the ti85, the location of the variables (strings specifically) in
the calculator's RAM are always changing.  Because of this, the
location of the addresses are always changing within the program that
you are making.  the first line of code that you write is the ".org
0".  when using instructions such as call, jp or ld, and you want to
use a 16-bit address within the program, the actual machine code is
calculated by adding the origin of the program (0 in this case) to the
16-bit address.  for example:
	ld hl,MyData	;MyData is a label that is the number of
			;bytes from the .org of the program.  this is
			;a 16-bit number that tells the *offset* from 
			;the beginning of your program.  You
			;then add the origin number (0) to find the
			;actual machine code.
	ld de,(PROGRAM_ADDR)
			;hl now has the address of my data relative
			;to the start of the program, but this does
			;not take into account the fact that the
			;program could be any where in memory.
			;so we look in PROG_ADDR to find the
			;location of the first byte of the code
	add hl,de
			;now, once these 2 addresses are added,
			;the exact location of MyData in memory
			;is known
	......
	more code
	......
MyData:
	.db 7,7

To overcome this repetitive action, shells such as Usgard and Rigel
take away the need for PROGRAM_ADDR addition using a table of offsets
or having the program always moved to a fixed address (the ".org"
value is the address of where it is moved), respectively.  And i
believe that the 86 uses fixed address relocation (like Rigel), but i
am not certain.  Maybe someone else can answer that for sure.
BTW, does anyone else the that this list is completely dead?  then
again, maybe its not the list, its the ti85 :(.
-mike
 mgp4007@omega.uta.edu


Follow-Ups: References: