www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/01/06/19:16:06

From: "Steve Patton" <leaphe AT pemail DOT net>
Newsgroups: comp.os.msdos.djgpp
Subject: NASM Binary files
Date: Tue, 6 Jan 1998 17:12:16 -0700
Organization: AT&T WorldNet Services
Lines: 50
Message-ID: <68uha0$kfm@bgtnsc02.worldnet.att.net>
NNTP-Posting-Host: 12.67.33.156
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Hello, I'm trying to write DLL files for a program that I'm making.  I'm
trying to make a library that I can send a request to for a file, and it
will load it using DOS interrupts and do the sorts (I know this is definitly
reinventing the wheel, but I really need control and to learn how to do this
by using something I already know how to do.  What I have is I have an .ASM
file that I will compile with NASM (because I don't think I can compile a
straight binary file using GCC or GAS or whatever).  So this is what I have

Header:
      dd     123           ; just a sample header, you get the picture
BITS 32
org 0x0
start:
    mov ah, 02h
    mov al, "a"
    int 21h
    ret
message:
     db  "This is a message that will be displayed", 10, 13, "$"


Now this compiles correctly, and it actually will print the letter 'a' to
the screen (pardon if it's incorrect code, I'm typing it from memory).  Now
my problem is I have no way to access local variables, such as message.  I
set es to equal cs (using the ax register to translate of course), such as

mov ax, cs
mov es, ax

and I set di to equal message.  and I load [di] into al such as

mov al, [di]

NOW, this returns garbled information.  I believe it has to do that all my
assembly experience (besides using a normal GCC assembly .S file) is dealt
with 16-bit, and not 32-bit addressing.  So can someone explain what I am
doing wrong?  BTW, I have a function prototype as

int (*proc)(void);

and I allocate a buffer, load the file directly into memory, and set proc to
the buffer position, and increment it to the start of the actual code (by
skipping the buffer).  This seems to work fine, it executes correctly, but I
can't get access using pointers very well.  Any help would be greatly
appreciated.

-Steve



- Raw text -


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