Return Must Match Memory Model for CALL to Label in ProcLast reviewed: January 23, 1995Article ID: Q70671 |
The information in this article applies to:
SUMMARYWith the Macro Assembler (MASM), if a CALL is made to a label within a procedure, a near call is generated by default. Depending on the memory model being used, you may need to explicitly specify the correct return.
MORE INFORMATIONThe standard RET instruction pops off the return address depending on the memory model. In a small memory model program, the RET instruction is converted to a RETN, which only pops off the offset to return. In medium and large memory models, the RET is converted to RETF, which pops off both the segment and offset to return from the far call. Because a call to a label within a procedure always results in a near call, the RETF instruction that is generated in medium and large models will pop a segment value for the return address that was never pushed. To ensure that the right size address is popped off the stack relative to that pushed on the stack, one of the following methods may be used:
Sample Code; Assemble options needed : none .MODEL large .STACK .CODE start: call proc1
mov ah, 4ch mov al, 0 int 21h proc1 PROC ; #1 - add PUSH CS instruction here CALL label1 ; #2 - change call to CALL FAR PTR label1 RET label1: ; #3 - change label to label1 LABEL FAR RET ; #4 - change return to RETN proc1 ENDPEND start
|
Additional reference words: kbinf 5.10 5.10 6.00 6.00a 6.00b
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |