Re: A86: simple code I can't figure out


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

Re: A86: simple code I can't figure out




In a message dated 7/7/99 2:57:31 PM !!!First Boot!!!, IVlusicman@aol.com 
writes:

> 
>  Thanks  A LOT...but I don't exactly know what you mean by "you could make 
>  this a <jp _clrLCD>". As far as I know (which isn't too far) "jp" would 
mean 
> 
>  to jump to a certain label, right? How could you "jump" to a clear-the-
> screen 
>  command?

ok  in one of the include files are a bunch of aliases. _clrLCD is one of 
them. TI told us the address of a rom routine that will clear the screen and 
save us the trouble of doing this
_my_own_clrLCD:
ld hl,$fc00		;i hope you can understand this
ld de,$fc01		;hl = videomem de=videomem+1
ld bc.1023		;whole screen -1
ld (hl),0			;clear the first byte of video mem	
ldir				;copy it to the rest of video mem
ret

thats a pain just to clear the screen isint it

well open up the include files and you see something like this
_clrLCD                          equ            4A7Eh
this tells the assembler to replace _clrLCD with 4A7Eh
when you compile a file the assembler figures out the address of every label 
in your code.
you see a ld hl,stringlabel  but the calc sees ld hl,$4f02  that is just a 
random example ok
back to the clrLCD routine at the address 4a7eh in the rom is another 
address. this second address tells us the where the "real" clrLCD routine is. 
each rom version has a slightly diffrent rom so ti made one rom page the same 
so our progs work
at the second address is code similar to the above example
at the end of that code is a ret
so when you call it it returns to the calling part
whenever a call is executed the current value of the pc (program counter) is 
pushed onto the stack
then when a ret comes along the pc is popped off the stack  so when your asm 
prog gets called from a shell or the homescreen the pc is saved and at the 
last ret it goes back to what called it
so if you jp there then the ret restores control to whatever called it

wow there is my second tutorial
i can just put this on my page and it should help some people

later
	matt c