     1                                  ;*********************************************************************
     2                                  ;*   MLPAROVL.ASM                                                    *
     3                                  ;*                                                                   *
     4                                  ;*   By:            Michael Devore                                   *
     5                                  ;*   Date:          11/05/92                                         *
     6                                  ;*   Model:         Small                                            *
     7                                  ;*   Version:       2.5                                              *
     8                                  ;*   Assembler:     MASM 5.0                                         *
     9                                  ;*   Environment:   MS-DOS 2.x+                                      *
    10                                  ;*                                                                   *
    11                                  ;*   Parse linker overlay options                                    *
    12                                  ;*                                                                   *
    13                                  ;*********************************************************************
    14                                  
    15                                  ;TITLE   WARPLINK mlparovl
    16                                  ;PAGE    50,80
    17                                  
    18                                  ;.MODEL  SMALL
    19                                  
    20                                  ;*****************************
    21                                  ;* Include files             *
    22                                  ;*****************************
    23                                  
    24                                  [list -]
    29                                       
    30                                  ;*****************************
    31                                  ;* Public declarations       *
    32                                  ;*****************************
    33                                       
    34                                  PUBLIC  parse_ovl_option,save_ovl_name
    35                                  
    36                                  ;*****************************
    37                                  ;* Data begins               *
    38                                  ;*****************************
    39                                       
    40                                  .DATA
    41                                  
    42                                  ;*****************************
    43                                  ;* External declarations     *
    44                                  ;*****************************
    45                                  
    46                                  ; variables
    47                                  EXTRN   def_lib_flag:BYTE
    48                                  EXTRN   exe_pathspec:BYTE
    49                                  
    50                                  ; initialized local variables
    51                                  
    52                                  ; byte values
    53                                  EVEN
    54 00000000 00                      is_ovl_filename DB  0       ; nonzero if overlay file name specified
    55                                  
    56                                  .DATA?
    57                                  
    58                                  ; uninitialized local variables
    59                                  
    60                                  ;*****************************
    61                                  ;* Code begins               *
    62                                  ;*****************************
    63                                       
    64                                  .CODE
    65                                  
    66                                  ;*****************************
    67                                  ;* External declarations     *
    68                                  ;*****************************
    69                                  
    70                                  ; procedures
    71                                  EXTRN   link_error:NEAR,dos_error:NEAR,alloc_memory:NEAR
    72                                  EXTRN	is_terminator:NEAR
    73                                  
    74                                  ;*****************************
    75                                  ;* PARSE_OVL_OPTION          *
    76                                  ;*****************************
    77                                  
    78                                  ; parse overlay option
    79                                  ; ds:si -> second  char of option (past 'O')
    80                                  ; cx -> start of option
    81                                  ; destroys ax,dx,es
    82                                  ; updates si
    83                                  
    84                                  parse_ovl_option    PROC
    85 00000000 8CD8                        mov ax,ds
    86 00000002 8EC0                        mov es,ax               ; es -> warplink data
    87 00000004 AC                          lodsb                   ; get overlay option char
    88 00000005 3C41                        cmp al,'A'              ; check bounds
    89 00000007 7303                    	jae	ovl_boundchk		; okay
    90 00000009 E9A801                  	jmp	NEAR PTR ovl_bad_option	; too low
    91                                  
    92                                  ovl_boundchk:
    93 0000000C 3C7A                        cmp al,'z'              ; check bounds
    94 0000000E 777D                        ja  ovl_bad1            ; too high
    95                                  
    96                                  ovl_toupper:
    97 00000010 24DF                        and al,0dfh             ; force char to uppercase
    98                                  
    99                                  %IFNDEF DEMO
   100 00000012 3C49                        cmp al,'I'              ; see if internal overlays
   101 00000014 7504                        jne pop_chkumb          ; no
   102 00000016 A2[0000]                    mov [is_internal],al      ; set internal overlays flag
   103 00000019 C3                          ret
   104                                  %ENDIF
   105                                  
   106                                  pop_chkumb:
   107 0000001A 3C55                        cmp al,'U'              ; see if UMB use
   108 0000001C 7504                        jne pop_swap			; no
   109 0000001E A2[0000]                    mov [is_umb],al      		; set UMB flag
   110 00000021 C3                          ret
   111                                  
   112                                  pop_swap:
   113 00000022 3C48                        cmp al,'H'              ; see if overlay file stashing
   114 00000024 7511                        jne pop_stash           ; no
   115 00000026 AC                          lodsb                   ; get third option char
   116 00000027 24DF                        and al,0dfh             ; force char to uppercase
   117 00000029 3C54                        cmp al,'T'              ; see if extended file stashing
   118 0000002B 7503                        jne pop_ohp             ; no
   119 0000002D E98A01                      jmp NEAR PTR ovl_get_oht	; yes
   120                                  
   121                                  pop_ohp:
   122 00000030 3C50                        cmp al,'P'              ; see if expanded filestashing
   123 00000032 7559                        jne ovl_bad1            ; no, bad option
   124 00000034 E99601                      jmp NEAR PTR ovl_get_ohp	; yes
   125                                  
   126                                  pop_stash:
   127 00000037 3C52                        cmp al,'R'              ; see if active overlay stashing
   128 00000039 7513                        jne pop_chkems          ; no
   129 0000003B AC                          lodsb                   ; get third option char
   130 0000003C 24DF                        and al,0dfh             ; force char to uppercase
   131 0000003E 3C54                        cmp al,'T'              ; see if extended stashing
   132 00000040 7504                        jne pop_orp             ; no
   133 00000042 A2[0000]                    mov [is_xtstash],al       ; flag extended memory stashing
   134 00000045 C3                          ret
   135                                  
   136                                  pop_orp:
   137 00000046 3C50                        cmp al,'P'              ; see if expanded stashing
   138 00000048 7543                        jne ovl_bad1            ; no, bad option
   139 0000004A A2[0000]                    mov [is_xpstash],al
   140 0000004D C3                          ret
   141                                  
   142                                  pop_chkems:
   143 0000004E 3C58                        cmp al,'X'              ; see if overlay pool in EMS
   144 00000050 750B                        jne eat_colon           ; no
   145 00000052 A2[0000]                    mov [is_ems_ovlpool],al   ; set overlay pool in EMS flag
   146 00000055 8A24                        mov ah,[si]             ; peek at next char
   147 00000057 80FC3A                      cmp ah,':'              ; see if colon (e-var setting)
   148 0000005A 7401                        je  eat_colon           ; yes
   149 0000005C C3                          ret
   150                                  
   151                                  eat_colon:
   152 0000005D 88C4                        mov ah,al               ; save option in ah
   153 0000005F AC                          lodsb                   ; get colon following overlay option char
   154 00000060 3C3A                        cmp al,':'              ; must be colon
   155 00000062 7529                        jne ovl_bad1            ; not a colon
   156                                  
   157                                  ; check for valid option char in ah
   158                                  ovl_check_valid:
   159                                  %IFNDEF DEMO
   160 00000064 80FC43                      cmp ah,'C'              ; check if overlay class option
   161 00000067 7461                        je  ovl_get_class       ; yes
   162                                  
   163 00000069 80FC4C                      cmp ah,'L'              ; check if max overlay loaded count option
   164 0000006C 7502                        jne pop_1               ; no
   165 0000006E EB7F                        jmp NEAR PTR ovl_get_load   ; yes
   166                                  %ENDIF
   167                                  
   168                                  pop_1:
   169 00000070 80FC50                      cmp ah,'P'              ; check if overlay pool size option
   170 00000073 7503                        jne pop_2               ; no
   171 00000075 E9EA00                      jmp NEAR PTR ovl_get_pool   ; yes
   172                                  
   173                                  pop_2:
   174                                  %IFNDEF DEMO
   175 00000078 80FC53                      cmp ah,'S'              ; check if overlay stack size option
   176 0000007B 7413                        je  ovl_get_stack       ; yes
   177                                  
   178                                  pop_3:
   179 0000007D 80FC4E                      cmp ah,'N'              ; check if overlay file name
   180 00000080 7503                        jne pop_ox              ; no
   181 00000082 E9AB00                      jmp NEAR PTR ovl_get_name   ; get overlay file name
   182                                  %ENDIF
   183                                  
   184                                  pop_ox:
   185 00000085 80FC58                      cmp ah,'X'              ; check if /ox environment variable
   186 00000088 7503                        jne ovl_bad1            ; no, no more valid options
   187 0000008A E9C400                      jmp NEAR PTR ovl_get_evar   ; get ox environment variable
   188                                  
   189                                  ovl_bad1:                   ; bad overlay option specified
   190 0000008D E92401                  	jmp	NEAR PTR ovl_bad_option
   191                                  
   192                                  %IFNDEF DEMO
   193                                  ; overlay stack size option
   194                                  ovl_get_stack:
   195 00000090 31D2                        xor dx,dx               ; dx == multiplier
   196                                  
   197                                  ogs_2:
   198 00000092 AC                          lodsb                   ; get number
   199 00000093 3C30                        cmp al,'0'              ; see nondigit
   200 00000095 721C                        jb  ogs_done            ; yes, done
   201 00000097 3C39                        cmp al,'9'              ; see nondigit
   202 00000099 7718                        ja  ogs_done            ; yes
   203                                  
   204 0000009B 240F                        and al,0fh              ; change from ASCII to actual value
   205 0000009D 88C6                        mov dh,al               ; save value
   206 0000009F 88D0                        mov al,dl               ; get pre-existing value
   207 000000A1 B40A                        mov ah,10
   208 000000A3 F6E4                        mul ah                  ; multiply pre-existing value by 10 (shift placeholder)
   209 000000A5 92                          xchg    dx,ax           ; save shifted value back to dx, get new value in ah
   210 000000A6 88E0                        mov al,ah               ; get value in low byte
   211 000000A8 30E4                        xor ah,ah               ; zap high byte
   212 000000AA 01C2                        add dx,ax               ; add in new value
   213 000000AC 08F6                        or  dh,dh               ; see if value too large
   214 000000AE 74E2                        je  ogs_2               ; no, get next digit
   215 000000B0 E90101                      jmp NEAR PTR ovl_bad_option ; yes
   216                                  
   217                                  ogs_done:
   218 000000B3 83FA3F                      cmp dx,63               ; check if absolute maximum exceeded
   219 000000B6 77D5                        ja  ovl_bad1            ; yes
   220 000000B8 09D2                        or  dx,dx               ; value cannot be zero
   221 000000BA 74D1                        je  ovl_bad1
   222 000000BC 88D6                        mov dh,dl
   223 000000BE 30D2                        xor dl,dl               ; effective multiply by 256
   224 000000C0 D0E6                        shl dh,1                ; x512
   225 000000C2 D0E6                        shl dh,1                ; x1024, convert stack size to kilobytes
   226 000000C4 8916[0000]                  mov [ovl_stack],dx        ; save stack size
   227 000000C8 4E                          dec si                  ; drop si back to -> nondigit char
   228 000000C9 C3                          ret                     ; done
   229                                  
   230                                  ; overlay class option
   231                                  ovl_get_class:
   232 000000CA BF[0000]                    mov di,OFFSET ovl_class wrt DGROUP  ; es:di -> place for overlay class name
   233 000000CD 8A04                        mov al,[si]             ; peek ahead at next char
   234 000000CF 3C2E                        cmp al,'.'              ; see if a period (exact match indicator)
   235 000000D1 7504                        jne ogc_2               ; no
   236 000000D3 AC                          lodsb                   ; gobble period
   237 000000D4 A2[0000]                    mov [exact_ovl_class],al  ; set exact class match flag
   238                                  
   239                                  ogc_2:
   240 000000D7 AC                          lodsb                   ; get name char
   241 000000D8 E8(0000)                	call	is_terminator	; see if name parse terminator
   242 000000DB 740D                        je 	ogc_done            ; yes, done
   243                                  
   244 000000DD 3C61                        cmp al,'a'              ; see if lowercase
   245 000000DF 7206                        jb  ogc_3               ; no
   246 000000E1 3C7A                        cmp al,'z'
   247 000000E3 7702                        ja  ogc_3
   248 000000E5 2C20                        sub al,20h              ; change lowercase to uppercase
   249                                  
   250                                  ogc_3:
   251 000000E7 AA                          stosb                   ; name char, transfer it
   252 000000E8 EBED                        jmp SHORT ogc_2         ; get next char
   253                                  
   254                                  ogc_done:
   255 000000EA 4E                          dec si                  ; drop si back to -> terminating char
   256 000000EB 30C0                        xor al,al               ; null terminate string
   257 000000ED AA                          stosb                   ; transfer it
   258 000000EE C3                          ret                     ; done
   259                                  
   260                                  ; maximum loaded overlay count option
   261                                  ovl_get_load:
   262 000000EF 31D2                        xor dx,dx               ; dx == multiplier
   263                                  
   264                                  ogl_2:
   265 000000F1 AC                          lodsb                   ; get number
   266 000000F2 3C30                        cmp al,'0'              ; see nondigit
   267 000000F4 721B                        jb  ogl_done            ; yes, done
   268 000000F6 3C39                        cmp al,'9'              ; see nondigit
   269 000000F8 7717                        ja  ogl_done            ; yes
   270                                  
   271 000000FA 240F                        and al,0fh              ; change from ASCII to actual value
   272 000000FC 08F6                        or  dh,dh               ; see if value too large for shift
   273 000000FE 752D                        jne ovl_bad2            ; yes
   274 00000100 88C6                        mov dh,al               ; save value
   275 00000102 88D0                        mov al,dl               ; get pre-existing value
   276 00000104 B40A                        mov ah,10
   277 00000106 F6E4                        mul ah                  ; multiply pre-existing value by 10 (shift placeholder)
   278 00000108 92                          xchg    dx,ax           ; save shifted value back to dx, get new value in ah
   279 00000109 88E0                        mov al,ah               ; get value in low byte
   280 0000010B 30E4                        xor ah,ah               ; zap high byte
   281 0000010D 01C2                        add dx,ax               ; add in new value
   282 0000010F EBE0                        jmp SHORT ogl_2         ; get next digit
   283                                  
   284                                  ogl_done:
   285 00000111 81FA0002                    cmp dx,512              ; check if absolute maximum exceeded
   286 00000115 7716                        ja  ovl_bad2            ; yes
   287 00000117 09D2                        or  dx,dx               ; value cannot be zero
   288 00000119 7412                        je  ovl_bad2
   289 0000011B 8916[0000]                  mov [ovl_max_load],dx     ; save maximum load count
   290 0000011F D1E2                        shl dx,1                ; x2
   291 00000121 D1E2                        shl dx,1                ; x4
   292 00000123 D1E2                        shl dx,1                ; x8
   293 00000125 D1E2                        shl dx,1                ; x16, size of load array (count*16)
   294 00000127 8916[0000]                  mov [ovl_max_load_size],dx
   295 0000012B 4E                          dec si                  ; drop si back to -> nondigit char
   296 0000012C C3                          ret                     ; done
   297                                  
   298                                  ovl_bad2:                   ; bad overlay option specified
   299 0000012D E98400                  	jmp	NEAR PTR ovl_bad_option
   300                                  
   301                                  ; overlay file name
   302                                  ovl_get_name:
   303 00000130 BF[0000]                    mov di,OFFSET ovl_nopath wrt DGROUP ; es:di -> place for overlay file name, without path
   304 00000133 C606[0000]01                mov byte [is_ovl_filename],1   ; set flag to indicate overlay file name indicated
   305                                  
   306                                  ogn_2:
   307 00000138 AC                          lodsb                   ; get name char
   308 00000139 E8(0000)                	call	is_terminator	; see if file name parse terminator
   309 0000013C 740E                        je	ogn_done            ; yes, done
   310                                  
   311 0000013E 3C5C                        cmp al,'\'              ; see if backslash, directory specifier, filename no good
   312 00000140 7472                        je  ovl_bad_option      ; yes, abort
   313 00000142 3C2E                        cmp al,'.'              ; see if extension was specified
   314 00000144 7503                        jne ogn_3               ; not yet
   315 00000146 A2[0000]                    mov [is_ovl_filename],al  ; set flag to '.' value to indicate extension specified
   316                                  
   317                                  ogn_3:
   318 00000149 AA                          stosb                   ; name char, transfer it
   319 0000014A EBEC                        jmp SHORT ogn_2         ; get next char
   320                                  %ENDIF
   321                                  
   322                                  ogn_done:
   323 0000014C 4E                          dec si                  ; drop si back to -> terminating char
   324 0000014D 30C0                        xor al,al               ; null terminate string
   325 0000014F AA                          stosb                   ; transfer it
   326 00000150 C3                          ret                     ; done
   327                                  
   328                                  ; /ox environment variable
   329                                  ovl_get_evar:
   330 00000151 BF[0000]                    mov di,OFFSET ovl_ox_evar wrt DGROUP    ; es:di -> place for overlay file name, without path
   331                                  oge_loop:
   332 00000154 AC                          lodsb                   ; get name char
   333 00000155 3C20                        cmp al,' '              ; see if whitespace char
   334 00000157 76F3                        jbe ogn_done            ; yes, done
   335 00000159 AA                          stosb                   ; transfer e-var setting
   336 0000015A 81FF[2000]                  cmp di,OFFSET ovl_ox_evar+32 wrt DGROUP ; see if overflowed maximum of 31 bytes
   337 0000015E 7354                        jae ovl_bad_option      ; yes
   338 00000160 EBF2                        jmp SHORT oge_loop
   339                                  
   340                                  ; overlay pool size option
   341                                  ovl_get_pool:
   342 00000162 31D2                        xor dx,dx               ; dx == multiplier
   343 00000164 8A04                        mov al,[si]             ; peek at next char
   344                                  
   345 00000166 3C4D                        cmp al,'M'              ; check if minimum pool size option
   346 00000168 7404                        je  ogp_minpool         ; yes
   347 0000016A 3C6D                        cmp al,'m'              ; check if lowercase option
   348 0000016C 7508                        jne ogp_notmin          ; no
   349                                  
   350                                  ogp_minpool:
   351 0000016E AC                          lodsb                   ; gobble 'M'
   352 0000016F A2[0000]                    mov [is_min_pool],al      ; set minimum pool size flag
   353 00000172 A2[0000]                    mov [ovl_mem_alloc],al    ; flag to allocate specified memory for pool, not free memory
   354 00000175 C3                          ret
   355                                  
   356                                  ogp_notmin:
   357 00000176 3C2D                        cmp al,'-'              ; see if minus, specified amount is free memory, not pool memory
   358 00000178 7405                        je  ogp_2               ; yes
   359 0000017A A2[0000]                    mov [ovl_mem_alloc],al    ; flag to allocate specified memory for pool, not free memory
   360 0000017D EB01                        jmp SHORT ogp_3         ; bypass '-' code
   361                                  
   362                                  ; - prepended to number, gobble it
   363                                  ogp_2:
   364 0000017F AC                          lodsb                   ; gobble sign
   365                                  
   366                                  ogp_3:
   367 00000180 AC                          lodsb                   ; get number
   368 00000181 3C30                        cmp al,'0'              ; see nondigit
   369 00000183 721B                        jb  ogp_done            ; yes, done
   370 00000185 3C39                        cmp al,'9'              ; see nondigit
   371 00000187 7717                        ja  ogp_done            ; yes
   372                                  
   373 00000189 240F                        and al,0fh              ; change from ASCII to actual value
   374 0000018B 08F6                        or  dh,dh               ; see if value too large for shift
   375 0000018D 7525                        jne ovl_bad_option      ; yes
   376 0000018F 88C6                        mov dh,al               ; save value
   377 00000191 88D0                        mov al,dl               ; get pre-existing value
   378 00000193 B40A                        mov ah,10
   379 00000195 F6E4                        mul ah                  ; multiply pre-existing value by 10 (shift placeholder)
   380 00000197 92                          xchg    dx,ax           ; save shifted value back to dx, get new value in ah
   381 00000198 88E0                        mov al,ah               ; get value in low byte
   382 0000019A 30E4                        xor ah,ah               ; zap high byte
   383 0000019C 01C2                        add dx,ax               ; add in new value
   384 0000019E EBE0                        jmp SHORT ogp_3         ; get next digit
   385                                  
   386                                  ogp_done:
   387 000001A0 81FA0002                    cmp dx,512              ; check if absolute maximum exceeded
   388 000001A4 770E                        ja  ovl_bad_option      ; yes
   389 000001A6 09D2                        or  dx,dx               ; value cannot be zero
   390 000001A8 740A                        je  ovl_bad_option
   391                                  
   392                                  ; convert memory allocated/free size to kilobytes
   393 000001AA D1E2                        shl dx,1                ; x2
   394 000001AC D1E2                        shl dx,1                ; x4
   395 000001AE 8916[0100]                  mov WORD PTR [ovl_pool+1],dx  ; store offset by one byte does effective multiply by 256
   396 000001B2 4E                          dec si                  ; drop si back to -> nondigit char
   397                                  
   398                                  pop_ret:
   399 000001B3 C3                          ret
   400                                  
   401                                  ovl_bad_option:             ; bad overlay option specified
   402 000001B4 B80500                      mov ax,BAD_OPTION_ERR   ; error value
   403 000001B7 E9(0000)                    jmp NEAR PTR link_error ; transfer control to error handler
   404                                  
   405                                  ovl_get_oht:
   406 000001BA E82F00                  	call	parse_ohx_value	; size in ax, zero flag set if minus value
   407 000001BD A3[0000]                	mov	[ovl_oht_size],ax
   408 000001C0 C606[0000]01            	mov	byte [is_oht],1			; flag /oht setting
   409 000001C5 74EC                    	je	pop_ret				; minus found
   410 000001C7 C606[0000]01            	mov	byte [ovl_oht_alloc],1		; set allocation flag
   411 000001CC C3                      	ret
   412                                  
   413                                  ovl_get_ohp:
   414 000001CD 8A04                    	mov	al,[si]			; peek at following char
   415                                  %IFNDEF DEMO
   416 000001CF 3C33                    	cmp	al,'3'				; see if explicit EMS 3.0 compatibility flag
   417 000001D1 7506                    	jne	ovl_parse_ohp		; no
   418 000001D3 AC                      	lodsb					; gobble the 3
   419 000001D4 C606[0000]01            	mov	byte [ems3_flag],1			; set EMS 3.0 compatibility mode
   420                                  %ENDIF
   421                                  
   422                                  ovl_parse_ohp:
   423 000001D9 E81000                  	call	parse_ohx_value	; size in ax, zero flag set if minus value
   424 000001DC A3[0000]                	mov	[ovl_ohp_size],ax
   425 000001DF C606[0000]01            	mov	byte [is_ohp],1			; flag /ohp setting
   426 000001E4 74CD                    	je	pop_ret				; minus found
   427 000001E6 C606[0000]01            	mov	byte [ovl_ohp_alloc],1		; set allocation flag
   428 000001EB C3                      	ret
   429                                  
   430                                  parse_ovl_option    ENDP
   431                                  
   432                                  ;*****************************
   433                                  ;* PARSE_OHX_VALUE           *
   434                                  ;*****************************
   435                                  
   436                                  ; parse out the value for /oht or /ohp
   437                                  ; returns zero flag set if '-' present, reset if no minus (no minus means allocate to, minus means leave free)
   438                                  ; returns size in ax
   439                                  ; updates si -> char after value
   440                                  ; destroys ax,dx
   441                                  
   442                                  parse_ohx_value	PROC
   443 000001EC 53                      	push	bx				; save critical register
   444 000001ED 31DB                        xor bx,bx               ; bx == value
   445 000001EF AC                      	lodsb					; get colon
   446 000001F0 3C3A                    	cmp	al,':'				; make sure is colon
   447 000001F2 753A                        jne pov_bad_option      ; bad option format
   448 000001F4 8A04                    	mov	al,[si]			; peek ahead at number or sign
   449 000001F6 3C2D                        cmp al,'-'              ; see if minus, specified amount is free memory, not allocated
   450 000001F8 9C                      	pushf					; save flag status of minus compare
   451 000001F9 7501                        jne pov_3               ; no
   452 000001FB AC                          lodsb                   ; gobble '-' char
   453                                  
   454                                  pov_3:
   455 000001FC AC                          lodsb                   ; get number
   456 000001FD 3C30                        cmp al,'0'              ; see nondigit
   457 000001FF 721D                        jb  pov_done            ; yes, done
   458 00000201 3C39                        cmp al,'9'              ; see nondigit
   459 00000203 7719                        ja  pov_done            ; yes
   460                                  
   461 00000205 240F                        and al,0fh              ; change from ASCII to actual value
   462 00000207 F6C780                  	test	bh,80h			; see if value too large
   463 0000020A 7522                        jne pov_bad_option      ; yes
   464 0000020C 93                      	xchg	ax,bx			; previous value in ax, ones digit in bl
   465 0000020D BA0A00                  	mov	dx,10
   466 00000210 F7E2                    	mul	dx					; 10x previous in ax
   467 00000212 09D2                    	or	dx,dx				; see if any overflow to high word
   468 00000214 7518                    	jne	pov_bad_option		; yes
   469 00000216 30FF                    	xor	bh,bh
   470 00000218 01D8                    	add	ax,bx				; 10x previous+new ones digit in ax
   471 0000021A 89C3                    	mov	bx,ax				; update value storage
   472 0000021C EBDE                        jmp SHORT pov_3         ; get next digit
   473                                  
   474                                  pov_done:
   475 0000021E 4E                          dec si                  ; drop si back to -> nondigit char
   476 0000021F 81FBFF3F                    cmp bx,16383            ; check if absolute maximum exceeded
   477 00000223 7709                        ja  pov_bad_option      ; yes
   478 00000225 09DB                        or  bx,bx               ; value cannot be zero
   479 00000227 7405                        je  pov_bad_option
   480                                  
   481 00000229 9D                      	popf					; restore flag status of compare
   482 0000022A 89D8                    	mov	ax,bx				; get size in ax
   483 0000022C 5B                      	pop	bx					; restore critical register
   484 0000022D C3                      	ret
   485                                  
   486                                  ; bad size value given for /ohp, /oht
   487                                  pov_bad_option:
   488 0000022E EB84                    	jmp	ovl_bad_option
   489                                  
   490                                  parse_ohx_value	ENDP
   491                                  
   492                                  ;*****************************
   493                                  ;* SAVE_OVL_NAME             *
   494                                  ;*****************************
   495                                  
   496                                  ; save overlay file name with .OVL extension
   497                                  ; destroys ax,bx,si,di,es
   498                                  
   499                                  save_ovl_name   PROC
   500 00000230 8CD8                        mov ax,ds
   501 00000232 8EC0                        mov es,ax               ; es -> WarpLink data
   502 00000234 BF[0000]                    mov di,OFFSET ovl_filename wrt DGROUP   ; point to destination
   503 00000237 803E[0000]00                cmp byte [is_ovl_filename],0   ; see if overlay file name specified
   504 0000023C 7505                        jne sov_2               ; yes          
   505 0000023E BE[0000]                    mov si,OFFSET exe_name wrt DGROUP   ; point to filename to transfer to global string
   506 00000241 EB0E                        jmp SHORT ovl_loop      ; no
   507                                  
   508                                  ; explicitly set overlay file name
   509                                  sov_2:
   510 00000243 BE[0000]                    mov si,OFFSET exe_pathspec wrt DGROUP
   511                                  
   512                                  sov_pathloop:
   513 00000246 803C00                      cmp BYTE PTR [si],0     ; see if done putting in path spec to exe file
   514 00000249 7403                        je  sov_3               ; yes
   515 0000024B A4                          movsb                   ; transfer path spec before overlay file name
   516 0000024C EBF8                        jmp SHORT sov_pathloop  ; loop until complete
   517                                  
   518                                  sov_3:
   519 0000024E BE[0000]                    mov si,OFFSET ovl_nopath wrt DGROUP ; point to filename to transfer
   520                                  
   521                                  ovl_loop:
   522 00000251 A4                          movsb                   ; transfer a char
   523 00000252 803E[0000]2E                cmp byte [is_ovl_filename],'.' ; see if overlay file extension was supplied
   524 00000257 7410                        je  sov_4               ; yes, bypass period check
   525 00000259 807CFF2E                    cmp BYTE PTR [si-1],'.' ; non-path period signals end of transfer
   526 0000025D 750A                        jne sov_4
   527 0000025F 803C2E                      cmp BYTE PTR [si],'.'   ; two periods indicate pathspec
   528 00000262 7405                        je  sov_4
   529 00000264 803C5C                      cmp BYTE PTR [si],'\'   ; period+backslash indicates pathspec
   530 00000267 750E                        jne sov_addext          ; real period extension, add .OVL extension
   531                                  
   532                                  sov_4:
   533 00000269 807CFF00                    cmp BYTE PTR [si-1],0   ; zero byte signals end of transfer
   534 0000026D 75E2                        jne ovl_loop            ; not zero, keep transferring
   535 0000026F 803E[0000]2E                cmp byte [is_ovl_filename],'.' ; see if overlay file extension was supplied
   536 00000274 7501                        jne sov_addext          ; no, add default extension
   537 00000276 C3                          ret                     ; yes, done with overlay filename setup
   538                                  
   539                                  sov_addext:
   540 00000277 C645FF2E                    mov BYTE PTR [di-1],'.' ; add period
   541 0000027B C6054F                      mov BYTE PTR [di],'O'   ; add OVL extension
   542 0000027E C6450156                    mov BYTE PTR [di+1],'V'
   543 00000282 C645024C                    mov BYTE PTR [di+2],'L'
   544 00000286 C6450300                    mov BYTE PTR [di+3],0   ; null terminate string
   545                                  
   546 0000028A BF[0000]                    mov di,OFFSET ovl_nopath wrt DGROUP ; point to destination
   547 0000028D BE[0000]                    mov si,OFFSET ovl_filename wrt DGROUP   ; point to filename to transfer to global string
   548                                  
   549                                  ; find zero terminator in overlay name and then back up until
   550                                  ; hit beginning or '\' char
   551 00000290 31DB                        xor bx,bx
   552                                  
   553                                  sov_endloop:
   554 00000292 AC                          lodsb                   ; get char
   555 00000293 08C0                        or  al,al
   556 00000295 7403                        je  sov_past_null       ; zero, found terminator
   557 00000297 43                          inc bx                  ; bump count of chars in name
   558 00000298 EBF8                        jmp SHORT sov_endloop   ; loop for next char
   559                                  
   560                                  ; shot past null terminator, back si up to -> null terminator
   561                                  sov_past_null:
   562 0000029A 4E                          dec si
   563                                  
   564                                  sov_at_end:
   565 0000029B 4E                          dec si                  ; back up one char in name
   566 0000029C 4B                          dec bx                  ; drop count of chars in name
   567 0000029D 7407                        je  ovl_loop2           ; no more chars in name, at beginning
   568 0000029F 8A04                        mov al,[si]             ; get char in name
   569 000002A1 3C5C                        cmp al,'\'              ; see if backslash, directory indicator
   570 000002A3 75F6                        jne sov_at_end          ; no, keep looking
   571 000002A5 46                          inc si                  ; point si past backslash in name
   572                                  
   573                                  ovl_loop2:
   574 000002A6 A4                          movsb                   ; transfer a char
   575 000002A7 807CFF00                    cmp BYTE PTR [si-1],0   ; zero byte signals end of transfer
   576 000002AB 75F9                        jne ovl_loop2           ; not zero, keep tranferring
   577                                  
   578 000002AD C3                          ret
   579                                  save_ovl_name   ENDP
   580                                  
   581                                  END
