[MAP ALL CURRFILE.MAP]
;;=======================================================================75
;; File: PROLOG_E.5.NSM  By: s_dubrovich@yahoo.com
;; Last: 08-May-11 10:12:47 AM
;; Prev: 06-May-11 02:14:51 PM,06-May-11 10:52:16 PM,07-May-11 07:19:50 AM
;; Init: 10-Jan-10 10:11:21 PM
;; Vers: 4r1
;; Note: .EXE Prolog. Pair to EPILOG_E.NSM.  This model is for small-c.exe
;;  where DS=ES=SS, CS.
;;=======================================================================75
;; --== Define EXE Header Section as same size as PSP ==--
;; v.2rN, - Map as: [DS w/hdr][SS][CS], nobits [FS][GS]
;; v.3r0, - Map as: [DS w/hdr][CS][SS], nobits [FS][GS]
;; v.4r0, - Map as: [DS w/hdr=ES=SS] [CS], nobits [FS][GS]
;;=======================================================================75
;; 19-Dec-10 01:51:41 PM - v.2r2, edits.
;; 06-May-11 02:01:49 PM - v.3r0, pcDos & codeview segment order.
;; 06-May-11 10:52:16 PM - v.4r0, Need SS=DS for small-c
;; 07-May-11 07:19:50 AM - this is done by setting SS -10h
;; 08-May-11 10:12:47 AM - v.4r1, terminate by: jmp _exit
;;=======================================================================75
  CPU PENTIUM
  [SECTION .dseg vstart=0 align=16]
hdr_:
  db 'MZ'			; -EXE file signature
  dw Len_Real % 512     ; -# bytes in last 200h sized page
  dw (Len_Real + 511) / 512  ; -# pages in file.
  dw 0			; -Relocation information: none;
                        ;  number of relocation table items.
  dw Len_hd / 16		; -Header size in paragraphs.
  dw Len_Virt / 16	; -Min extra mem req'd above the end
                        ;  of the loaded prgm, in paragraphs.
				;  a.k.a. nobits sections
  dw 0FFFFh			; -Max extra mem req'd above the end
                        ;  of the loaded prgm, in paragraphs.
                        ;  0000h is taken as a flag by the
                        ;  Loader to load in  high memory.
  dw -10h			; -Displacement in paragraphs of
                        ; stack segment within load module,
                        ; which excludes this header in size.
  dw stacktop		; -Initial SP to be set by Loader.
  dw 0			; (no) Checksum. Word, negative cksum.
  dw Start 			; -Initial IP - start, just after the
                        ;  header.
  dw ((Len_ds-Len_hd)/16)
                        ; -Displacement in paragraphs of code
                        ;  segment within load module.  By -10h
				;  initial CS includes header space,
				;  which gets replaced by PSP on Load.
  dw 0			; -File offset to relocation table:
                        ;  none; Displacement in bytes of the
                        ;  first relocation item within the file.
  dw 0			; -(no overlay).  Overlay number (0
                        ;  for resident part of the program).
  align 256,db 0 
hdr_end:			
  Len_hd EQU (hdr_end-hdr_)

;; -= Declare Stack Segment as next in order after Data =-
;-;  [SECTION .sseg vstart=0 align=16] !removed for small-c.

;; -= Executable Start =-
;; -= The EXE Loader sets.. DS=ES, CS, SS, SP, IP from header. =-
;; -= Our Order: DS, CS, SS, (nobits FS, GS) =-
;; -= Setup FS,GS to point to first nobits, .x1seg, in =-
;; -= paragraphs.  If a second nobits area is used, GS is =-
;; -= set to its base. =-

  [SECTION .cseg vstart=0]
Start:

;-  mov  sp, stacktop

  mov  edx, DS
  mov  FS, dx
  mov  GS, dx       ;; if no 'nobits'

  mov  edx, CS      ;; Base of last loaded section
  mov  ecx, Len_cs  ;; convert length in bytes to paragraphs.
  shr  ecx, 4
  add  edx, ecx     ;; Base + paragraph length = Next Base = nobits

  mov  ecx, Len_x1
  cmp  ecx, 0       ;; Test for zero length (unused)
  je   NoX          ;; keep FS,GS = DS

  mov  FS,  dx      ;; holds next base, segment .sseg or .x1seg
  mov  GS,  dx

NoX:
  mov  ecx, Len_x2
  cmp  ecx, 0
  je   noX2         ;; keep FS,GS as is.

do_x2:
  mov  ecx, Len_x1
  shr  ecx, 4       ;; segment offset of .X2SEG
  add  edx, ecx
  mov  GS,  dx      ;; .x2seg -> GS

noX2:
;; -= MAIN =-
  call main  ;; start label.

Xit:
	jmp	_exit
;-  mov  ah, 0
;-  int  16h   ;; pause for keypress
;-  int  19h   ;; reboot

;;=======================================================================75
;; --== Define Data Section as following Code Section ==--
;; -= F I R S T   D A T A =-
;;=======================================================================75
  [SECTION .dseg] ;; first .dseg
SN_CTRL:  DB  0,0,0,0,0,0,0,0  ;; - S/N, or Control Number -

;;=======================================================================75
;; - =   E O   P R O L O G _ E   = -
;;=======================================================================75

8:55 PM 6/20/2011