[A83] Re: call, stack adresses and free space


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

[A83] Re: call, stack adresses and free space




Yeah, so you could do something like this:

#define myCall(xxxx) call myCall \.dw xxxx

...some code...
mycall(datalocation)

...more code...


myCall:
pop hl	  ; get the address to return to
ld d,(hl) ; get the first byte of your word into d
inc hl	  ; put the ret address a byte further
ld e,(hl) ; get the second byte of your word into e
inc hl    ; put the ret address beyond the defined word
push hl   ; put the ret address back
	
	  ; de should now contain the word defined	
ld a,(de) ; get the byte at de (or do something compleately different if you
	  ; like to)
...do some important routine with a...
ret

...even more code...
.end

Now this is obviously inefficient for most programs, but it's just to show
something's possible.

Someone might even find a use for it. 

--(Peter-Martijn)






 
> 
> >When you make a call, it's more like this:
> >
> >push pp
> >jp xxxx
> >
> >Likewise, a ret is like this:
> >
> >pop <rr> ;16 bit register
> >jp <rr>
> >
> >So, if you do something like this:
> >
> >ld hl,bob
> >push hl
> >ret
> >
> >it would be like
> >
> >jp bob
> 
> 
> This is great! So when you pop hl in the beginning of a
> prgm, you would know where the code is that resumes the
> TI-OS !!!!
> 
>     SUCKER
> 
> _________________________________________________________________
> Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
> 
> 
> 





References: