[net.micro.pc] query about Microsoft MASM

coltoff@burdvax.UUCP (Joel Coltoff) (07/25/86)

I am tyring to get at a global in a C program from an assembly
routine. Although everything links ok I am not grabbing the right
variable from memory when the program runs. The address the linker puts
in for the "mov" instructions isn't the same as the one it shows in the
map it produces. Can anyone see what I am doing wrong in the code
below. I've tried to copy the code that the C compiler generates and am
not having any luck. ANY advice would be greatly appreciated. Thanks
in advance,

        Joel Coltoff
        {psuvax1,sdcrdcf}!burdvax!coltoff

int monitor_stackptr;
int monitor_stackbase;

main()
{

/* initialize the variables */
        monitor_stackptr = 0x7ff;
        monitor_stackbase = 0;
/* print them out */
        prmon();

}

PRMON_TEXT      SEGMENT  BYTE PUBLIC 'CODE'
PRMON_TEXT      ENDS
CONST   SEGMENT  WORD PUBLIC 'CONST'
CONST   ENDS
_BSS    SEGMENT  WORD PUBLIC 'BSS'
_BSS    ENDS
_DATA   SEGMENT  WORD PUBLIC 'DATA'
_DATA   ENDS
DGROUP  GROUP   CONST,  _BSS,   _DATA
        ASSUME  CS: PRMON_TEXT, DS: DGROUP, SS: DGROUP, ES: DGROUP
PUBLIC  _prmon
EXTRN   _print_word:FAR
EXTRN   _monitor_stackptr:WORD
EXTRN   _monitor_stackbase:WORD
_DATA   SEGMENT
_DATA   ENDS
CONST   SEGMENT
$T20000 dw      SEG _monitor_stackptr
$T20001 dw      SEG _monitor_stackbase
CONST   ENDS
PRMON_TEXT      SEGMENT
        PUBLIC  _prmon
_prmon  PROC FAR
        push    bp
        mov     bp,sp
        mov     es, $T20000
        mov     ax, es:_monitor_stackptr
        push    ax
        call    FAR PTR _print_word
        add     sp, 2
        mov     es, $T20001
        mov     ax, es:_monitor_stackbase
        push    ax
        call    FAR PTR _print_word
        add     sp, 2
        pop     bp
        ret
_prmon  ENDP
PRMON_TEXT      ENDS
END