Processors (Intel® Core™, Intel® Xeon®, etc); processor utilities and programs (Intel® Processor Identification Utility, Intel® Extreme Tuning Utility, Intel® Easy Streaming Wizard, etc.)
12599 Discussions

in recursive macro call in macro processor algorithm of intel 8086, why s(sp) is -1 at first?


I am taking a system programming class, and in the class I learned intel 8086 processor. I'm studying recursive macro call algorithm. But I wonder why first s(sp) becomes -1 when stack pointer(==sp) is 1. I know little about intel 8086 processor.

here's pseudo code

SP <- 1;
N(the number of actual arguments) <- 0;

Repeat{ //macro call 
S(SP) <- -1;
S(SP+1) <- MDT index from MDT;

insert actual argument to S(SP+2, ..., S(SP+N+1);
S(SP+1) <- S(SP+1)+1;

repeat{ //macro call in macro 

 read S(SP) from MDT;
match actual arguments using S(SP+2),...,S(SP+N+1);
complete the instruction;
S(SP+1) <- S(SP+1)+1;
if(ENDM) SP <- S(SP); //go to sp before macro call 

if(macro call){

S(SP+n+2) <- SP; 
SP <- SP+N+2;
S(SP+1) <-MNT의 MDT index;
insert actual arguments to S(SP+2),...,S(SP+N+1);
S(SP+1) <- S(SP+1)+1;

else{ print the expanded instruction; }

else{ print read instruction;}


until (NOT END instruction)
END expanded macro procedure;

0 Kudos
0 Replies