Author Topic: ORG directive in MASM?  (Read 4485 times)

Paulo

  • Guest
ORG directive in MASM?
« on: August 21, 2013, 02:47:45 AM »
Hi

Can anyone confirm if MASM32 can compile flat binary files with a user defined .ORG directive like in NASM?
I know that MASM versions later then 6.0 can produce .com files with the .MODEL tiny directive but that means the
ORG is fixed at 100h.

Thanks in advance
Paulo.

FORTRANS

  • Member
  • *****
  • Posts: 1064
Re: ORG directive in MASM?
« Reply #1 on: August 21, 2013, 03:06:31 AM »
Hi,

   Yes.  Do a search on the old forum for "boot sector".  You
should find some threads where building a boot sector was
done from scratch.

Regards,

Steve N.

Paulo

  • Guest
Re: ORG directive in MASM?
« Reply #2 on: August 21, 2013, 03:08:00 AM »
Thanks FORTRANS.

============================
EDIT:
============================

Found the solution (thanks once again to Steve for pointing me in the right direction)
and I'm posting it here in case some one else might be interested.

Below is the test code I used, compiled it twice, once with ORG 0 and again with ORG 100h
BTW, if one specifies an ORG which is not 0 or 100h, Link16.exe throws a warning (with .MODEL Tiny), ignore it as it still produces correct code.

Code: [Select]

.MODEL  Tiny
 OPTION  CaseMap:None

.CODE

          ORG     100h

  ;ORG 0h

; ========================================================
;
; use the 16-bit linker. \masm32\bin\Link16.exe
;
; \masm32\bin\ml /c TestMasmOrg.asm
; \masm32\bin\Link16 /TINY TestMasmOrg.obj
;
; ========================================================

_main   PROC

        mov     dx,offset SomeText
        mov     ah,9
        int     21h

nop
nop

        mov     ax,4C00h
        int     21h

nop
nop

_main   ENDP

; -----------------------------------------------------------

SomeText db 'Yup Hello World What Else',0Dh,0Ah,24h

; -----------------------------------------------------------

        END     _main

Result as follows:

« Last Edit: August 21, 2013, 07:08:35 AM by Paulo »