Board index » off-topic » Linker error using Tlink32 (Bad Code?)

Linker error using Tlink32 (Bad Code?)


2005-10-05 06:25:12 AM
off-topic15
Hello,
I have recently become interested in seeing how operating systems get
various information about the computer upon booting. I have stumbled
across a wonderful 16-bit assembly programming book which has given me
most of the basics of the language (Assembly Language For The PC. 3rd
Ed. By John Socha and Peter Norton).
However, since now I am trying my luck at 32-bit programming I have hit
a few walls. The most immediate one is in my first real project, which
is using Int 15h function E820h to return the amount of memory
installed. I am using Ralf Brown's Interrupt list
(www.ctyme.com/intr/rb-1741.htm) for the details of the
interrupt function I am using. I have shortened my source code down the
the simplest it can be to do what I am trying to do, and I'd like to
learn two things.
First, what am I doing wrong in my source code to give me a "bad loc
for fixupp in module near file offset d8". I will dump both my source
code the .LST file at the end to give you reference. I'd like to know
what misconceptions I have about using the 32-bit assembler/linker
which led the the problem in the first place.
Second, is my code correct for loading the memory map into ES:EDI? Yes,
this is off topic and I'll post it to the x86 newsgroup once I get my
code linked, but if I can get this answered it'll save a post.
I do appreciate anyones response to this, here is the source and LST
text:
..386 ;32BIT, 386 AND SUBSETS INSTRUCTIONS
..MODEL FLAT ;FLAT MEMORY ADDRESSING MODE
..DATA ;DATA SEGMENT
BUFFER DB 512 DUP(0h) ;RESERVE 512 BYTES FOR MEMORY MAP
..CODE ;CODE SEGMENT
D_MEM PROC ;MAIN PROCEDURE
MOV EAX,DGROUP ;MOVE SEGMENT ADDRESS OF DATA GROUP TO AX
MOV ES,EAX ;MOVE SEGMENT ADDRESS OF DATA GROUP TO ES
LEA EDI,BUFFER ;MOVE ADDRESS OF BUFFER TO EDI (ES:EDI)
MOV EAX,00000E820h ;FUNCTION FOR GET SYSTEM MEMORY MAP
MOV EDX,0534D4150h ;UNKNOWN, THE INTERRUPT LIST LABELS THIS
AS 'SMAP'
XOR EBX,EBX ;CONTINUATION VALUE, ITS 0h TO START AT
BEGINNING
MOV ECX,014h ;READ 20 BYTES
INT 15h ;TRY TO FILL BUFFER
MOV AH,04Ch ;TERMINATE PROGRAM
INT 21h
D_MEM ENDP
END D_MEM
1 .386 ;32BIT, 386 AND SUBSETS INSTRUCTIONS
2 00000000 .MODEL FLAT ;FLAT MEMORY ADDRESSING MODE
3
4 00000000 .DATA ;DATA SEGMENT
5
6 00000000 0200*(00) BUFFER DB 512 DUP(0h) ;RESERVE 512
BYTES FOR MEMORY MAP
7
8 00000200 .CODE ;CODE SEGMENT
9
10 00000000 D_MEM PROC ;MAIN PROCEDURE
11
12 00000000 B8 00000000s MOV EAX,DGROUP
;MOVE SEGMENT ADDRESS OF DATA GROUP TO AX
13 00000005 8E C0 MOV ES,EAX ;MOVE SEGMENT ADDRESS OF
DATA GROUP TO ES
14 00000007 BF 00000000r LEA EDI,BUFFER ;MOVE ADDRESS OF
BUFFER TO EDI (ES:EDI)
15
16 0000000C B8 0000E820 MOV EAX,00000E820h ;FUNCTION FOR GET
SYSTEM MEMORY MAP
17 00000011 BA 534D4150 MOV EDX,0534D4150h ;UNKNOWN, THE
INTERRUPT LIST LABELS THIS AS 'SMAP'
18 00000016 33 DB XOR EBX,EBX ;CONTINUATION VALUE, ITS 0h
TO START AT BEGINNING
19 00000018 B9 00000014 MOV ECX,014h ;READ 20 BYTES
20 0000001D CD 15 INT 15h ;TRY TO FILL BUFFER
21
22 0000001F B4 4C MOV AH,04Ch ;TERMINATE PROGRAM
23 00000021 CD 21 INT 21h
24
25 00000023 D_MEM ENDP
26
27 END D_MEM
Turbo Assembler Version 5.0 10-04-05 15:25:59 Page 2
Symbol Table
Symbol Name Type Value
??DATE Text "10-04-05"
??FILENAME Text "mem1 "
??TIME Text "15:25:59"
??VERSION Number 0500
@32BIT Text 1
@CODE Text FLAT
@CODESIZE Text 0
@CPU Text 0F0FH
@CURSEG Text _TEXT
@DATA Text FLAT
@DATASIZE Text 0
@FILENAME Text MEM1
@INTERFACE Text 000H
@MODEL Text 1
@STACK Text FLAT
@WORDSIZE Text 4
BUFFER Byte FLAT:0000
D_MEM Near32 FLAT:0000
Groups & Segments Bit Size Align Combine Class
DGROUP Group
_DATA 32 0200 Dword Public DATA
FLAT Group
_TEXT 32 0023 Dword Public CODE
 
 

Re:Linker error using Tlink32 (Bad Code?)

Quote
First, what am I doing wrong in my source code to give me a "bad loc
for fixupp in module near file offset d8". I will dump both my source
code the .LST file at the end to give you reference. I'd like to know
what misconceptions I have about using the 32-bit assembler/linker
which led the the problem in the first place.
TASM and TLink: for 16 bit asm,
TASM32 and TLink32: for 32 bit asm,
Don't mix them up, or you may get some trouble. :-)