© Thomas Kunz 2000
SCE 574
99
   Subroutine Call/Return
äCALL does a push of the instruction pointer (IP) onto the stack automatically (FAR call also pushes segment information)
äRET pops the IP off the stack automatically (If FAR call, the FAR return is done automatically)
äConsider the following nested subroutines
äPRINTB prints 4 hexadecimal digits
äPRINTB: MOV AL,BH ;get high order byte
ä CALL PBYTE ;print both nibbles
ä MOV AL,BL ;get low order byte
ä CALL PBYTE ; print both nibbles
ä RET
äPBYTE: PUSH AX ;saves a copy of value AX
ä MOV CL,4 ;shift AL right 4 bits
ä SHR AL,CL
ä CALL PRINT ;print hex digit low nibble
ä ;of AL
ä POP AX ;restore value of AX
ä CALL PRINT ;print second hex digit
ä RET
Always push
words not
bytes