Re: Loading Memory Addresses
- From: "Jim Carlock" <anonymous@xxxxxxxxx>
- Date: Wed, 09 Aug 2006 02:33:37 GMT
Jim Carlock wrote:
....
.286
.MODEL TINY
"Frank Kotler" <fbkotler@xxxxxxxxxxx> replied:
If you move the "size" directive *after* the model directive,
you'll be able to use ".386" or better. As I understand it, putting
".386" before the ".model" directive calls for 32-bit code, putting
it after just enables the newer instructions.
100% correct. Thanks, Frank.
....
mov dx, WORD PTR [sMsg + 100h]
This is asking for "contents of memory". You want "offset". I don't
know if adding the 100h for a .com file is necessary or not.
The .386 directive position ended up messing things up when I tried
OFFSET. Thanks for describing the .386 positioning problems.
I noticed in your [other] post that "link.exe" and "link16.exe"
were the same size.
They represent two copies of the same file. They compare identical
when doing fc /b link.exe link16.exe. Why two copies, I'm not sure,
as running link16.exe from the command line presents no problems.
....
I'm currently working on getting
the number of the address rather than the contents of the address
into DX.
mov dx, offset sMsg
or:
lea dx, sMsg
Great! Thanks alot, Frank. I'm not using the ORG 100h directive,
so I have to add 100h to the address. I didn't see anything in the
32bit "incremental" link.exe parameters as far as creating a .com
goes.
The following code works. The label caused some problems and
ended up I commenting it out. Putting the ORG 100h directive
into the file also caused some problems whereby it looks for a
SEGMENT directive. I played with a such a segment directive,
and ended up taking it out. The following compiles with a couple
complaints from the linker...
;
; Hello World application
;
; Microsoft (R) Macro Assembler Version 7.10.4035
; ml.exe /c /AT /omf hellow.asm (YES)
;
; Microsoft (R) Incremental Linker Version 7.10.4035
; link.exe /SUBSYSTEM:CONSOLE /RELEASE /MACHINE:X86 hellow.obj (NO)
; link.exe /RELEASE /MACHINE:X86 hellow.obj (NO)
;
; Microsoft (R) Segmented Executable Linker NTGroup Version 5.60.220 Dec 28 1999
; link16.exe /TINY hellow.obj (YES)
; link16.exe hellow.obj => results in hellow.exe
;
TITLE Hello World
OPTION CASEMAP: none
..MODEL TINY
..386
;ORG 100h
..DATA
sMsg db "Hello World",0Dh,0Ah,"$"
..STACK
..CODE
;START_UP:
;
;THESE WORK AS LONG AS THE .386 DIRECTIVE FOLLOWS THE
;.MODEL DIRECTIVE.
;
;mov dx, OFFSET [sMsg + 100h]
;
lea dx, OFFSET [sMsg + 100h]
mov ah, 09h
int 21h
int 20h
;END START_UP
END
Microsoft (R) Segmented Executable Linker NTGroup Version 5.60.220 Dec 28 1999
Copyright (C) Microsoft Corp 1984-1993. All rights reserved.
Run File [hellow.com]:
List File [nul.map]:
Libraries [.lib]:
Definitions File [nul.def]:
LINK : warning L4045: name of output file is 'hellow.com'
LINK : warning L4055: start address not equal to 0x100 for /TINY
I end up with a 24 byte hellow.com file that looks and runs great.
Thanks much, Frank.
--
Jim Carlock
Post replies to the group.
.
- References:
- Loading Memory Addresses
- From: Jim Carlock
- Re: Loading Memory Addresses
- From: Frank Kotler
- Loading Memory Addresses
- Prev by Date: Re: Reverse Engineering
- Next by Date: Re: Loading Memory Addresses
- Previous by thread: Re: Loading Memory Addresses
- Next by thread: Re: Loading Memory Addresses
- Index(es):
Relevant Pages
|