Re: A86: link86.asm


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

Re: A86: link86.asm




When you make a call, the address to return after the
call is stored in the stack... if you want it to
return to the previous routine you do "pop hl" before
the ret... try this code...

routine1:
 call _clrLCD
 call _homeup
 ld hl,str_routine1
 call _puts
 call _newline
 call routine2
 ld hl,str_routine1
 call _puts
 call _newline
 ret
routine2:
 ld hl,str_routine2
 call _puts
 call _newline
 call routine3
 ld hl,str_routine2
 call _puts
 call _newline
 ret
routine3:
 ld hl,str_routine3
 call _puts
 call _newline
 pop hl            ;go back to routine1
 ret

str_routine1:
 .db "In routine1",0
str_routine2:
 .db "In routine2",0
str_routine3:
 .db "In routine3",0

The output for this code is this:
In routine1
In routine2
In routine3
In routine1


--- Andrew T <ironman_294@hotmail.com> wrote:
> 
> Ok there are three parts of these calls that i dont
> undestand
> On is after it has opend red or opend white it goes
> and waits for
> %00000011 wich is both active but i didn't see where
> made active thus 
> wouldn't it just go forver?  Second I don't
> understand both
> 
> rbTest_ON:
> ld a,(_OP1)
> inc a
> ld (_OP1),a
> cp 255
> ret nz
> ;why is it poped?
> pop hl  ;Back to the place you were before.	Gotta
> love it!
> xor a
> ret
> 
> 
> sbSendTest_ON:
> ld a,%00111111
> out (1),a
> nop
> nop
> in a,(1)
> bit 6,a
> ret nz
> ;same thing why was it poped?
> pop hl
> ; pop hl		; instead of returning, jump to
> ; jp Quit		; some program exit code
> ret
> 
> 
> 
>
______________________________________________________
> Get Your Private, Free Email at
> http://www.hotmail.com
> 
> 

__________________________________________________
Do You Yahoo!?
Bid and sell for free at http://auctions.yahoo.com