Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
06/01/01 10:26
Read: times


 
#12100 - RE: POP&PUSH
I waited a while to see if anybody with more knowledge would answer this but...here goes.
First off these questions are being answered in the tutorial pages you can find on the left of the main page, but I myself have felt lost even after reading them.

A program could work straight down from the top, performing one command after the other until finished and maybe start over again. But most of the time registers which have a global use might be overwritten by a command along the line. If and when this is undesired, that's when you use PUSH and POP. For instance: The ACCU, used in virtually every statement is pushed when a subroutine is called together with the PSW and DPTR.

example:

SUBROUTINE: ;just a dummy name
PUSH ACC ;save the accu
PUSH PSW ;program status word
PUSH DPL ;low byte datapointer
PUSH DPH ;high byte
do something: ;could be a program here
finished doing something?:
POP DPH ;put
POP DPL ;everything
POP PSW ;back in
POP ACC ;place
RET ;return to main

main:
have a program with a
CALL SUBROUTINE ;step out of main!
continue program like it was
JMP main ;repeat
end

hope this helps

PS but generally the PUSH and POP is used to save any register on the stack
on a temp. basis.


List of 5 messages in thread
TopicAuthorDate
POP&PUSH            01/01/70 00:00      
RE: POP&PUSH            01/01/70 00:00      
RE: POP&PUSH            01/01/70 00:00      
RE: POP&PUSH            01/01/70 00:00      
RE: POP&PUSH            01/01/70 00:00      

Back to Subject List