FORMAT  MS COFF
;============================================================================
include         'PRIVATE\DOS.INC'
;============================================================================

;----------------------------------------------------------------------------
;
;	RELOC_ADDR - Reloated runtime Address
;
;	Entry:
;		FloatAddr : It's need to be reloate address.
;
;	Exit:
;		EAX  : It point to runtime address.
;		         
;	Modified:
;		EAX
;
;	Processing:
;		1. Calculated the OS loading address of program.
;		2. Added the absolate address onto float address.
;
;----------------------------------------------------------------------------	
macro  RELOC_ADDR	FloatAddr
{
	local	NextInst
  common
  	push	ebx
  	xor	ebx, ebx
        call    near NextInst
NextInst:
        pop     bx
        sub     ebx,NextInst                 ;Calculate the Loaded Address
        lea	eax, [FloatAddr]
        add	eax, ebx
        pop	ebx
}

section '.text' code
        USE16        
 public _Start
        
        org     0h
 _Start:
        cli
        cld
        mov     eax, 0
        sub     eax, 8
        mov     esp, eax
        push    cs
        pop     ds
        mov     ax, ds
        mov     ds, ax
        mov     es, ax
        mov     gs, ax
        
        RELOC_ADDR hello
        mov	edx, eax
        mov     ah,9
        int     21H
        
        mov     ax,4c00H
        int     21H


section '.data' data shareable
        hello   db      'COFF OBJ Format for DOS Demo Program',0DH,0AH
                db      'Hello, The FASM World!',0DH,0AH
                db      'Designer:Kenneth Zheng 2003/07/16','$'     
                