     1                                  ;*********************************************************************
     2                                  ;*   MLMAP.ASM                                                       *
     3                                  ;*                                                                   *
     4                                  ;*   By:            Michael Devore                                   *
     5                                  ;*   Date:          12/21/92                                         *
     6                                  ;*   Model:         Small                                            *
     7                                  ;*   Version:       2.5                                              *
     8                                  ;*   Assembler:     MASM 5.0                                         *
     9                                  ;*   Environment:   MS-DOS 2.x+                                      *
    10                                  ;*                                                                   *
    11                                  ;*   map file code                                                   *
    12                                  ;*                                                                   *
    13                                  ;*********************************************************************
    14                                  
    15                                  ;TITLE   WARPLINK mlmap
    16                                  ;PAGE    50,80
    17                                  
    18                                  ;.MODEL  SMALL
    19                                  
    20                                  ;*****************************
    21                                  ;* Include files             *
    22                                  ;*****************************
    23                                  
    24                                  [list -]
    14                              <1> [list -]
    26                                  [list -]
    31                                       
    32                                  ;*****************************
    33                                  ;* Public declarations       *
    34                                  ;*****************************
    35                                       
    36                                  PUBLIC  init_map,finish_map,map_segments,map_groups
    37                                  PUBLIC  map_detail_seg
    38                                  
    39                                  ;*****************************
    40                                  ;* Data begins               *
    41                                  ;*****************************
    42                                  
    43                                  .DATA
    44                                  
    45                                  ;*****************************
    46                                  ;* External declarations     *
    47                                  ;*****************************
    48                                  
    49                                  ; variables
    50                                  EXTRN   segment_start:DWORD,segment_stop:DWORD,true_seg_len:DWORD
    51                                  EXTRN   filename:BYTE
    52                                  
    53                                  ; initialized local variables
    54                                  
    55                                  ; byte values
    56                                  EVEN
    57 00000000 00                      detail_flag DB  0           ; nonzero if not calling map_detail_seg for first time
    58 00000001 00                      EVEN
    59 00000002 00                      comm_loop_flag  DB  0       ; nonzero if publics written to map are in communal (vs public) declarations block
    60                                  
    61 00000003 53756E4D6F6E547565-     array_weekday:	db "SunMonTueWedThuFriSat"
    61 0000000C 576564546875467269-
    61 00000015 536174             
    62                                  
    63                                  .DATA?
    64                                  
    65                                  ; uninitialized local variables
    66                                  
    67                                  EVEN
    68                                  ; word values
    69 00000000 ????                    map_seg_ovl DW  ?           ; nonzero if mapping overlaid segment, holds overlay id
    70                                  
    71                                  ; byte buffer
    72                                  EVEN
    73 00000002 <res 2BCh>              map_text_buffer DB  700 DUP (?) ; space for buffered line in map file
    74                                  
    75                                  ;*****************************
    76                                  ;* Constant data             *
    77                                  ;*****************************
    78                                  
    79                                  .CONST
    80                                  
    81                                  EVEN
    82 00000000 35                      mhtext_len      DB  mhtext_stop-map_header_text
    83 00000001 0D0A53746172742020-     map_header_text DB  CR,LF,'Start  Stop   Length Name                   Class',CR,LF
    83 0000000A 53746F702020204C65-
    83 00000013 6E677468204E616D65-
    83 0000001C 202020202020202020-
    83 00000025 202020202020202020-
    83 0000002E 20436C6173730D0A   
    84                                  mhtext_stop equ   $
    85                                  
    86 00000036 0D0A50524F4752414D-     prog_text       DB  CR,LF,'PROGRAM: '
    86 0000003F 3A20               
    87                                  
    88 00000041 0D0A444154453A2020-     date_text       DB  CR,LF,'DATE:    '
    88 0000004A 2020               
    89                                  
    90 0000004C 0D0A54494D453A2020-     time_text       DB  CR,LF,'TIME:    '
    90 00000055 2020               
    91                                  
    92 00000057 26                      metext_len      DB  metext_stop-map_entry_text
    93 00000058 0D0A0D0A50726F6772-     map_entry_text  DB  CR,LF,CR,LF,'Program entry point at '
    93 00000061 616D20656E74727920-
    93 0000006A 706F696E7420617420 
    94 00000073 303030303A30303030-     map_entry_value DB  '0000:0000',CR,LF
    94 0000007C 0D0A               
    95                                  metext_stop equ   $
    96                                  
    97 0000007E 6D                      mestext_len:	db mestext_stop - map_exe_size_text
    98                                  map_exe_size_text:
    99 0000007F 45786563757461626C-     		db "Executable header size "
    99 00000088 652068656164657220-
    99 00000091 73697A6520         
   100                                  map_exe_header_size_value:
   101 00000096 3030303030680D0A        		db "00000h",13,10
   102 0000009E 45786563757461626C-     		db "Executable initialised image size "
   102 000000A7 6520696E697469616C-
   102 000000B0 6973656420696D6167-
   102 000000B9 652073697A6520     
   103                                  map_exe_init_image_size_value:
   104 000000C0 3030303030680D0A        		db "00000h",13,10
   105 000000C8 45786563757461626C-     		db "Executable total image size "
   105 000000D1 6520746F74616C2069-
   105 000000DA 6D6167652073697A65-
   105 000000E3 20                 
   106                                  map_exe_total_image_size_value:
   107 000000E4 3030303030680D0A        		db "00000h",13,10
   108                                  mestext_stop:
   109                                  
   110 000000EC 10                      mgtext_len      DB  mgtext_stop-map_group_text
   111 000000ED 0D0A4F726967696E20-     map_group_text  DB  CR,LF,'Origin   Group'
   111 000000F6 202047726F7570     
   112                                  mgtext_stop equ   $
   113                                  
   114 000000FD 75                      msegtext_len      DB  msegtext_stop-map_detseg_text
   115 000000FE 0D0A0D0A4465746169-     map_detseg_text   DB  CR,LF,CR,LF,'Detailed Segment Map',CR,LF
   115 00000107 6C6564205365676D65-
   115 00000110 6E74204D61700D0A   
   116 00000118 4E616D652020202020-                       DB  'Name             Ovl# Address   Length Align Combine Class    Group     Module       File',CR,LF
   116 00000121 20202020202020204F-
   116 0000012A 766C23204164647265-
   116 00000133 73732020204C656E67-
   116 0000013C 746820416C69676E20-
   116 00000145 436F6D62696E652043-
   116 0000014E 6C6173732020202047-
   116 00000157 726F75702020202020-
   116 00000160 4D6F64756C65202020-
   116 00000169 2020202046696C650D-
   116 00000172 0A                 
   117                                  msegtext_stop   equ   $
   118                                  
   119 00000173 21                      maddrtext_len   DB  maddrtext_stop-maddr_text
   120 00000174 0D0A20416464726573-     maddr_text      DB  CR,LF,' Address   Status   Symbol Name'
   120 0000017D 732020205374617475-
   120 00000186 7320202053796D626F-
   120 0000018F 6C204E616D65       
   121                                  maddrtext_stop  equ   $
   122                                  
   123 00000195 20204F766C20202020-     mpub_ovl    DB  '  Ovl      '   ; overlaid public
   123 0000019E 2020               
   124 000001A0 202041627320202020-     mpub_abs    DB  '  Abs      '   ; absolute public
   124 000001A9 2020               
   125 000001AB 2020556E7265732020-     mpub_unres  DB  '  Unres    '   ; unresolved public
   125 000001B4 2020               
   126 000001B6 2020436F6D6D202020-     mpub_comm   DB  '  Comm     '   ; communal variable
   126 000001BF 2020               
   127 000001C1 202052657320202020-     mpub_res    DB  '  Res      '   ; resolved, resident public
   127 000001CA 2020               
   128                                  
   129                                  	align 2, db 0
   130                                  align_table:
   131 000001CC [0002]                  dw align_inval	; A0
   132 000001CE [DC01]                  dw align_byte	; A1
   133 000001D0 [E201]                  dw align_word	; A2
   134 000001D2 [EE01]                  dw align_para	; A3
   135 000001D4 [F401]                  dw align_page	; A4
   136 000001D6 [E801]                  dw align_dword	; A5
   137 000001D8 [FA01]                  dw align_4kib	; A6 (PharLap extension)
   138 000001DA [0002]                  dw align_inval	; A7
   139                                  
   140 000001DC 425954452020            align_byte  DB  'BYTE  '
   141 000001E2 574F52442020            align_word  DB  'WORD  '
   142 000001E8 44574F524420            align_dword db  'DWORD '
   143 000001EE 504152412020            align_para  DB  'PARA  '
   144 000001F4 504147452020            align_page  DB  'PAGE  '
   145 000001FA 344B49422020            align_4kib  db  '4KIB  '
   146 00000200 494E56414C20            align_inval db  'INVAL '
   147                                  
   148 00000206 5052495641544520        comb_priv   DB  'PRIVATE '
   149 0000020E 5055424C49432020        comb_pub    DB  'PUBLIC  '
   150 00000216 535441434B202020        comb_stack  DB  'STACK   '
   151 0000021E 434F4D4D4F4E2020        comb_com    DB  'COMMON  '
   152                                  
   153                                  ;*****************************
   154                                  ;* Code begins               *
   155                                  ;*****************************
   156                                  
   157                                  .CODE
   158                                  
   159                                  ;*****************************
   160                                  ;* External declarations     *
   161                                  ;*****************************
   162                                  
   163                                  EXTRN   link_error:NEAR,dos_error:NEAR
   164                                  EXTRN   restore_ems_map:NEAR
   165                                  
   166                                  ;*****************************
   167                                  ;* INIT_MAP                  *
   168                                  ;*****************************
   169                                  
   170                                  ; open map file and write header
   171                                  ; destroys ax,bx,cx,dx,es,si,di
   172                                  
   173                                  init_map    PROC
   174 00000000 803E[0000]00                cmp byte [is_mapfile],0        ; see if map file to be created
   175 00000005 7501                        jne im_1                ; yes
   176 00000007 C3                          ret
   177                                  
   178                                  im_1:
   179 00000008 BA[0000]                    mov dx,OFFSET map_name wrt DGROUP
   180 0000000B 31C9                        xor cx,cx               ; normal file
   181 0000000D B43C                        mov ah,3ch              ; create or truncate file
   182 0000000F CD21                        int 21h
   183 00000011 E8(0000)                    call    restore_ems_map
   184 00000014 7303E9D300                  jc  im_error
   185                                  
   186 00000019 A3[0000]                    mov [map_handle],ax       ; save handle of map file
   187                                  
   188                                  ; get date
   189 0000001C 1E                          push    ds
   190 0000001D 07                          pop es
   191 0000001E BF[0200]                    mov di,OFFSET map_text_buffer wrt DGROUP    ; es:di -> buffer
   192 00000021 B42A                        mov ah,2Ah              ;DOS function to get date
   193 00000023 CD21                        int 21h			; cx = year, dh = month, dl = day
   194                                  
   195 00000025 30E4                    	xor ah, ah
   196 00000027 50                      	push ax			; ax = day of week (0 = Sunday)
   197 00000028 52                      	push dx
   198 00000029 91                      	xchg ax, cx
   199 0000002A BB0A00                  	mov bx, 10
   200 0000002D 53                      	push bx
   201                                  .loopdiv:
   202 0000002E 31D2                    	xor dx, dx
   203 00000030 F7F3                    	div bx
   204 00000032 52                      	push dx
   205 00000033 85C0                    	test ax, ax
   206 00000035 75F7                    	jnz .loopdiv
   207                                  .loopsto:
   208 00000037 58                      	pop ax
   209 00000038 0430                    	add al, '0'
   210 0000003A AA                      	stosb
   211 0000003B 3C39                    	cmp al, '9'
   212 0000003D 76F8                    	jbe .loopsto
   213 0000003F 4F                      	dec di
   214 00000040 B02D                    	mov al, '-'
   215 00000042 AA                      	stosb
   216 00000043 5B                      	pop bx
   217 00000044 88F8                        mov al,bh               ;AL = month
   218 00000046 D40A                        aam                     ;AX = month in BCD format
   219 00000048 053030                      add ax,"00"             ;AX = month in decimal digits
   220 0000004B 86C4                        xchg    al,ah
   221 0000004D AB                          stosw                   ;write month to string
   222 0000004E B02D                        mov al, '-'
   223 00000050 AA                          stosb                   ;write '-' to string
   224 00000051 93                          xchg    ax,bx           ;AL = day
   225 00000052 D40A                        aam                     ;AX = day in BCD format
   226 00000054 053030                      add ax,"00"             ;AX = day in decimal digits
   227 00000057 86C4                        xchg    al,ah
   228 00000059 AB                          stosw                   ;write day to string
   229 0000005A 5E                      	pop si			; = day of week, 0 = Sunday
   230 0000005B 89F0                    	mov ax, si
   231 0000005D 01F6                    	add si, si		; times 2
   232 0000005F 01C6                    	add si, ax		; times 3
   233 00000061 81C6[0300]              	add si, array_weekday
   234 00000065 B020                    	mov al, 32
   235 00000067 AA                      	stosb			; store a blank
   236 00000068 A5                      	movsw
   237 00000069 A4                      	movsb			; copy over a 3-byte day name
   238 0000006A 57                      	push di
   239                                  ; write program name
   240 0000006B 8B1E[0000]                  mov bx,[map_handle]
   241 0000006F BA[3600]                    mov dx,OFFSET prog_text wrt DGROUP
   242 00000072 B90B00                      mov cx,11
   243 00000075 E86300                      call    NEAR PTR im_sharerout
   244                                  
   245 00000078 BF[0000]                    mov di,OFFSET exe_name wrt DGROUP
   246                                  im_nameloop:
   247 0000007B 803D00                      cmp BYTE PTR [di],0
   248 0000007E 740A                        je  im_writedate
   249 00000080 89FA                        mov dx,di
   250 00000082 B101                        mov cl,1
   251 00000084 E85400                      call    NEAR PTR im_sharerout
   252 00000087 47                          inc di
   253 00000088 EBF1                        jmp SHORT im_nameloop
   254                                  
   255                                  ; write date
   256                                  im_writedate:
   257 0000008A BA[4100]                    mov dx,OFFSET date_text wrt DGROUP
   258 0000008D B10B                        mov cl,11
   259 0000008F E84900                      call    NEAR PTR im_sharerout
   260                                  
   261 00000092 BA[0200]                    mov dx,OFFSET map_text_buffer wrt DGROUP
   262 00000095 59                      	pop cx
   263 00000096 29D1                    	sub cx, dx
   264 00000098 E84000                      call    NEAR PTR im_sharerout
   265                                  
   266                                  ; get time
   267 0000009B BF[0200]                    mov di,OFFSET map_text_buffer wrt DGROUP    ; es:di -> buffer
   268 0000009E B42C                        mov ah,2Ch              ;dos function to get time
   269 000000A0 CD21                        int 21h                 ;returns time in CX:DX
   270 000000A2 92                          xchg    ax,dx           ;move time to DX:AX...
   271 000000A3 89CA                        mov dx,cx
   272 000000A5 88F0                        mov al,dh               ;Al = hours (24 hr clock)
   273 000000A7 D40A                        aam                     ;AX = hours in BCD format
   274 000000A9 053030                      add ax,"00"             ;AX = hours in decimal digits
   275 000000AC 86C4                        xchg    al,ah
   276 000000AE AB                          stosw                   ;write hours to string
   277 000000AF B03A                        mov al,":"
   278 000000B1 AA                          stosb                   ;write ":" to string
   279 000000B2 88D0                        mov al,dl               ;AL = minutes
   280 000000B4 D40A                        aam                     ;AX = minutes in BCD format
   281 000000B6 053030                      add ax,"00"             ;AX = minutes in decimal digits
   282 000000B9 86C4                        xchg    al,ah
   283 000000BB AB                          stosw                   ;write minutes to string
   284                                  
   285                                  ; write time
   286 000000BC BA[4C00]                    mov dx,OFFSET time_text wrt DGROUP
   287 000000BF B90B00                      mov cx,11
   288 000000C2 E81600                      call    NEAR PTR im_sharerout
   289                                  
   290 000000C5 BA[0200]                    mov dx,OFFSET map_text_buffer wrt DGROUP
   291 000000C8 89F9                        mov cx, di
   292 000000CA 29D1                        sub cx, dx
   293 000000CC E80C00                      call    NEAR PTR im_sharerout
   294                                  
   295                                  ; write segment header
   296 000000CF BA[0100]                    mov dx,OFFSET map_header_text wrt DGROUP
   297 000000D2 B102                        mov cl,2                ; write CR/LF, fall through and write full text
   298 000000D4 E80400                      call    NEAR PTR im_sharerout
   299                                  
   300 000000D7 8A0E[0000]                  mov cl,[mhtext_len]
   301                                  
   302                                  im_sharerout:
   303 000000DB B440                        mov ah,40h              ; write to file
   304 000000DD CD21                        int 21h
   305 000000DF E8(0000)                    call    restore_ems_map
   306 000000E2 7208                        jc  im_error
   307 000000E4 39C8                    	cmp ax, cx
   308 000000E6 B82700                  	mov ax, 27h			; insufficient disk space error
   309 000000E9 7501                    	jne im_error
   310 000000EB C3                          retn
   311                                  
   312                                  im_error:
   313 000000EC BA[0000]                    mov dx,OFFSET map_name wrt DGROUP
   314 000000EF E9(0000)                    jmp NEAR PTR dos_error  ; error writing to file
   315                                  
   316                                  init_map    ENDP
   317                                  
   318                                  ;*****************************
   319                                  ;* MAP_SEGMENTS              *
   320                                  ;*****************************
   321                                  
   322                                  ; show map of segments
   323                                  ; called for each segment
   324                                  ; prints segment start, stop, length, name, and class in map file
   325                                  ; uses memory variables segment_start, segment_stop, true_seg_len
   326                                  ; destroys ax,bx,cx,dx,di
   327                                  
   328                                  map_segments    PROC
   329 000000F2 06                          push    es              ; save critical register
   330 000000F3 1E                      	push	ds
   331 000000F4 07                      	pop	es					; es -> warplink data
   332                                  
   333                                  ; convert all needed amount of map_text_buffer bytes to spaces
   334 000000F5 B98C00                      mov cx,140              ; 140 words in field
   335 000000F8 B82020                      mov ax,2020h            ; spaces in high and low bytes
   336 000000FB BF[0200]                    mov di,OFFSET map_text_buffer wrt DGROUP
   337 000000FE F3AB                        rep stosw			; spaces in two bytes
   338                                  
   339 00000100 31D2                        xor dx,dx               ; zero count of chars in string
   340 00000102 BB[0200]                    mov bx,OFFSET map_text_buffer wrt DGROUP    ; bx -> place to put ascii chars
   341                                  
   342 00000105 8A0E[0200]                  mov cl,BYTE PTR [segment_start+2] ; get value of LSB of MSW of segment start
   343 00000109 B401                        mov ah,1                ; 4 bit value
   344 0000010B E80C04                      call    hexxit
   345                                  
   346 0000010E 8A0E[0100]                  mov cl,BYTE PTR [segment_start+1] ; get value of MSB of LSW of segment start
   347 00000112 30E4                        xor ah,ah               ; 8 bit value
   348 00000114 E80304                      call    hexxit
   349                                  
   350 00000117 8A0E[0000]                  mov cl,BYTE PTR [segment_start]   ; get value of LSB of LSW of segment start
   351 0000011B E8FC03                      call    hexxit
   352                                  
   353 0000011E C60748                      mov BYTE PTR [bx],'H'   ; put a hexadecimal number indicator
   354 00000121 43                          inc bx
   355 00000122 43                          inc bx                ; move to segment length portion of field
   356 00000123 42                          inc dx
   357 00000124 42                          inc dx
   358 00000125 8A0E[0200]                  mov cl,BYTE PTR [segment_stop+2]  ; get value of LSB of MSW of segment stop
   359 00000129 B401                        mov ah,1                ; 4 bit value
   360 0000012B E8EC03                      call    hexxit
   361                                  
   362 0000012E 8A0E[0100]                  mov cl,BYTE PTR [segment_stop+1]  ; get value of LSB of LSW of segment stop
   363 00000132 30E4                        xor ah,ah               ; 8 bit value
   364 00000134 E8E303                      call    hexxit
   365                                  
   366 00000137 8A0E[0000]                  mov cl,BYTE PTR [segment_stop]    ; get value of LSB of LSW of segment stop
   367 0000013B E8DC03                      call    hexxit
   368                                  
   369 0000013E C60748                      mov BYTE PTR [bx],'H'   ; put a hexadecimal number indicator
   370 00000141 43                          inc bx
   371 00000142 43                          inc bx                ; move to segment length portion of field
   372 00000143 42                          inc dx
   373 00000144 42                          inc dx
   374 00000145 8A0E[0200]                  mov cl,BYTE PTR [true_seg_len+2]  ; get value of LSB of MSW of segment length
   375 00000149 B401                        mov ah,1                ; 4 bit value
   376 0000014B E8CC03                      call    hexxit
   377                                  
   378 0000014E 8A0E[0100]                  mov cl,BYTE PTR [true_seg_len+1]  ; get value of LSB of LSW of segment length
   379 00000152 30E4                        xor ah,ah               ; 8 bit value
   380 00000154 E8C303                      call    hexxit
   381                                  
   382 00000157 8A0E[0000]                  mov cl,BYTE PTR [true_seg_len]    ; get value of LSB of LSW of segment length
   383 0000015B E8BC03                      call    hexxit
   384 0000015E C60748                      mov BYTE PTR [bx],'H'   ; put a hexadecimal number indicator
   385 00000161 43                          inc bx
   386 00000162 43                          inc bx                ; move to segment name part of field
   387 00000163 42                          inc dx
   388 00000164 42                          inc dx
   389                                  
   390 00000165 07                          pop es                  ; es -> segdef entry
   391 00000166 06                          push    es              ; restore to stack
   392 00000167 268B3E0800                  mov di,[es:8]
   393 0000016C 83C708                      add di,8                ; bump past 2 doubleword pointers
   394 0000016F 268E060A00                  mov es,[es:10]          ; es:di -> segment name
   395 00000174 31C9                        xor cx,cx               ; zero count of chars in name
   396                                  
   397                                  ms_segloop:
   398 00000176 268A05                      mov al,[es:di]          ; get name char
   399 00000179 08C0                        or  al,al               ; check for zero terminator
   400 0000017B 7408                        je  ms_2                ; done
   401 0000017D 8807                        mov [bx],al             ; transfer char
   402 0000017F 47                          inc di
   403 00000180 43                          inc bx
   404 00000181 41                          inc cx                  ; bump count of chars in name
   405 00000182 42                          inc dx                  ; bump count of chars in map string
   406 00000183 EBF1                        jmp SHORT ms_segloop    ; loop back for next char
   407                                  
   408                                  ms_2:
   409 00000185 83F916                      cmp cx,22               ; see if at least 22 chars were in name
   410 00000188 7309                        jae ms_3                ; yes
   411 0000018A B81600                      mov ax,22
   412 0000018D 29C8                        sub ax,cx               ; get difference between length of char string and 22
   413 0000018F 01C3                        add bx,ax
   414 00000191 01C2                        add dx,ax               ; move to class name field in map file
   415                                  
   416                                  ms_3:
   417 00000193 43                          inc bx                  ; move one space to class name field
   418 00000194 42                          inc dx
   419                                  
   420 00000195 07                          pop es                  ; es -> segdef entry
   421 00000196 06                          push    es              ; restore to stack
   422 00000197 268B3E0C00                  mov di,[es:12]
   423 0000019C 83C708                      add di,8                ; bump past 2 doubleword pointers
   424 0000019F 268E060E00                  mov es,[es:14]          ; es:di -> class name
   425                                      
   426                                  ms_clloop:
   427 000001A4 268A05                      mov al,[es:di]          ; get name char
   428 000001A7 08C0                        or  al,al               ; check for zero terminator
   429 000001A9 7407                        je  ms_4                ; done
   430 000001AB 8807                        mov [bx],al             ; transfer char
   431 000001AD 47                          inc di
   432 000001AE 43                          inc bx
   433 000001AF 42                          inc dx                  ; bump count of chars in map string
   434 000001B0 EBF2                        jmp SHORT ms_clloop    ; loop back for next char
   435                                  
   436                                  ms_4:
   437 000001B2 C7070D0A                    mov word [bx], CR + (LF << 8)    ; cr/lf terminate
   438 000001B6 42                          inc dx
   439 000001B7 42                          inc dx                ; bump count of chars in string
   440                                  
   441 000001B8 89D1                        mov cx,dx               ; get count of chars to write
   442 000001BA 8B1E[0000]                  mov bx,[map_handle]
   443 000001BE BA[0200]                    mov dx,OFFSET map_text_buffer wrt DGROUP   ; ds:dx -> text to write
   444 000001C1 B440                        mov ah,40h              ; write to file
   445 000001C3 CD21                        int 21h
   446 000001C5 E8(0000)                    call    restore_ems_map
   447 000001C8 7306                        jnc .checkspace              ; no errors
   448                                  .error:
   449 000001CA BA[0000]                    mov dx,OFFSET map_name wrt DGROUP
   450 000001CD E9(0000)                    jmp NEAR PTR dos_error  ; error writing to file
   451                                  
   452                                  .checkspace:
   453 000001D0 39C8                    	cmp ax, cx
   454 000001D2 B82700                  	mov ax, 27h			; insufficient disk space error
   455 000001D5 75F3                    	jne .error
   456                                  ms_ret:
   457 000001D7 07                          pop es                  ; restore critical register
   458 000001D8 C3                          ret
   459                                  map_segments    ENDP
   460                                  
   461                                  ;*****************************
   462                                  ;* MAP_GROUPS                *
   463                                  ;*****************************
   464                                  
   465                                  ; show map of groups
   466                                  ; only called once
   467                                  ; destroys ax,bx,cx,dx,di,si,es
   468                                  
   469                                  map_groups  PROC
   470 000001D9 A1[0000]                    mov ax,[first_grpblk_ptr] ; get pointer to first group block
   471 000001DC 89C7                        mov di,ax               ; save pointer
   472 000001DE 09C0                        or  ax,ax               ; check if null
   473 000001E0 7501                        jne mg_grp_exist        ; no, one or groups exist
   474 000001E2 C3                          ret                     ; zero, no groups, return
   475                                  
   476                                  ; write group header
   477                                  mg_grp_exist:
   478 000001E3 8B1E[0000]                  mov bx,[map_handle]
   479 000001E7 8A0E[EC00]                  mov cl,[mgtext_len]       ; get length of text to write
   480 000001EB 30ED                        xor ch,ch               ; zap high byte
   481 000001ED BA[ED00]                    mov dx,OFFSET map_group_text wrt DGROUP ; ds:dx -> text to write
   482 000001F0 B440                        mov ah,40h              ; write to file
   483 000001F2 CD21                        int 21h
   484 000001F4 E8(0000)                    call    restore_ems_map
   485 000001F7 7306                        jnc .checkspace                ; no errors
   486                                  .error:
   487 000001F9 BA[0000]                    mov dx,OFFSET map_name wrt DGROUP
   488 000001FC E9(0000)                    jmp NEAR PTR dos_error  ; error writing to file
   489                                  
   490                                  .checkspace:
   491 000001FF 39C8                    	cmp ax, cx
   492 00000201 B82700                  	mov ax, 27h			; insufficient disk space error
   493 00000204 75F3                    	jne .error
   494                                  mg_2:
   495 00000206 8EC7                        mov es,di               ; es -> block
   496 00000208 268B0E0000                  mov cx,[es:0]           ; get count
   497 0000020D 89F8                        mov ax,di
   498 0000020F 40                          inc ax
   499 00000210 8EC0                        mov es,ax               ; es -> first entry in block
   500                                  
   501                                  mg_3:
   502 00000212 09C9                        or  cx,cx               ; check entry count
   503 00000214 7503                        jne mg_3a
   504 00000216 E98E00                      jmp NEAR PTR mg_next_block  ; count is zero, get next group block, if any
   505                                  
   506                                  mg_3a:
   507 00000219 49                          dec cx                  ; decrement count
   508 0000021A 51                          push    cx              ; save critical register
   509                                  
   510                                  ; print group offset and  group name
   511 0000021B 31D2                        xor dx,dx               ; zero count of chars in string to print
   512 0000021D BB[0200]                    mov bx,OFFSET map_text_buffer wrt DGROUP    ; bx -> place to put ascii chars
   513                                  
   514 00000220 C7070D0A                    mov word [bx], CR + (LF << 8)    ; cr/lf prepend
   515 00000224 43                          inc bx
   516 00000225 43                          inc bx
   517 00000226 42                          inc dx
   518 00000227 42                          inc dx                ; bump count of chars in string
   519                                  
   520 00000228 268B0E0000                  mov cx,[es:0]           ; get group offset low word
   521 0000022D 26A10200                    mov ax,[es:2]           ; get group offset high word
   522                                  
   523                                  ; convert offset value in ax:cx to paragraphs
   524 00000231 D1E8                        shr ax,1
   525 00000233 D1D9                        rcr cx,1                ; /2
   526 00000235 D1E8                        shr ax,1
   527 00000237 D1D9                        rcr cx,1                ; /4
   528 00000239 D1E8                        shr ax,1
   529 0000023B D1D9                        rcr cx,1                ; /8
   530 0000023D D1E8                        shr ax,1                ; ax should be zero by the final shift
   531 0000023F D1D9                        rcr cx,1                ; /16
   532                                  
   533 00000241 86E9                        xchg    ch,cl           ; get high byte in cl, save low byte in ch
   534 00000243 30E4                        xor ah,ah               ; 8 bit value
   535 00000245 E8D202                      call    hexxit
   536                                  
   537 00000248 88E9                        mov cl,ch               ; get low byte
   538 0000024A E8CD02                      call    hexxit
   539                                  
   540 0000024D C7073A30                    mov word [bx], ":0"    ; put in ':0   ' after group origin segment value
   541 00000251 43                          inc bx
   542 00000252 43                          inc bx
   543 00000253 B82020                      mov ax, "  "
   544 00000256 8907                        mov word [bx], ax
   545 00000258 43                          inc bx
   546 00000259 43                          inc bx
   547 0000025A 8807                        mov BYTE PTR [bx],al
   548 0000025C 43                          inc bx
   549 0000025D 83C205                      add dx,5                ; bump count of chars in string
   550                                  
   551 00000260 268B360400                  mov si,[es:4]
   552 00000265 83C608                      add si,8                ; bump past 2 doubleword pointers
   553 00000268 8CC1                        mov cx,es               ; save -> group entry
   554 0000026A 268E060600                  mov es,[es:6]           ; es:si -> segment name
   555                                  
   556                                  mg_grploop:
   557 0000026F 268A04                      mov al,[es:si]          ; get name char
   558 00000272 08C0                        or  al,al               ; check for zero terminator
   559 00000274 7407                        je  mg_4                ; done
   560 00000276 8807                        mov [bx],al             ; transfer char
   561 00000278 46                          inc si
   562 00000279 43                          inc bx
   563 0000027A 42                          inc dx                  ; bump count of chars in map string
   564 0000027B EBF2                        jmp SHORT mg_grploop    ; loop back for next char
   565                                  
   566                                  mg_4:
   567 0000027D 8EC1                        mov es,cx               ; restore es -> group entry
   568 0000027F 89D1                        mov cx,dx               ; get count of chars to write
   569 00000281 8B1E[0000]                  mov bx,[map_handle]
   570 00000285 BA[0200]                    mov dx,OFFSET map_text_buffer wrt DGROUP    ; ds:dx -> text to write
   571 00000288 B440                        mov ah,40h              ; write to file
   572 0000028A CD21                        int 21h
   573 0000028C E8(0000)                    call    restore_ems_map
   574 0000028F 7306                        jnc .mg_5                ; no errors
   575                                  .error:
   576 00000291 BA[0000]                    mov dx,OFFSET map_name wrt DGROUP
   577 00000294 E9(0000)                    jmp NEAR PTR dos_error  ; error writing to file
   578                                  
   579                                  .mg_5:
   580 00000297 39C8                    	cmp ax, cx
   581 00000299 B82700                  	mov ax, 27h			; insufficient disk space error
   582 0000029C 75F3                    	jne .error
   583 0000029E 59                          pop cx                  ; restore critical register
   584 0000029F 8CC0                        mov ax,es
   585 000002A1 40                          inc ax
   586 000002A2 8EC0                        mov es,ax               ; es -> next group entry
   587 000002A4 E96BFF                      jmp NEAR PTR mg_3       ; loop for next entry
   588                                  
   589                                  mg_next_block:
   590 000002A7 8EC7                        mov es,di               ; es -> group block
   591 000002A9 268B3E0200                  mov di,[es:2]           ; get pointer to next block
   592 000002AE 09FF                        or  di,di               ; make sure that it isn't null
   593 000002B0 7403                        je  mg_ret              ; null, return
   594 000002B2 E951FF                      jmp NEAR PTR mg_2       ; non-null, another block exists, loop and print entries
   595                                  
   596                                  mg_ret:
   597 000002B5 C3                          ret
   598                                  map_groups  ENDP
   599                                  
   600                                  ;*****************************
   601                                  ;* MAP_DETAIL_SEG            *
   602                                  ;*****************************
   603                                  
   604                                  ; detail map of segments
   605                                  ; upon entry es -> segment partition entry
   606                                  ; destroys ax,di
   607                                  
   608                                  map_detail_seg  PROC
   609 000002B6 53                          push    bx              ; save critical register
   610 000002B7 51                          push    cx
   611 000002B8 52                          push    dx
   612 000002B9 56                          push    si
   613                                  
   614                                  ; convert all of map_text_buffer bytes to spaces
   615 000002BA 8CC3                        mov bx,es               ; save es critical register
   616 000002BC 1E                      	push	ds
   617 000002BD 07                      	pop	es					; es -> warplink data
   618 000002BE B95E01                      mov cx,350              ; 350 words in field
   619 000002C1 B82020                      mov ax,2020h            ; spaces in high and low bytes
   620 000002C4 BF[0200]                    mov di,OFFSET map_text_buffer wrt DGROUP
   621 000002C7 F3AB                        rep stosw                   ; store spaces
   622                                  
   623 000002C9 8EC3                        mov es,bx               ; restore es critical register
   624 000002CB A0[0000]                    mov al,[detail_flag]
   625 000002CE 08C0                        or  al,al               ; see if detail segment header text was printed
   626 000002D0 7527                        jne mds_2               ; yes
   627                                  
   628                                  ; print detail segment header text
   629 000002D2 40                          inc ax
   630 000002D3 A2[0000]                    mov [detail_flag],al      ; see flag to show printed this pass
   631 000002D6 8B1E[0000]                  mov bx,[map_handle]
   632 000002DA 8A0E[FD00]                  mov cl,[msegtext_len]     ; get length of text to write in cx
   633 000002DE 30ED                        xor ch,ch
   634 000002E0 BA[FE00]                    mov dx,OFFSET map_detseg_text wrt DGROUP
   635 000002E3 B440                        mov ah,40h              ; write to file
   636 000002E5 CD21                        int 21h
   637 000002E7 E8(0000)                    call    restore_ems_map
   638 000002EA 7306                        jnc .checkspace               ; no errors
   639                                  .error:
   640 000002EC BA[0000]                    mov dx,OFFSET map_name wrt DGROUP
   641 000002EF E9(0000)                    jmp NEAR PTR dos_error  ; error writing to file
   642                                  
   643                                  .checkspace:
   644 000002F2 39C8                    	cmp ax, cx
   645 000002F4 B82700                  	mov ax, 27h			; insufficient disk space error
   646 000002F7 75F3                    	jne .error
   647                                  mds_2:
   648 000002F9 31D2                        xor dx,dx               ; zero count of chars in string to print
   649 000002FB BF[0200]                    mov di,OFFSET map_text_buffer wrt DGROUP    ; di -> place to put ascii chars
   650                                  
   651                                  ; write segment name
   652 000002FE 8CC3                        mov bx,es               ; save -> segment partition entry
   653 00000300 C706[0000]0000              mov word [map_seg_ovl],0       ; zero overlaid segment flag
   654                                  
   655 00000306 26A10400                    mov ax,[es:4]           ; get master segdef entry/overlay identifier
   656 0000030A 26F6060F0080                test    BYTE PTR [es:15],80h    ; see if overlaid segment
   657 00000310 740F                        je  mds_2a              ; no, ax holds master segdef entry
   658                                  
   659                                  ; overlaid segment, ax holds overlay identifier
   660 00000312 A3[0000]                    mov [map_seg_ovl],ax      ; set overlaid segment flag with identifier
   661 00000315 89C6                        mov si,ax
   662 00000317 4E                          dec si                  ; make relative zero
   663 00000318 D1E6                        shl si,1                ; convert to word offset
   664 0000031A 8E06[0000]                  mov es,[master_segblk]    ; es:si -> proper master segdef entry
   665 0000031E 268B04                      mov ax,[es:si]          ; get master segdef entry in ax
   666                                  
   667                                  mds_2a:
   668 00000321 50                          push    ax              ; save -> segdef entry on stack
   669 00000322 8CDE                        mov si,ds
   670 00000324 8ED8                        mov ds,ax               ; ds -> master segdef entry
   671 00000326 8EC6                        mov es,si               ; es:di -> write buffer
   672 00000328 C5360800                    lds si,[8]           ; ds:si -> segment name
   673 0000032C 83C608                      add si,8                ; adjust past doubleword pointers
   674                                  
   675                                  mds_loop1:
   676 0000032F 8A04                        mov al,[si]             ; see if null terminator reached
   677 00000331 08C0                        or  al,al
   678 00000333 7404                        je  mds_3               ; yes
   679 00000335 A4                          movsb                   ; transfer byte of name
   680 00000336 42                          inc dx                  ; no, bump count of chars in string
   681 00000337 EBF6                        jmp SHORT mds_loop1     ; loop for next char transfer
   682                                  
   683                                  mds_3:
   684 00000339 B8[ssss]                    mov ax,DGROUP
   685 0000033C 8ED8                        mov ds,ax               ; restore ds -> warplink data
   686 0000033E 87FB                        xchg    di,bx           ; bx -> write buffer, di -> segment partition entry
   687 00000340 43                          inc bx                  ; add space after name
   688 00000341 42                          inc dx
   689 00000342 833E[0000]00                cmp word [map_seg_ovl],0       ; see if overlaid segment
   690 00000347 741F                        je  mds_3b              ; no
   691                                  
   692                                  ; add overlay number
   693 00000349 B81100                      mov ax,17
   694 0000034C 39C2                        cmp dx,ax               ; see if at least 17 chars of name+space written
   695 0000034E 7306                        jae mds_3a              ; yes
   696 00000350 29D0                        sub ax,dx
   697 00000352 01C3                        add bx,ax               ; position to overlay number field
   698 00000354 01C2                        add dx,ax               ; adjust char count
   699                                  
   700                                  mds_3a:
   701 00000356 8B0E[0000]                  mov cx,[map_seg_ovl]      ; get overlay identifier
   702 0000035A 86E9                        xchg    ch,cl           ; high byte in cl, low byte in ch
   703 0000035C 30E4                        xor ah,ah               ; flag 8 bit values
   704 0000035E E8B901                      call    hexxit          ; print high byte
   705 00000361 88E9                        mov cl,ch               ; get low byte
   706 00000363 E8B401                      call    hexxit          ; print low byte
   707 00000366 43                          inc bx                  ; add space after overlay identifier
   708 00000367 42                          inc dx
   709                                  
   710                                  mds_3b:
   711 00000368 B81600                      mov ax,22
   712 0000036B 39C2                        cmp dx,ax               ; see if at least 22 chars of name+overlay #+space written
   713 0000036D 7306                        jae mds_4               ; yes
   714 0000036F 29D0                        sub ax,dx
   715 00000371 01C3                        add bx,ax               ; position to address field
   716 00000373 01C2                        add dx,ax               ; adjust char count
   717                                  
   718                                  ; write address
   719                                  mds_4:
   720 00000375 833E[0000]00                cmp word [map_seg_ovl],0       ; see if overlaid segment
   721 0000037A 7406                        je  mds_4a
   722 0000037C 8EC7                        mov es,di               ; es -> segment partition entry
   723 0000037E 31C9                        xor cx,cx               ; zero offset bytes
   724 00000380 EB05                        jmp SHORT mds_4b
   725                                  
   726                                  mds_4a:
   727 00000382 07                          pop es                  ; es -> segdef entry
   728 00000383 06                          push    es              ; replace -> segdef entry on stack
   729 00000384 E87901                      call    seg_offset_to_para  ; convert segment offset to paragraphs in cx
   730                                  
   731                                  mds_4b:
   732 00000387 86E9                        xchg    ch,cl           ; get high byte in cl, save low byte in ch
   733 00000389 30E4                        xor ah,ah               ; 8 bit value
   734 0000038B E88C01                      call    hexxit
   735 0000038E 88E9                        mov cl,ch               ; get low byte
   736 00000390 E88701                      call    hexxit
   737 00000393 C6073A                      mov BYTE PTR [bx],':'   ; put in ':'
   738 00000396 43                          inc bx
   739 00000397 42                          inc dx
   740                                  
   741 00000398 833E[0000]00                cmp word [map_seg_ovl],0       ; see if overlaid segment
   742 0000039D 7404                        je  mds_4c
   743 0000039F 31C9                        xor cx,cx               ; zero offset bytes
   744 000003A1 EB0F                        jmp SHORT mds_4d
   745                                  
   746                                  mds_4c:
   747 000003A3 26A00200                    mov al,[es:2]           ; get low byte of offset
   748 000003A7 83E00F                      and ax,0fh              ; only save lowest 4 bits of offset
   749 000003AA 8EC7                        mov es,di               ; es -> segment partition entry
   750 000003AC 2603060000                  add ax,[es:0]           ; add in segment partition offset
   751 000003B1 91                          xchg cx, ax			; clobbers ax
   752                                  
   753                                  mds_4d:
   754 000003B2 86E9                        xchg    ch,cl           ; get high byte in cl, save low byte in ch
   755 000003B4 30E4                        xor ah,ah               ; 8 bit value
   756 000003B6 E86101                      call    hexxit
   757 000003B9 88E9                        mov cl,ch               ; get low byte
   758 000003BB E85C01                      call    hexxit
   759 000003BE 43                          inc bx                  ; add space after address
   760 000003BF 42                          inc dx
   761                                  
   762                                  ; write length
   763 000003C0 B020                        mov al,' '              ; assume length is less than 64K
   764 000003C2 26F6060B0002                test BYTE PTR [es:11],2 ; test Big bit of acbp byte of segment partition
   765 000003C8 7402                        je  mds_5
   766                                  
   767 000003CA B031                        mov al,'1'              ; Big bit set
   768                                  
   769                                  mds_5:
   770 000003CC 8807                        mov [bx],al             ; put in space or '1'
   771 000003CE 43                          inc bx
   772 000003CF 42                          inc dx
   773 000003D0 268B0E0C00                  mov cx,[es:12]          ; get segment partition length low word
   774 000003D5 86E9                        xchg    ch,cl           ; get high byte in cl, save low byte in ch
   775 000003D7 30E4                        xor ah,ah               ; 8 bit value
   776 000003D9 E83E01                      call    hexxit
   777 000003DC 88E9                        mov cl,ch               ; get low byte
   778 000003DE E83901                      call    hexxit
   779 000003E1 C60768                      mov BYTE PTR [bx],'h'   ; put in 'h '
   780 000003E4 43                          inc bx
   781 000003E5 43                          inc bx
   782 000003E6 42                          inc dx
   783 000003E7 42                          inc dx
   784                                  
   785                                  ; write alignment
   786 000003E8 31C0                    	xor ax, ax
   787 000003EA 26A00B00                    mov al,[es:11]          ; get segment partition entry's acbp byte
   788 000003EE B105                    	mov cl, 5
   789 000003F0 D3E8                    	shr ax, cl		; get alignment field
   790 000003F2 96                      	xchg si, ax
   791 000003F3 01F6                    	add si, si		; = word index
   792 000003F5 8BB4[CC01]              	mov si, word [align_table + si]
   793                                  				; si -> alignment message
   794                                  mds_6:
   795 000003F9 B90600                      mov cx,6                ; transfer 6 chars
   796 000003FC 01CA                        add dx, cx			; adjust total char count
   797                                  
   798                                  mds_loop2:
   799 000003FE AC                          lodsb                   ; get align message char
   800 000003FF 8807                        mov [bx],al             ; transfer char
   801 00000401 43                          inc bx
   802 00000402 E2FA                        loop    mds_loop2       ; loop until all message chars transferred
   803                                  
   804                                  ; write combine
   805 00000404 26A00B00                    mov al,[es:11]          ; get segment partition entry's acbp byte
   806 00000408 241C                        and al,1ch              ; get combine field
   807 0000040A 741F                        je  mds_priv            ; private combine
   808 0000040C 3C08                        cmp al,8                ; check if public combine
   809 0000040E 7416                        je  mds_public
   810 00000410 3C10                        cmp al,10h              ; check if public combine
   811 00000412 7412                        je  mds_public
   812 00000414 3C1C                        cmp al,1ch              ; check if public combine
   813 00000416 740E                        je  mds_public
   814 00000418 3C14                        cmp al,14h              ; check if stack combine
   815 0000041A 7405                        je  mds_stack
   816                                  
   817                                  ; assume common combine (combine field 18h)
   818 0000041C BE[1E02]                    mov si,OFFSET comb_com wrt DGROUP
   819 0000041F EB0D                        jmp SHORT mds_7
   820                                  
   821                                  mds_stack:
   822 00000421 BE[1602]                    mov si,OFFSET comb_stack wrt DGROUP
   823 00000424 EB08                        jmp SHORT mds_7
   824                                  
   825                                  mds_public:
   826 00000426 BE[0E02]                    mov si,OFFSET comb_pub wrt DGROUP
   827 00000429 EB03                        jmp SHORT mds_7
   828                                  
   829                                  mds_priv:
   830 0000042B BE[0602]                    mov si,OFFSET comb_priv wrt DGROUP
   831                                  
   832                                  mds_7:
   833 0000042E B90800                      mov cx,8                ; transfer 8 chars
   834 00000431 01CA                        add dx, cx			; adjust total char count
   835                                  
   836                                  mds_loop3:
   837 00000433 AC                          lodsb                   ; get combine message char
   838 00000434 8807                        mov [bx],al             ; transfer char
   839 00000436 43                          inc bx
   840 00000437 E2FA                        loop    mds_loop3       ; loop until all message chars transferred
   841                                  
   842 00000439 8CDE                        mov si,ds
   843                                  
   844                                  mds_7a:
   845 0000043B 07                          pop es                  ; es -> master segdef entry
   846                                  
   847                                  ; write class
   848                                  mds_7b:
   849 0000043C 87FB                        xchg    di,bx           ; di -> write buffer, bx -> segment partition entry
   850 0000043E 8CC0                        mov ax,es               ; get master segdef entry
   851 00000440 50                          push    ax              ; save -> segdef entry on stack
   852 00000441 8ED8                        mov ds,ax               ; ds -> master segdef entry
   853 00000443 8EC6                        mov es,si               ; es:di -> write buffer
   854 00000445 C5360C00                    lds si,[12]          ; ds:si -> class name
   855 00000449 83C608                      add si,8                ; adjust past doubleword pointers
   856                                  
   857                                  mds_loop4:
   858 0000044C 8A04                        mov al,[si]             ; see if null terminator reached
   859 0000044E 08C0                        or  al,al
   860 00000450 7404                        je  mds_8               ; yes
   861 00000452 A4                          movsb                   ; transfer byte of name
   862 00000453 42                          inc dx                  ; no, bump count of chars in string
   863 00000454 EBF6                        jmp SHORT mds_loop4     ; loop for next char transfer
   864                                  
   865                                  mds_8:
   866 00000456 47                          inc di                  ; add space after name, di still -> write buffer
   867 00000457 42                          inc dx
   868 00000458 B83E00                      mov ax,62
   869 0000045B 39C2                        cmp dx,ax               ; see if at least 62 chars written
   870 0000045D 7306                        jae mds_9               ; yes
   871 0000045F 29D0                        sub ax,dx
   872 00000461 01C7                        add di,ax               ; position to class field
   873 00000463 01C2                        add dx,ax               ; adjust char count
   874                                  
   875                                  mds_9:
   876 00000465 B8[ssss]                    mov ax,DGROUP
   877 00000468 8ED8                        mov ds,ax
   878 0000046A 07                          pop es                  ; es -> segdef entry
   879                                  
   880 0000046B 833E[0000]00                cmp word [map_seg_ovl],0       ; see if overlaid segment
   881 00000470 7523                        jne mds_10              ; yes, no group association
   882                                  
   883                                  ; write group
   884 00000472 BE[ssss]                    mov si,DGROUP
   885 00000475 8CC0                        mov ax,es               ; get master segdef entry
   886 00000477 8ED8                        mov ds,ax               ; ds -> master segdef entry
   887 00000479 8EC6                        mov es,si               ; es:di -> write buffer
   888 0000047B A11000                      mov ax,[16]          ; get pointer to group entry
   889 0000047E 09C0                        or  ax,ax               ; check if zero (no group)
   890 00000480 7413                        je  mds_10              ; zero, no group name
   891 00000482 8ED8                        mov ds,ax               ; ds -> group entry
   892 00000484 C5360400                    lds si,[4]           ; ds:si -> group name
   893 00000488 83C608                      add si,8                ; adjust past doubleword pointers
   894                                  
   895                                  mds_loop5:
   896 0000048B 8A04                        mov al,[si]             ; see if null terminator reached
   897 0000048D 08C0                        or  al,al
   898 0000048F 7404                        je  mds_10              ; yes
   899 00000491 A4                          movsb                   ; transfer byte of name
   900 00000492 42                          inc dx                  ; no, bump count of chars in string
   901 00000493 EBF6                        jmp SHORT mds_loop5     ; loop for next char transfer
   902                                  
   903                                  mds_10:
   904 00000495 47                          inc di                  ; add space after name
   905 00000496 42                          inc dx
   906 00000497 B84800                      mov ax,72
   907 0000049A 39C2                        cmp dx,ax               ; see if at least 72 chars written
   908 0000049C 7306                        jae mds_11              ; yes
   909 0000049E 29D0                        sub ax,dx
   910 000004A0 01C7                        add di,ax               ; position to class field
   911 000004A2 01C2                        add dx,ax               ; adjust char count
   912                                  
   913                                  mds_11:
   914 000004A4 B8[ssss]                    mov ax,DGROUP
   915 000004A7 8ED8                        mov ds,ax               ; restore ds -> warplink data
   916 000004A9 8EC0                        mov es,ax               ; es -> warplink data
   917                                  
   918                                  ; write module
   919 000004AB BE[0000]                    mov si,OFFSET tmod_name wrt DGROUP
   920                                  
   921                                  mds_loop6:
   922 000004AE 8A04                        mov al,[si]             ; see if null terminator reached
   923 000004B0 08C0                        or  al,al
   924 000004B2 7404                        je  mds_12              ; yes
   925 000004B4 A4                          movsb                   ; transfer byte of name
   926 000004B5 42                          inc dx                  ; no, bump count of chars in string
   927 000004B6 EBF6                        jmp SHORT mds_loop6     ; loop for next char transfer
   928                                  
   929                                  mds_12:
   930 000004B8 47                          inc di                  ; add space after name
   931 000004B9 42                          inc dx
   932 000004BA B85500                      mov ax,85
   933 000004BD 39C2                        cmp dx,ax               ; see if at least 85 chars written
   934 000004BF 7306                        jae mds_13              ; yes
   935 000004C1 29D0                        sub ax,dx
   936 000004C3 01C7                        add di,ax               ; position to class field
   937 000004C5 01C2                        add dx,ax               ; adjust char count
   938                                  
   939                                  ; write file
   940                                  mds_13:
   941 000004C7 BE[0000]                    mov si,OFFSET filename wrt DGROUP
   942                                  
   943                                  mds_loop7:
   944 000004CA 8A04                        mov al,[si]             ; see if null terminator reached
   945 000004CC 08C0                        or  al,al
   946 000004CE 7404                        je  mds_14              ; yes
   947 000004D0 A4                          movsb                   ; transfer byte of name
   948 000004D1 42                          inc dx                  ; no, bump count of chars in string
   949 000004D2 EBF6                        jmp SHORT mds_loop7     ; loop for next char transfer
   950                                  
   951                                  mds_14:
   952 000004D4 C7050D0A                    mov word [di], CR + (LF << 8)    ; cr/lf terminate
   953 000004D8 42                          inc dx
   954 000004D9 42                          inc dx                ; bump count of chars in string
   955                                  
   956 000004DA 8EC3                        mov es,bx               ; restore es -> segment partition entry
   957                                  
   958 000004DC 89D1                        mov cx,dx               ; get count of chars to write
   959 000004DE 8B1E[0000]                  mov bx,[map_handle]
   960 000004E2 BA[0200]                    mov dx,OFFSET map_text_buffer wrt DGROUP   ; ds:dx -> text to write
   961 000004E5 B440                        mov ah,40h              ; write to file
   962 000004E7 CD21                        int 21h
   963 000004E9 E8(0000)                    call    restore_ems_map
   964 000004EC 7306                        jnc .checkspace             ; no errors
   965                                  .error:
   966 000004EE BA[0000]                    mov dx,OFFSET map_name wrt DGROUP
   967 000004F1 E9(0000)                    jmp NEAR PTR dos_error  ; error writing to file
   968                                  
   969                                  .checkspace:
   970 000004F4 39C8                    	cmp ax, cx
   971 000004F6 B82700                  	mov ax, 27h			; insufficient disk space error
   972 000004F9 75F3                    	jne .error
   973                                  
   974                                  mds_ret:
   975 000004FB 5E                          pop si
   976 000004FC 5A                          pop dx
   977 000004FD 59                          pop cx
   978 000004FE 5B                          pop bx
   979 000004FF C3                          ret
   980                                  map_detail_seg  ENDP
   981                                  
   982                                  ;*****************************
   983                                  ;* SEG_OFFSET_TO_PARA        *
   984                                  ;*****************************
   985                                  
   986                                  ; convert segment offset to paragraphs
   987                                  ; destroys ax
   988                                  ; returns value in cx
   989                                  
   990                                   global seg_offset_to_para
   991                                  seg_offset_to_para  PROC
   992 00000500 268B0E0200                  mov cx,[es:2]           ; get low word of offset
   993 00000505 26A10400                    mov ax,[es:4]           ; get high word of offset
   994 00000509 D1E8                        shr ax,1                ; convert offset in ax:cx to paragraphs
   995 0000050B D1D9                        rcr cx,1                ; /2
   996 0000050D D1E8                        shr ax,1
   997 0000050F D1D9                        rcr cx,1                ; /4
   998 00000511 D1E8                        shr ax,1
   999 00000513 D1D9                        rcr cx,1                ; /8
  1000 00000515 D1E8                        shr ax,1
  1001 00000517 D1D9                        rcr cx,1                ; /16
  1002 00000519 C3                          ret
  1003                                  seg_offset_to_para  ENDP
  1004                                  
  1005                                  ;*****************************
  1006                                  ;* HEXXIT                    *
  1007                                  ;*****************************
  1008                                  
  1009                                  ; convert 4 or 8 bit hex number to its ASCII representation
  1010                                  ; upon entry cl contains number
  1011                                  ; ah == 1 if 4 bit, == 0 if 8 bit
  1012                                  ; bx -> place to put digits
  1013                                  ; destroys al,cl
  1014                                  ; updates bx,dx (number of chars in string)
  1015                                  
  1016                                  hexxit  PROC
  1017 0000051A 08E4                        or  ah,ah               ; check if 4 bit or 8 bit value
  1018 0000051C 7518                        jne hx_4bit             ; 4 bit
  1019 0000051E 88C8                        mov al,cl
  1020 00000520 24F0                        and al,0f0h             ; get high nybble
  1021 00000522 D0E8                        shr al,1                ; make value relative zero
  1022 00000524 D0E8                        shr al,1
  1023 00000526 D0E8                        shr al,1
  1024 00000528 D0E8                        shr al,1                ; al has relative zero value
  1025 0000052A 3C0A                        cmp al,0ah              ; see if need to use hex numbers a-f
  1026 0000052C 7202                        jb  hx_2                ; no
  1027 0000052E 0407                        add al,7                ; adjust for ASCII jump to alpha chars
  1028                                  
  1029                                  hx_2:
  1030 00000530 0430                        add al,30h              ; make number an ASCII representation
  1031 00000532 8807                        mov [bx],al             ; save it to number string
  1032 00000534 43                          inc bx                  ; point to next char slot
  1033 00000535 42                          inc dx                  ; bump count of chars in number string
  1034                                  
  1035                                  hx_4bit:
  1036 00000536 80E10F                      and cl,0fh              ; get low nybble
  1037 00000539 80F90A                      cmp cl,0ah              ; see if hex number a-f
  1038 0000053C 7203                        jb  hx_5                ; no
  1039 0000053E 80C107                      add cl,7                ; adjust for ASCII jump to alpha chars
  1040                                  hx_5:
  1041 00000541 80C130                      add cl,30h              ; make number an ASCII representation
  1042 00000544 880F                        mov [bx],cl             ; save it to number string
  1043 00000546 43                          inc bx                  ; point to next char slot
  1044 00000547 42                          inc dx                  ; bump count of chars in number string
  1045 00000548 C3                          ret
  1046                                  hexxit  ENDP
  1047                                  
  1048                                  ;*****************************
  1049                                  ;* FINISH_MAP                *
  1050                                  ;*****************************
  1051                                  
  1052                                  ; write remaining map info
  1053                                  ; destroys ax,bx,cx,dx
  1054                                  
  1055                                  finish_map  PROC
  1056 00000549 803E[0000]00                cmp byte [is_mapfile],0        ; see if map file
  1057 0000054E 741B                        je  fm_ret              ; no
  1058                                  
  1059 00000550 803E[0000]00                cmp byte [is_mapexpand],0      ; check if expanded map file
  1060 00000555 7403                        je  fm_2                ; no
  1061 00000557 E81200                      call    map_publics     ; write the public addresses and names to map file
  1062                                  
  1063                                  fm_2:
  1064 0000055A E8F301                      call    map_entry       ; write program entry point
  1065 0000055D E83602                  	call map_exe_size
  1066 00000560 8B1E[0000]                  mov bx,[map_handle]       ; get handle of map file
  1067 00000564 B43E                        mov ah,3eh              ; close file
  1068 00000566 CD21                        int 21h
  1069 00000568 E8(0000)                    call    restore_ems_map
  1070                                  
  1071                                  fm_ret:
  1072 0000056B C3                          ret
  1073                                  finish_map  ENDP
  1074                                  
  1075                                  ;*****************************
  1076                                  ;* MAP_PUBLICS               *
  1077                                  ;*****************************
  1078                                  
  1079                                  ; map public symbol addresses and names
  1080                                  ; destroys ax,bx,cx,dx,di,si,es
  1081                                  
  1082                                  map_publics PROC
  1083 0000056C 8A0E[7301]                  mov cl,[maddrtext_len]    ; get length of text to write
  1084 00000570 30ED                        xor ch,ch               ; zap high byte
  1085 00000572 8B1E[0000]                  mov bx,[map_handle]
  1086 00000576 BA[7401]                    mov dx,OFFSET maddr_text wrt DGROUP ; ds:dx -> text to write
  1087 00000579 B440                        mov ah,40h              ; write to file
  1088 0000057B CD21                        int 21h
  1089 0000057D E8(0000)                    call    restore_ems_map
  1090 00000580 7306                        jnc .mp_2                ; no errors
  1091                                  .error:
  1092 00000582 BA[0000]                    mov dx,OFFSET map_name wrt DGROUP
  1093 00000585 E9(0000)                    jmp NEAR PTR dos_error  ; error writing to file
  1094                                  
  1095                                  .mp_2:
  1096 00000588 39C8                    	cmp ax, cx
  1097 0000058A B82700                  	mov ax, 27h			; insufficient disk space error
  1098 0000058D 75F3                    	jne .error
  1099 0000058F A1[0000]                    mov ax,[first_pdeclblk_ptr]   ; get pointer to first public declarations block
  1100 00000592 09C0                        or  ax,ax               ; check if non-null
  1101 00000594 7503                        jne mp_blkloop          ; non-null, public declarations exist
  1102 00000596 E9A101                      jmp NEAR PTR mp_communal_chk    ; null, try communal declarations block
  1103                                  
  1104                                  mp_blkloop:
  1105 00000599 50                          push    ax              ; save -> block on stack
  1106 0000059A 8EC0                        mov es,ax               ; es -> declarations block
  1107 0000059C 268B360000                  mov si,[es:0]           ; get count of entries in block
  1108                                  
  1109                                  mp_entloop:
  1110 000005A1 40                          inc ax                  ; ax -> next entry in block
  1111 000005A2 8EC0                        mov es,ax               ; es -> declaration entry
  1112 000005A4 06                          push    es              ; save -> declaration entry
  1113                                  
  1114                                  ; 12/21/92
  1115                                  ;***	test    BYTE PTR [es:15],20h    ; see if local communal (don't list locals)
  1116 000005A5 26F6060F0024                test    BYTE PTR [es:15],24h    ; see if local
  1117                                  
  1118 000005AB 7404                        je  mp_not_local        ; no
  1119                                  
  1120                                  mp_noprint:
  1121 000005AD 07                          pop es                  ; restore stack
  1122 000005AE E96F01                      jmp NEAR PTR mp_next_entry  ; try next entry in block
  1123                                  
  1124                                  mp_not_local:
  1125 000005B1 26F6060E0003                test    BYTE PTR [es:14],3  ; see if weak extdef
  1126 000005B7 74F4                        je  mp_noprint          ; yes, don't print it
  1127                                  
  1128 000005B9 268A260F00                  mov ah,[es:15]          ; get general flags
  1129 000005BE F6C401                      test    ah,1            ; get in overlay flag
  1130 000005C1 751B                        jne mp_overlaid         ; set, in overlay, zero segment offset
  1131 000005C3 26A00E00                    mov al,[es:14]          ; get definition flag
  1132 000005C7 2403                        and al,3                ; get definition bits
  1133 000005C9 3C03                        cmp al,3                ; see if absolute
  1134 000005CB 7509                        jne mp_not_abs          ; no
  1135                                  
  1136                                  ; absolute symbol
  1137 000005CD 268B0E0200                  mov cx,[es:2]           ; get frame number in cx
  1138                                  
  1139                                  mp_zero_offset:
  1140 000005D2 31FF                        xor di,di               ; di==low nybble of segment offset (always zero)
  1141 000005D4 EB6E                        jmp SHORT mp_3          ; bypass segment frame code
  1142                                  
  1143                                  mp_not_abs:
  1144 000005D6 3C02                        cmp al,2                ; see if resolved
  1145 000005D8 740A                        je  mp_2a               ; yes
  1146 000005DA 31C9                        xor cx,cx               ; zero frame
  1147 000005DC EBF4                        jmp SHORT mp_zero_offset    ; go to zero offset code
  1148                                  
  1149                                  mp_overlaid:
  1150 000005DE 31C9                        xor cx,cx               ; zero frame
  1151 000005E0 89CF                        mov di,cx               ; zero public offset
  1152 000005E2 EB60                        jmp SHORT mp_3          ; bypass segment frame code
  1153                                  
  1154                                  mp_2a:
  1155 000005E4 268E060000                  mov es,[es:0]           ; es -> segment partition entry
  1156 000005E9 268B0E0000                  mov cx,[es:0]           ; get segment partition offset
  1157 000005EE 268E060400                  mov es,[es:4]           ; es -> segdef entry
  1158                                  
  1159 000005F3 80E480                      and ah,80h              ; see if public is in group
  1160 000005F6 743F                        je  mp_2b               ; no
  1161                                  
  1162 000005F8 89CF                        mov di,cx               ; di holds segment partition entry offset
  1163                                  
  1164 000005FA 268B0E0200                  mov cx,[es:2]           ; get low word of segment offset
  1165 000005FF 26A10400                    mov ax,[es:4]           ; get high word of segment offset
  1166 00000603 07                          pop es                  ; es -> public declaration entry
  1167 00000604 06                          push    es              ; restore -> public declaration entry to stack
  1168 00000605 268E060200                  mov es,[es:2]           ; es -> group entry
  1169 0000060A 262B0E0000                  sub cx,[es:0]           ; compute low word difference in group/segment offset
  1170 0000060F 261B060200                  sbb ax,[es:2]           ; compute high word difference in group/segment offset
  1171 00000614 01CF                        add di,cx               ; add difference into di, public offset
  1172                                  
  1173 00000616 26A10000                    mov ax,[es:0]           ; get low word of group offset
  1174 0000061A 89C1                        mov cx,ax               ; save in cx
  1175 0000061C 83E00F                      and ax,0fh              ; get paragraph remainder
  1176 0000061F 01C7                        add di,ax               ; add to public offset
  1177                                  
  1178 00000621 26A10200                    mov ax,[es:2]           ; get high word of group offset
  1179 00000625 D1E8                        shr ax,1                ; convert offset in ax:cx to paragraphs
  1180 00000627 D1D9                        rcr cx,1                ; /2
  1181 00000629 D1E8                        shr ax,1
  1182 0000062B D1D9                        rcr cx,1                ; /4
  1183 0000062D D1E8                        shr ax,1
  1184 0000062F D1D9                        rcr cx,1                ; /8
  1185 00000631 D1E8                        shr ax,1
  1186 00000633 D1D9                        rcr cx,1                ; /16
  1187 00000635 EB0D                        jmp SHORT mp_3          ; bypass segment specific code
  1188                                  
  1189                                  ; non-group public
  1190                                  mp_2b:
  1191 00000637 268B3E0200                  mov di,[es:2]           ; get low word of segment offset
  1192 0000063C 83E70F                      and di,0fh              ; di==low nybble of segment offset
  1193 0000063F 01CF                        add di,cx               ; add in segment partition entry offset
  1194                                  
  1195 00000641 E8BCFE                      call    seg_offset_to_para  ; get segment offset in paragraphs (frame) in cx
  1196                                  
  1197                                  mp_3:
  1198 00000644 BB[0200]                    mov bx,OFFSET map_text_buffer wrt DGROUP
  1199 00000647 C7070D0A                    mov word [bx], CR + (LF << 8)    ; prepend cr/lf pair
  1200 0000064B 43                          inc bx
  1201 0000064C 43                          inc bx
  1202 0000064D 86E9                        xchg    ch,cl           ; get high byte in cl, save low byte in ch
  1203 0000064F 30E4                        xor ah,ah               ; 8 bit value
  1204 00000651 E8C6FE                      call    hexxit
  1205 00000654 88E9                        mov cl,ch               ; get low byte
  1206 00000656 E8C1FE                      call    hexxit
  1207 00000659 C6073A                      mov BYTE PTR [bx],':'   ; put in ':'
  1208 0000065C 43                          inc bx
  1209                                  
  1210 0000065D 07                          pop es                  ; es -> declaration entry
  1211 0000065E 26033E0800                  add di,[es:8]           ; add in public offset
  1212 00000663 89F9                        mov cx,di
  1213 00000665 86E9                        xchg    ch,cl           ; get high byte in cl, save low byte in ch
  1214 00000667 30E4                        xor ah,ah               ; 8 bit value
  1215 00000669 E8AEFE                      call    hexxit
  1216 0000066C 88E9                        mov cl,ch               ; get low byte
  1217 0000066E E8A9FE                      call    hexxit
  1218                                  
  1219 00000671 B90B00                      mov cx,11                ; nine bytes to write, CR,LF,nnnn:nnnn
  1220 00000674 8B1E[0000]                  mov bx,[map_handle]
  1221 00000678 BA[0200]                    mov dx,OFFSET map_text_buffer wrt DGROUP    ; ds:dx -> text to write
  1222 0000067B B440                        mov ah,40h              ; write to file
  1223 0000067D CD21                        int 21h
  1224 0000067F E8(0000)                    call    restore_ems_map
  1225 00000682 7306                        jnc mp_4                ; no errors
  1226                                  
  1227                                  mp_toerr:
  1228 00000684 BA[0000]                    mov dx,OFFSET map_name wrt DGROUP
  1229 00000687 E9(0000)                    jmp NEAR PTR dos_error  ; error writing to file
  1230                                  
  1231                                  mp_4:
  1232 0000068A 39C8                    	cmp ax, cx
  1233 0000068C B82700                  	mov ax, 27h			; insufficient disk space error
  1234 0000068F 75F3                    	jne mp_toerr
  1235 00000691 26A00F00                    mov al,[es:15]          ; get general flag
  1236 00000695 2401                        and al,1                ; see if overlaid
  1237 00000697 751B                        jne mp_ovl              ; yes
  1238 00000699 26A00E00                    mov al,[es:14]          ; get definitions flag
  1239 0000069D 2403                        and al,3                ; get definition bits
  1240 0000069F 3C03                        cmp al,3                ; see if absolute
  1241 000006A1 7431                        je  mp_abs              ; no
  1242 000006A3 3C02                        cmp al,2                ; see if resolved public/communal
  1243 000006A5 7537                        jne mp_unres            ; no
  1244 000006A7 26F6060F0040                test    BYTE PTR [es:15],40h    ; see if communal
  1245 000006AD 742A                        je  mp_res              ; no, resolved public
  1246                                  
  1247                                  ;communal variable
  1248 000006AF BA[B601]                    mov dx,OFFSET mpub_comm wrt DGROUP
  1249 000006B2 EB2D                        jmp SHORT mp_print_pubtype
  1250                                  
  1251                                  ; overlaid variable
  1252                                  mp_ovl:
  1253 000006B4 06                          push    es              ; save critical register
  1254 000006B5 268E060000                  mov es,[es:0]           ; es -> segment partition entry
  1255 000006BA 268B0E0400                  mov cx,[es:4]           ; get overlay identifier
  1256 000006BF 07                          pop es                  ; restore critical register
  1257 000006C0 BB[9A01]                    mov bx,OFFSET mpub_ovl+5 wrt DGROUP ; bx -> place to put overlay number
  1258 000006C3 86E9                        xchg    ch,cl           ; get high byte in cl, save low byte in ch
  1259 000006C5 30E4                        xor ah,ah               ; 8 bit value
  1260 000006C7 E850FE                      call    hexxit
  1261 000006CA 88E9                        mov cl,ch               ; get low byte
  1262 000006CC E84BFE                      call    hexxit
  1263                                  
  1264 000006CF BA[9501]                    mov dx,OFFSET mpub_ovl wrt DGROUP
  1265 000006D2 EB0D                        jmp SHORT mp_print_pubtype
  1266                                  
  1267                                  ; absolute variable
  1268                                  mp_abs:
  1269 000006D4 BA[A001]                    mov dx,OFFSET mpub_abs wrt DGROUP
  1270 000006D7 EB08                        jmp SHORT mp_print_pubtype
  1271                                  
  1272                                  ; resolved public
  1273                                  mp_res:
  1274 000006D9 BA[C101]                    mov dx,OFFSET mpub_res wrt DGROUP
  1275 000006DC EB03                        jmp SHORT mp_print_pubtype
  1276                                  
  1277                                  ; unresolved public
  1278                                  mp_unres:
  1279 000006DE BA[AB01]                    mov dx,OFFSET mpub_unres wrt DGROUP
  1280                                  
  1281                                  mp_print_pubtype:
  1282 000006E1 B90B00                      mov cx,11
  1283 000006E4 8B1E[0000]                  mov bx,[map_handle]
  1284 000006E8 B440                        mov ah,40h              ; write to file
  1285 000006EA CD21                        int 21h
  1286 000006EC E8(0000)                    call    restore_ems_map
  1287 000006EF 7293                        jc  mp_toerr            ; error occurred
  1288 000006F1 39C8                    	cmp ax, cx
  1289 000006F3 B82700                  	mov ax, 27h			; insufficient disk space error
  1290 000006F6 758C                    	jne mp_toerr
  1291                                  
  1292 000006F8 8B1E[0000]                  mov bx,[map_handle]
  1293 000006FC 1E                          push    ds              ; save critical register
  1294 000006FD 26C53E0400                  lds di,[es:4]           ; get -> pubdef name in es:bx
  1295 00000702 89FA                        mov dx,di               ; save -> name
  1296 00000704 31C9                        xor cx,cx               ; cx will hold of chars in name
  1297                                  
  1298                                  mp_loop:
  1299 00000706 803D00                      cmp BYTE PTR [di],0     ; see if zero terminator in symbol name found
  1300 00000709 7404                        je  mp_5                ; yes
  1301 0000070B 41                          inc cx                  ; bump count of chars in string
  1302 0000070C 47                          inc di                  ; move to next char slot to test
  1303 0000070D EBF7                        jmp SHORT mp_loop       ; loop back to test next char
  1304                                  
  1305                                  mp_5:
  1306 0000070F B440                        mov ah,40h              ; write to file
  1307 00000711 CD21                        int 21h
  1308 00000713 E8(0000)                    call    restore_ems_map
  1309 00000716 1F                          pop ds                  ; restore ds -> machlink data
  1310 00000717 720F                        jc  mp_toerr2           ; error occurred
  1311 00000719 39C8                    	cmp ax, cx
  1312 0000071B B82700                  	mov ax, 27h			; insufficient disk space error
  1313 0000071E 7508                    	jne mp_toerr2
  1314                                  
  1315                                  mp_next_entry:
  1316 00000720 8CC0                        mov ax,es               ; ax -> current entry
  1317 00000722 4E                          dec si                  ; drop count of entries in block
  1318 00000723 7409                        je  mp_next_block       ; no more entries try next block
  1319 00000725 E979FE                      jmp NEAR PTR mp_entloop ; print next entry
  1320                                  
  1321                                  mp_toerr2:
  1322 00000728 BA[0000]                    mov dx,OFFSET map_name wrt DGROUP
  1323 0000072B E9(0000)                    jmp NEAR PTR dos_error  ; error writing to file
  1324                                  
  1325                                  mp_next_block:
  1326 0000072E 07                          pop es                  ; restore es -> block
  1327 0000072F 26A10200                    mov ax,[es:2]           ; get pointer to next block, if any
  1328 00000733 09C0                        or  ax,ax               ; check if non-null
  1329 00000735 7403                        je  mp_communal_chk     ; null, check communals
  1330 00000737 E95FFE                      jmp NEAR PTR mp_blkloop ; loop back for more publics
  1331                                  
  1332                                  mp_communal_chk:
  1333 0000073A FE06[0200]                  inc byte [comm_loop_flag]      ; bump counter
  1334 0000073E 803E[0200]01                cmp byte [comm_loop_flag],1    ; see if communal blocks printed yet
  1335 00000743 770A                        ja  mp_ret              ; yes
  1336 00000745 A1[0000]                    mov ax,[first_cdeclblk_ptr]   ; get pointer to first communal declarations block
  1337 00000748 09C0                        or  ax,ax               ; check if non-null
  1338 0000074A 7403                        je  mp_ret              ; null, done
  1339 0000074C E94AFE                      jmp NEAR PTR mp_blkloop ; non-null, print declarations in communal block
  1340                                  
  1341                                  mp_ret:
  1342 0000074F C3                          ret
  1343                                  map_publics ENDP
  1344                                  
  1345                                  ;*****************************
  1346                                  ;* MAP_ENTRY                 *
  1347                                  ;*****************************
  1348                                  
  1349                                  ; map entry point of program
  1350                                  ; destroys ax,bx,cx,dx
  1351                                  
  1352                                  map_entry   PROC
  1353 00000750 BB[7300]                    mov bx,OFFSET map_entry_value wrt DGROUP    ; point to place to stuff entry value
  1354 00000753 8A0E[0100]                  mov cl,BYTE PTR [entry_segval+1]  ; get MSB of entry segment
  1355 00000757 30E4                        xor ah,ah               ; 8 bit value
  1356 00000759 E8BEFD                      call    hexxit
  1357 0000075C 8A0E[0000]                  mov cl,BYTE PTR [entry_segval]    ; get LSB of entry segment
  1358 00000760 E8B7FD                      call    hexxit
  1359                                  
  1360 00000763 43                          inc bx                  ; bump past colon
  1361 00000764 8A0E[0100]                  mov cl,BYTE PTR [entry_offval+1]  ; get MSB of entry offset
  1362 00000768 E8AFFD                      call    hexxit
  1363 0000076B 8A0E[0000]                  mov cl,BYTE PTR [entry_offval]    ; get LSB of entry offset
  1364 0000076F E8A8FD                      call    hexxit
  1365                                  
  1366 00000772 8A0E[5700]                  mov cl,[metext_len]       ; get length of text to write
  1367 00000776 30ED                        xor ch,ch               ; zap high byte
  1368 00000778 8B1E[0000]                  mov bx,[map_handle]
  1369 0000077C BA[5800]                    mov dx,OFFSET map_entry_text wrt DGROUP    ; ds:dx -> text to write
  1370 0000077F B440                        mov ah,40h              ; write to file
  1371 00000781 CD21                        int 21h
  1372 00000783 E8(0000)                    call    restore_ems_map
  1373 00000786 7306                        jnc .me_ret              ; no errors
  1374                                  .error:
  1375 00000788 BA[0000]                    mov dx,OFFSET map_name wrt DGROUP
  1376 0000078B E9(0000)                    jmp NEAR PTR dos_error  ; error writing to file
  1377                                  
  1378                                  .me_ret:
  1379 0000078E 39C8                    	cmp ax, cx
  1380 00000790 B82700                  	mov ax, 27h			; insufficient disk space error
  1381 00000793 75F3                    	jne .error
  1382 00000795 C3                          ret
  1383                                  map_entry   ENDP
  1384                                  
  1385                                  
  1386                                  
  1387                                  ; map exe header/image progbits/image nobits sizes of program
  1388                                  ; destroys ax,bx,cx,dx
  1389                                  
  1390                                  map_exe_size:
  1391 00000796 803E[0000]00            	cmp byte [is_comfile], 0	; see if is a com file
  1392 0000079B 7403E99600              	jne .ret
  1393                                  
  1394                                  	lframe near
  1395 000007A0 5589E5                  	lenter
  1396                                  
  1397                                   extern exe_header.eh_hsize
  1398 000007A3 B90400                  	mov cx, 4
  1399 000007A6 A1[0000]                	mov ax, [exe_header.eh_hsize]
  1400 000007A9 31D2                    	xor dx, dx
  1401                                  @@:
  1402 000007AB 01C0                    	add ax, ax
  1403 000007AD 11D2                    	adc dx, dx
  1404 000007AF E2FA                    	loop @B
  1405                                  
  1406                                  	lvar dword, headersize
  1407 000007B1 52                      	 push dx
  1408 000007B2 50                      	 push ax
  1409                                  
  1410 000007B3 BB[9600]                	mov bx, map_exe_header_size_value
  1411 000007B6 B401                    	mov ah, 1
  1412 000007B8 8A4EFE                  	mov cl, [bp + ?headersize + 2]
  1413 000007BB E85CFD                  	call hexxit
  1414 000007BE 30E4                    	xor ah, ah
  1415 000007C0 8A4EFD                  	mov cl, [bp + ?headersize + 1]
  1416 000007C3 E854FD                  	call hexxit
  1417 000007C6 8A4EFC                  	mov cl, [bp + ?headersize + 0]
  1418 000007C9 E84EFD                  	call hexxit
  1419                                  
  1420 000007CC A1[0000]                	mov ax, [highest_exe_write]
  1421 000007CF 8B16[0200]              	mov dx, [highest_exe_write + 2]
  1422 000007D3 83C001                  	add ax, 1
  1423 000007D6 83D200                  	adc dx, 0
  1424                                  
  1425                                  	lvar dword, initsize
  1426 000007D9 52                      	 push dx
  1427 000007DA 50                      	 push ax
  1428                                  
  1429 000007DB BB[C000]                	mov bx, map_exe_init_image_size_value
  1430 000007DE B401                    	mov ah, 1
  1431 000007E0 8A4EFA                  	mov cl, [bp + ?initsize + 2]
  1432 000007E3 E834FD                  	call hexxit
  1433 000007E6 30E4                    	xor ah, ah
  1434 000007E8 8A4EF9                  	mov cl, [bp + ?initsize + 1]
  1435 000007EB E82CFD                  	call hexxit
  1436 000007EE 8A4EF8                  	mov cl, [bp + ?initsize + 0]
  1437 000007F1 E826FD                  	call hexxit
  1438                                  
  1439 000007F4 89EC5D                  	lleave
  1440                                  
  1441 000007F7 BB[E400]                	mov bx, map_exe_total_image_size_value
  1442 000007FA B401                    	mov ah, 1
  1443 000007FC 8A0E[0200]              	mov cl, [image_size + 2]
  1444 00000800 E817FD                  	call hexxit
  1445 00000803 30E4                    	xor ah, ah
  1446 00000805 8A0E[0100]              	mov cl, [image_size + 1]
  1447 00000809 E80EFD                  	call hexxit
  1448 0000080C 8A0E[0000]              	mov cl, [image_size + 0]
  1449 00000810 E807FD                  	call hexxit
  1450                                  
  1451 00000813 8A0E[7E00]                  mov cl,[mestext_len]       ; get length of text to write
  1452 00000817 30ED                        xor ch,ch               ; zap high byte
  1453 00000819 8B1E[0000]                  mov bx,[map_handle]
  1454 0000081D BA[7F00]                	mov dx, map_exe_size_text	; ds:dx -> text to write
  1455 00000820 B440                        mov ah,40h              ; write to file
  1456 00000822 CD21                        int 21h
  1457 00000824 E8(0000)                    call    restore_ems_map
  1458 00000827 7306                        jnc .checkspace              ; no errors
  1459                                  .error:
  1460 00000829 BA[0000]                    mov dx,OFFSET map_name wrt DGROUP
  1461 0000082C E9(0000)                    jmp dos_error  ; error writing to file
  1462                                  .checkspace:
  1463 0000082F 39C8                    	cmp ax, cx
  1464 00000831 B82700                  	mov ax, 27h			; insufficient disk space error
  1465 00000834 75F3                    	jne .error
  1466                                  .ret:
  1467 00000836 C3                          retn
  1468                                  
  1469                                  END
