Article View: net.micro.pc
Article #7424query about Microsoft MASM
From: Joel Coltoff
Date: Fri, 25 Jul 1986 20:47
Date: Fri, 25 Jul 1986 20:47
66 lines
2377 bytes
2377 bytes
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
Technical Details
Message-ID:
<2585@burdvax.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!mnetor!seismo!caip!clyde!cbatt!cbosgd!ukma!psuvm.bitnet!psuvax1!burdvax!coltoffShow Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!caip!clyde!cbatt!cbosgd!ukma!psuvm.bitnet!psuvax1!burdvax!coltoff From: coltoff@burdvax.UUCP (Joel Coltoff) Newsgroups: net.micro.pc Subject: query about Microsoft MASM Message-ID: <2585@burdvax.UUCP> Date: Fri, 25-Jul-86 16:47:27 EDT Article-I.D.: burdvax.2585 Posted: Fri Jul 25 16:47:27 1986 Date-Received: Sat, 26-Jul-86 11:11:13 EDT Distribution: na Organization: System Development Corp., Paoli, PA Lines: 66 Keywords: Microsoft C, MASM