delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/06/05/16:00:21

From: "Frank Cornelis" <fcorn AT dot DOT digibel DOT be>
Newsgroups: comp.os.msdos.djgpp
Subject: DJGPP 2.01
Date: Fri, 5 Jun 1998 21:52:31 +0200
Organization: BELGACOM-SKYNET SA/NV
Lines: 108
Message-ID: <6l9ikr$5bi$1@news0.skynet.be>
NNTP-Posting-Host: dialup48.aalst.skynet.be
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Hi,
I've got a serious problem using DJGPP 2.01
I'm working under Linux Slackware 3.2
I want to make 16 bit plain binary files.
What I did:
In a file called "myasm.asm"
BITS 16
GLOBAL myproc1
GLOBAL myproc2
myproc1
 ret
myproc2
 ret
----
Compile this using
nasm -f elf myasm.asm
Next make a file called "myasm.h"
void myproc1 ();
void myproc2 ();
----
Next make a file called "main.c"
#include "myasm.h"
void main () {
 myproc1 ();
 myproc2 ();
}
----
Compile this using
gcc -c -Wall main.c
Do:
ld -o main -Ttext 0x0000 -e main main.o myasm.o
objcopy -R .note -R .comment -S -O binary main main.bin
Now do:
ndisasm main.bin
Then you get something like:
00000000  55                push bp
00000001  89E5              mov bp,sp
00000003  E81800            call 0x1e
00000006  0000              add [bx+si],al
00000008  E81400            call 0x1f
0000000B  0000              add [bx+si],al
0000000D  89EC              mov sp,bp
0000000F  5D                pop bp
00000010  C3                ret
00000011  90                nop
00000012  90                nop
00000013  90                nop
00000014  90                nop
00000015  90                nop
00000016  90                nop
00000017  90                nop
00000018  90                nop
00000019  90                nop
0000001A  90                nop
0000001B  90                nop
0000001C  90                nop
0000001D  90                nop
0000001E  90                nop
0000001F  90                nop
00000020  C3                ret
00000021  C3                ret
----
You can see this is a 32-bit file,
because the CALLs are using 4 bytes for the
memory address and the CALLs points 2 bytes
besides the real myproc1 (at offset 20) and
myproc2 (at offset 21), because of the large
address.
I _need_ a plain 16 bit binary file for an
OS Loader. (I hate to do it all in pure asm)
I made the dos-gcc, dos-ld, dos-objcopy using:
gcc-2.7.2.2.tar.gz & binutils-2.7.tar.gz on
Slackware 3.2 (normal configuration).
Making went OK.
I did:
dos-gcc -c -Wall main.c
All OK.
But when I do:
ld -o main -Ttext 0x0000 -e main main.o myasm.o
I get:
ld: warning: cannot find entry symbol main; defaulting to 0000000000000000
main.o(.text+0x4): undefined reference to `___main'
main.o(.text+0x9): undefined reference to `_myproc1'
main.o(.text+0xe): undefined reference to `_myproc2'
----
And when I do:
dos-ld -o main -Ttext 0x0000 -e main main.o myasm.o
I get:
main.o: file not recognized: File format not recognized
----
So how do it without getting errors?
Some background info on my system:
gcc --version
2.7.2.1
bash -version
GNU bash, version 1.14.7(1)
arch
i586
uname -s
Linux
uname -r
2.0.29
You can reach me at:
<fcorn AT freeusers DOT digibel DOT be>
Thanks.



- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019