FIX: Using EXTERNDEF w/ a label May Work IncorrectlyLast reviewed: September 16, 1997Article ID: Q85227 |
6.00 6.00a 6.00b | 6.00 6.00a 6.00b
MS-DOS | OS/2kbtool kbfixlist kbbuglist The information in this article applies to:
SYMPTOMSIn the Microsoft Macro Assembler (MASM) initializing a data structure with the offset of a label declared with EXTERNDEF or PROTO can cause incorrect results.
RESOLUTIONUse EXTERN to perform the same task as the EXTERNDEF; this method will work properly. Also, instead of using OFFSET to initialize a WORD field in the structure, use the label to initialize a NEAR PTR field.
STATUSMicrosoft has confirmed this to be a problem in MASM versions 6.0, 6.0a, and 6.0b. This problem was corrected in MASM for MS-DOS version 6.1.
MORE INFORMATIONEXTERNDEF was introduced as a convenient way to declare shared data structures, variables, symbols, and labels inside a header file. The same functionality can be obtained by using EXTERN and PUBLIC. To replace "EXTERNDEF <name>":
Sample Code; Assemble options needed: /c /Zi ; Link options needed: /CO ; If SOURCE1.ASM and SOURCE2.ASM are assembled and linked together, ; The structure fields an_st.func2 and an_st.func3 will be improperly ; initialized with the offset 0x0000. ;===========================<source1.asm>============================= .MODEL small st_st STRUCT 1b func1 WORD ? func2 WORD ? func3 WORD ? func4 WORD ?st_st ENDS ; Uncomment the line below to have fn_2a properly marked for external ; linkage. Note that if the EXTERNDEF statement is not commented out, ; the EXTERN statement must come first for this to work properly. ;EXTERN fn_2a:NEAR EXTERN fn_1a:NEAR EXTERNDEF fn_2a:NEAR fn_3a PROTO NEAR .DATA an_st st_st { \ offset fn_1a, offset fn_2a, ; This doesn't work. offset fn_3a, ; This doesn't work either. offset fn_4a}.CODE .startup .exit 0fn_4a: retEND ;===========================<source2.asm>============================= .MODEL small EXTERNDEF fn_1a:NEAR EXTERNDEF fn_2a:NEAR EXTERNDEF fn_3a:NEAR .CODE fn_1a: retfn_2a: retfn_3a: retEND
|
Additional reference words: 6.00 6.00a 6.00b buglist6.00 buglist6.00a
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |