Re: A83: Re: ROM calls


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

Re: A83: Re: ROM calls




>
>The call command moves the stack pointer (SP) and the program counter 
>(PC). Like this: -SP=PC,PC=nn where nn is the location being called.
>

and in plain english that is: :)

it pushes the the address of the next instruction onto the stack and jumps
to the memorylocation specified..
the 'ret' instructions then pops the 'return-address' from the stack and
jumps to it (= puts it in PC..)
that is why your program fucks up if you dont pop your pushed bytes
properly in your sub-routine..

example  (for you who likes that.. :)

	call sub303	    this pushes the addresss of 
	ld   a,42	<- THIS instruction onto the stack and then jumps to
               	...              'sub303'
	...
	...
sub303
	...
	...
	ret		This then pops two bytes (an address) from the stack
			and puts this in the PC, thus making a jump back to the
			'ld   a,42' instruction, if you havent messed the stack 			up..

Got it?

//Olle


References: