home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / tools / unload / unload86.a86 < prev    next >
Text File  |  1988-08-09  |  17KB  |  529 lines

  1. ;************************************************************************
  2. ;*                                    *
  3. ;*    UNLOAD86.A86  This is a MS-DOS unload program.    See the help    *
  4. ;*    screen at the end of this file for details on its use.        *
  5. ;*    Written by:  Mark D. Pickerill for Pro-Log Corp. 9 Aug. 1988    *
  6. ;*    Assemble with the 2500 A.D. X8086 assembler.            *
  7. ;*                                    *
  8. ;************************************************************************
  9.                 ;
  10. CR:    EQU    0DH        ; Carriage return
  11. LF:    EQU    0AH        ; Line feed
  12. EOF:    EQU    1AH        ; End of file
  13.                 ;
  14.     ORG    0100H        ; Start of tpa
  15.                 ;
  16. UNLOAD:    JMP    SHORT START    ; Skip data area
  17.                 ;
  18. FILDAT:    DB    0FFH        ; Data to fill empty space in rom (if selected)
  19. BNPFTYP:DB    'PN'        ; Pn for bnpf, hl for bhlf, or 10 for b10f
  20. FTYPE:    DB    '.HEX',00H    ; File type
  21. FTYPE1:    DB    '.BNP',00H    ; File type for bnpf files
  22. OUTTYPE:DB    00H        ; 00 for hex, non-zero for bnpf
  23. USEEXT:    DB    00H        ; 00 for no extended address records
  24. DOFILL:    DB    00H        ; 00 not to fill to end of rom
  25. ENDSEG:    DW    0000H        ; Space to store end segment for rom fill
  26. ENDADDR:DW    0000H        ; Space to store end address for rom fill
  27. OOD:    DB    00H        ; Flag 0 for read from disk, ff to use fildat
  28. NOPARMS:JMP    HELP        ; Extend short jump
  29.                 ;
  30. START:    PUSH    CS        ; Set data segment
  31.     POP    DS        ; It's set
  32.     PUSH    DS        ; Get this segment
  33.     POP    ES        ; And set es as well
  34.     CALL    ILPRT        ; Print signon message
  35.     DB    CR,LF,'UNLOAD86 ver. 1.0',00H
  36.     MOV    SI,0080H    ; Point to parameter field in psp
  37.     MOV    CL,[SI]        ; Get parameter length
  38.     OR    CL,CL        ; Force flags
  39.     JZ    NOPARMS        ; Print help screen
  40.     MOV    CH,00H        ; Zero ch
  41. LOOP1:    INC    SI        ; Point to start of parameters
  42.     MOV    AL,[SI]        ; Get byte from parameter field
  43.     CMP    AL,' '        ; Space?
  44.     LOOPZ    LOOP1        ; Wait until you get a non-space char
  45.     JZ    NOPARMS        ; Just spaces, print help screen
  46.     CMP    AL,'/'        ; Switch char?
  47.     JZ    NOPARMS        ; No filename!, print help screen
  48.     LEA    DI,INFN        ; Point to input filename area
  49.     MOV    [DI],AL        ; Stuff this char
  50. LOOP2:    INC    SI        ; Increment source
  51.     INC    DI        ; And destination
  52.     MOV    AL,[SI]        ; Get byte
  53.     CMP    AL,' '        ; End?
  54.     JZ    CONT        ; Yes
  55.     CMP    AL,'/'        ; Or switch char?
  56.     JZ    SWITCH        ; Yes
  57.     MOV    [DI],AL        ; Stuff char
  58.     LOOP    LOOP2        ; Nope
  59.     JMP    SHORT CONT    ; No more
  60. SWITCH:    INC    SI        ; Point to next
  61.     MOV    AL,[SI]        ; Get switch options
  62.     AND    AL,5FH        ; Make upper case as ibm types
  63.                 ; Usualy use lower case!
  64.     CMP    AL,'B'        ; Bnpf option?
  65.     JZ    SETBNPF        ; Yes
  66.     CMP    AL,'E'        ; Use extended address records?
  67.     JZ    SETEXT        ; Yes
  68.     CMP    AL,'P'        ; Set eprom type?
  69.     JZ    SETROM        ; Yes
  70.     LOOP    SWITCH        ; Look for more options
  71.     JMP    CONT        ; No more
  72.                 ;
  73. SETEXT:    MOV    AL,0FFH        ; Indicate use of extended addressing
  74.     MOV    [USEEXT],AL    ; Flag it as such
  75.     LOOP    SWITCH        ; Look for more options
  76.     JMP    CONT        ; No more
  77.                 ;
  78. SETBNPF:MOV    AL,0FFH        ; Indicate bnpf option
  79.     MOV    [OUTTYPE],AL    ; Set it
  80.                 ;
  81. LOOKMOR:LOOP    SWITCH        ; If more, look for additional options
  82.     JMP    CONT        ; No more
  83.                 ;
  84. SETROM:    INC    SI        ; Look at next char
  85.     DEC    CX        ; And decrement loop counter
  86.     MOV    AL,[SI]        ; Get char
  87.     CMP    AL,'0'        ; At least a zero?
  88.     JC    LOOKMOR        ; No,ignore
  89.     CMP    AL,'A'        ; At least an a?
  90.     JC    NUM        ; Numeric
  91.     AND    AL,5FH        ; Force upper case
  92.     CMP    AL,'G'        ; More garbage?
  93.     JNC    LOOKMOR        ; Yes, ignore
  94.     SUB    AL,37H        ; Remove alpha bias
  95.     JMP    SHORT FOUNDIT    ; And continue
  96. NUM:    CMP    AL,3AH        ; Above numeric?
  97.     JNC    LOOKMOR        ; Yes, ignore
  98.     SUB    AL,30H        ; Remove numeric bias
  99. FOUNDIT:PUSH    AX        ; Save our number
  100.     CMP    AL,0CH        ; Big rom?
  101.     JC    SMALL        ; No
  102.     MOV    AL,0FFH        ; Larger than 64k, force extended addressing
  103.     MOV    [USEEXT],AL    ; Do it
  104. SMALL:    POP    AX        ; Recover our number
  105.     PUSH    SI        ; Save pointer
  106.     LEA    SI,ATABLE    ; Point to address table
  107.     ADD    AL,AL        ; Multiply by two
  108.     ADD    AL,AL        ; And by four
  109.     XOR    AH,AH        ; Clear ah
  110.     ADD    SI,AX        ; Add in offset
  111.     MOV    AX,[SI]        ; Get segment address
  112.     MOV    [ENDSEG],AX    ; Stuff it
  113.     ADD    SI,02H        ; Point to offset address
  114.     MOV    AX,[SI]        ; Get offset address
  115.     MOV    [ENDADDR],AX    ; Stuff it
  116.     MOV    [DOFILL],BYTE PTR 0FFH ; Flag fillrom operation
  117.     POP    SI        ; Restore si
  118.     JMP    LOOKMOR        ; Go look for more options
  119.                 ;
  120. CONT:    INC    DI        ; Point past new filename
  121.     MOV    [DI],BYTE PTR 00H ; Terminate string
  122.     LEA    SI,INFN        ; Copy input to output fn
  123.     LEA    DI,OUTFN    ; Pointing to output filename
  124.     MOV    CX,60D        ; 64-4 for 'hex0' is 60
  125. LOOP3:    MOV    AL,[SI]        ; Get byte
  126.     MOV    [DI],AL        ; Go ahead & move it
  127.     INC    SI        ; Increment source
  128.     INC    DI        ; And destination
  129.     CMP    AL,'.'        ; Looking for that file extension
  130.     JZ    DONE        ; Found the dot
  131.     CMP    AL,'0'        ; End?
  132.     LOOPNZ    LOOP3        ; Continue
  133. DONE:    DEC    DI        ; Backup over dot or zero
  134.     MOV    CX,0005H    ; Five bytes to move
  135.     MOV    AL,[OUTTYPE]    ; Hex or bnpf?
  136.     OR    AL,AL        ; Force flags
  137.     JZ    OHEX        ; Hex
  138.     LEA    SI,FTYPE1    ; Point to file type for bnpf
  139.     JMP    SHORT ALL    ; And continue
  140. OHEX:    LEA    SI,FTYPE    ; Point to file type for hex
  141. ALL:    REP    MOVSB        ; Move the rest
  142.                 ;
  143.     MOV    AL,00H        ; Read access code
  144.     MOV    AH,3DH        ; Open file function
  145.     LEA    DX,INFN        ; Point to input file name
  146.     INT    21H        ; Open the file
  147.     MOV    [INHDL],AX    ; Save handle
  148.     JNC    OK        ; Ok
  149.     CALL    ILPRT        ; Print this...
  150.     DB    CR,LF,'Failure to Open Input file',00H
  151.     JMP    FINIS        ; Go to error handler
  152.                 ;
  153. OK:    MOV    CL,00H        ; Normal addributes
  154.     MOV    AH,3CH        ; Create file function
  155.     LEA    DX,OUTFN    ; Point to file name
  156.     INT    21H        ; Open the file
  157.     JNC    OK1        ; Ok
  158.     CALL    ILPRT        ; Print this...
  159.     DB    CR,LF,'Failure to Open output file',00H
  160.     JMP    FINIS        ; Go to error handler
  161. OK1:    MOV    [OUTHDL],AX    ; Save handle
  162.     MOV    AL,[OUTTYPE]    ; Get output format
  163.     OR    AL,AL        ; Force flags
  164.     JZ    READ        ; Don't do start char for bnpf
  165.     LEA    DX,CNTRLB    ; Point to start byte
  166.     MOV    BX,[OUTHDL]    ; Get output handle
  167.     MOV    AH,40H        ; Write function
  168.     MOV    CX,0003H    ; One byte + crlf
  169.     INT    21H        ; Do it
  170.     JNC    READ        ; Ok
  171.     JMP    BADWR        ; Error
  172.                 ;
  173. READ:    LEA    DI,INBUF    ; Point to input buffer
  174.     MOV    CX,16D        ; Fill entire buffer
  175.     MOV    AL,[FILDAT]    ; Get fill data
  176.     MOV    AH,AL        ; Dup into ah
  177.     REP    STOSW        ; Do it
  178.                 ;
  179.     MOV    AL,[OOD]    ; Already out of data?
  180.     OR    AL,AL        ; Force flags
  181.     JNZ    FILLIT        ; Yup
  182.     LEA    DX,INBUF    ; Point to buffer
  183.     MOV    CX,32D        ; Process 32 bytes at a time
  184.     MOV    BX,[INHDL]    ; Get handle
  185.     MOV    AH,3FH        ; Read function
  186.     INT    21H        ; Do it
  187.     JNC    ROK        ; Ok
  188.     CALL    ILPRT        ; Print this...
  189.     DB    CR,LF,'Error Reading Input file',00H
  190.     JMP    FINIS        ; Go to error handler
  191.                 ;
  192. CNTRLB:    DB    02H,CR,LF    ; Bnpf start
  193.                 ;
  194. ROK:    CMP    AX,0000H    ; Completely finished?
  195.     JNZ    NOPE        ; Nope
  196.     MOV    AL,[OUTTYPE]    ; Check for bnpf
  197.     OR    AL,AL        ; Force flags
  198.     JNZ    EXIT        ; Bnpf ignores all this...
  199.     MOV    AL,0FFH        ; Indicate we're finished reading from disk
  200.     MOV    [OOD],AL    ; Flag it
  201.     MOV    AL,[DOFILL]    ; Check for fillrom function
  202.     OR    AL,AL        ; Force flags
  203.     JZ    EXIT        ; Not selected
  204. FILLIT:    MOV    AX,[EXTEND]    ; Get current segment
  205.     SUB    AX,1000H    ; Compensate to what is in use
  206.     CMP    [ENDSEG],AX    ; Check against selected end segment
  207.     JC    TOOBIG        ; Warn operator that his data won't fit
  208.     JNZ    NOPE        ; Segment hasn't been reached yet, continue
  209.     MOV    AX,[ADDRESS]    ; Get current address
  210.     DEC    AX        ; To last location, not next avail loc
  211.     CMP    [ENDADDR],AX    ; Check against selected end address
  212.     JC    TOOBIG        ; Warn oerator that his data won't fit
  213.     JNZ    NOPE        ; Address hasn't been reached yet
  214.                 ;
  215. EXIT:    JMP    FINISHUP    ; Yes, finish up & terminate
  216. TOOBIG:    JMP    WARN        ; Tell operator
  217. NOPE:    MOV    AL,[OUTTYPE]    ; Get output format
  218.     OR    AL,AL        ; Force flags
  219.     JZ    HEX        ; Do hex
  220.                 ; Drop through to bnpf
  221.     LEA    SI,INBUF    ; Point to input buffer
  222.     MOV    CX,32D        ; 32 bytes to process
  223. BNPF:    LEA    DI,OUTBUF    ; Output buffer
  224.     MOV    [DI],BYTE PTR 'B' ; The b for begin
  225.     INC    DI        ; Next location
  226. BIGLP:    MOV    AL,[SI]        ; Get byte
  227.     PUSH    CX        ; Save byte loop
  228.     MOV    CX,0008H    ; 8 bits in a byte
  229. BNPFLP:    RCL    AL,1        ; Rotate through carry
  230.     JC    P        ; High
  231.     MOV    AH,[BNPFTYP]+1    ; Get the byte for low
  232.     MOV    [DI],AH        ; Put in buffer
  233.     INC    DI        ; Next location
  234.     LOOP    BNPFLP        ; Do entire byte
  235.     JMP    ONEBYTE        ; Complete & write
  236. P:    MOV    AH,[BNPFTYP]    ; Get the byte for high
  237.     MOV    [DI],AH        ; Put in buffer
  238.     INC    DI        ; Next location
  239.     LOOP    BNPFLP        ; Do entire byte
  240. ONEBYTE:MOV    [DI],BYTE PTR 'F' ; The f for finish
  241.     POP    CX        ; Recover byte loop
  242.     INC    SI        ; Next byte
  243.     INC    DI        ; Next dest
  244.     MOV    [DI],BYTE PTR 0DH ; Send a cr
  245.     INC    DI        ; Next
  246.     MOV    [DI],BYTE PTR 0AH ; Send a lf
  247.     INC    DI        ; Next
  248.     PUSH    CX        ; Save loop counter
  249.     PUSH    SI        ; Save input counter
  250.     MOV    CX,12D        ; Twelve bytes every time
  251.     CALL    WRITE        ; Write byte
  252.     POP    SI        ; Recover input counter
  253.     POP    CX        ; Recover loop counter
  254.     LOOP    BNPF        ; Do next byte
  255.     JMP    READ        ; Read next 32 bytes
  256.                 ;
  257. HEX:    XOR    BX,BX        ; Output counter
  258.     MOV    CX,32D        ; Input counter
  259.     XOR    DX,DX        ; Dl is checksum reg
  260.     MOV    AX,[ADDRESS]    ; Get current load address
  261.     OR    AX,AX        ; Force flags
  262.     JNZ    NOEXT        ; No extended address record needed
  263.     CALL    EAR        ; Do extended addressing if selected
  264. NOEXT:    LEA    SI,INBUF    ; Point to input buffer
  265.     LEA    DI,OUTBUF    ; Point to output buffer
  266.     MOV    [DI],BYTE PTR ':' ; Stuff that colon
  267.     INC    DI        ; And point to next
  268.     INC    BX        ; And increment counter
  269.     MOV    AL,20H        ; All are 32 byte records
  270.     CALL    BITE        ; Stuff it
  271.     MOV    AX,[ADDRESS]    ; Get load address
  272.     XCHG    AL,AH        ; Do high byte first
  273.     CALL    BITE        ; Send it
  274.     XCHG    AH,AL        ; Now do low byte
  275.     CALL    BITE        ; Send it
  276.     MOV    AX,[ADDRESS]    ; Get load address
  277.     ADD    AX,20H        ; Increment to next
  278.     MOV    [ADDRESS],AX    ; Put back
  279.     MOV    AL,00H        ; Record type 00
  280.     CALL    BITE        ; Send it
  281. LOOP4:    MOV    AL,[SI]        ; Get input
  282.     CALL    BITE        ; Process
  283.     INC    SI        ; Point to next
  284.     LOOP    LOOP4        ; Until done
  285.     MOV    AL,DL        ; Get checksum
  286.     CALL    BITE        ; Process, [clobbering dl]
  287.     MOV    [DI], WORD PTR 0A0DH ; Append crlf
  288.     ADD    BX,02H        ; Bump output counter appropiately
  289.     MOV    CX,BX        ; Get count into cx
  290.     CALL    WRITE        ; Write output
  291.     JMP    READ        ; Read more
  292.                 ;
  293. WRITE:    LEA    DX,OUTBUF    ; Point to beginning of output buffer
  294.     MOV    BX,[OUTHDL]    ; Get output handle
  295.     MOV    AH,40H        ; Write function
  296.     INT    21H        ; Do it
  297.     JNC    WOK        ; Ok
  298. BADWR:    CALL    ILPRT        ; Print this...
  299.     DB    CR,LF,'Error Writing Output file',00H
  300.     JMP    FINIS        ; Go to error handler
  301. WOK:    RET            ; Near
  302.                 ;
  303. EAR:    PUSH    AX        ; Save everything
  304.     MOV    AL,[USEEXT]    ; Get extended address flag
  305.     OR    AL,AL        ; Force flags
  306.     JNZ    GOAHEAD        ; Yes, do extended addressing
  307.     MOV    AX,[EXTEND]    ; Get extended address anyway
  308.     ADD    AX,1000H    ; Increment to next 64k block
  309.     MOV    [EXTEND],AX    ; Put back for consistancy
  310.     POP    AX        ; Restore ax
  311.     RET            ; Go home
  312. GOAHEAD:PUSH    DI        ;
  313.     PUSH    CX        ;
  314.     PUSH    DX        ;
  315.     PUSH    SI        ;
  316.     PUSH    BX        ;
  317.     LEA    DI,OUTBUF    ; Point to output buffer
  318.     MOV    [DI],BYTE PTR ':' ; Stuff that colon
  319.     INC    DI        ; And point to next
  320.     INC    BX        ; And increment counter
  321.     MOV    AL,02H        ; Two bytes of data in extended record
  322.     CALL    BITE        ; Stuff it
  323.     MOV    AX,0000H    ; Extended address records have load addr of 0
  324.     XCHG    AL,AH        ; Do high byte first
  325.     CALL    BITE        ; Send it
  326.     XCHG    AH,AL        ; Now do low byte
  327.     CALL    BITE        ; Send it
  328.     MOV    AL,02H        ; Record type 02
  329.     CALL    BITE        ; Send it
  330.     MOV    AX,[EXTEND]    ; Get current extended address
  331.     XCHG    AL,AH        ; Do high byte first
  332.     CALL    BITE        ; Send it
  333.     XCHG    AH,AL        ; Now do low byte
  334.     CALL    BITE        ; Send it
  335.     MOV    AX,[EXTEND]    ; Get extended address again
  336.     ADD    AX,1000H    ; Increment to next 64k block
  337.     MOV    [EXTEND],AX    ; Put back
  338.     MOV    AL,DL        ; Get checksum
  339.     CALL    BITE        ; Process, [clobbering dl]
  340.     MOV    [DI], WORD PTR 0A0DH ; Append crlf
  341.     ADD    BX,02H        ; Bump output counter appropiately
  342.     MOV    CX,BX        ; Get count into cx
  343.     CALL    WRITE        ; Write output
  344.     POP    BX        ; Recover everything
  345.     POP    SI        ;
  346.     POP    DX        ;
  347.     POP    CX        ;
  348.     POP    DI        ;
  349.     POP    AX        ;
  350.     RET            ; Go home
  351.                 ;
  352. FINISHUP:            ;
  353.     CALL    ILPRT        ; Print this...
  354.     DB    CR,LF,'Function Complete.',00H
  355.     MOV    AL,[OUTTYPE]    ; Get output format
  356.     OR    AL,AL        ; Force flags
  357.     JZ    HEXEND        ; Do hex
  358.                 ; Drop through to bnpf
  359.                 ;
  360. BNPFEND:LEA    DX,CNTRLC    ; Point to eof marker
  361.     MOV    BX,[OUTHDL]    ; Get output handle
  362.     MOV    AH,40H        ; Write function
  363.     MOV    CX,0003H    ; One byte
  364.     INT    21H        ; Do it
  365.     JNC    WOKK        ; Ok
  366.     JMP    BADWR        ; Error
  367.                 ;
  368. WARN:    CALL    ILPRT        ; Print this...
  369.     DB    CR,LF,LF,'WARNING:  Input data file too large for output size'
  370.     DB    ' selected.',07H,LF,00H    ;
  371.     JMP    FINISHUP    ; Terminate
  372.                 ;
  373. CNTRLC:    DB    03H,CR,LF    ; Termination for bnpf
  374.                 ;
  375. HEXEND:    LEA    DX,EOFREC    ; Point to eof record
  376.     MOV    BX,[OUTHDL]    ; Get output handle
  377.     MOV    AH,40H        ; Write function
  378.     MOV    CX,0014H    ; Fourteen bytes
  379.     INT    21H        ; Do it
  380.     JNC    WOKK        ; Ok
  381.     JMP    BADWR        ; Error
  382.                 ;
  383. WOKK:    MOV    AH,3EH        ; Close the file now
  384.     MOV    BX,[OUTHDL]    ; Close output
  385.     INT    21H        ; Close the damn thing
  386.     JNC    CLOK        ; Closed ok
  387.     CALL    ILPRT        ; Print this...
  388.     DB    CR,LF,'Error Closing Output file!',00H
  389.                 ;
  390. CLOK:    MOV    AH,3EH        ; Close the file now
  391.     MOV    BX,[INHDL]    ; Close input
  392.     INT    21H        ; Close the damn thing
  393.     JNC    FINIS        ; Closed ok
  394.     CALL    ILPRT        ; Print this...
  395.     DB    CR,LF,'Error Closing Input file!',00H
  396.                 ;
  397. FINIS:    MOV    AX,4C00H    ; Terminate
  398.     INT    21H        ; Bye-bye
  399.                 ;
  400. EOFREC:    DB    ':00000001FF',CR,LF,EOF    ; End of file record
  401.                 ;
  402. ;************************************************************************
  403. ;*                                    *
  404. ;*    ILPRT:    This is an 8088 in-line print routine.    It will print    *
  405. ;*    the string following the CALL NEAR instruction until a 00H is    *
  406. ;*    encountered.  Accepts:    Data string to print in memory following*
  407. ;*    the CALL NEAR used to invoke this routine.  Returns:  Nothing.    *
  408. ;*    Calls:    CONOUT.  Clobbers:  ES,SI                *
  409. ;*                                    *
  410. ;************************************************************************
  411.                 ;
  412. ILPRT:    PUSH    CS        ; Get code segment
  413.     POP    ES        ; Into es
  414.     POP    SI        ; Get offset
  415.     PUSH    AX        ; Save ax
  416.     PUSH    DX        ; And dx
  417. ILLP:    MOV    AL,ES:[SI]    ; Get char
  418.     OR    AL,AL        ; Force flags
  419.     JZ    ILEXIT        ; Exit if last
  420.     CALL    CONOUT        ; Send char
  421.     INC    SI        ; Point to next
  422.     JMP    SHORT ILLP    ; Loop til done
  423. ILEXIT:    INC    SI        ; Point to next instruction
  424.     POP    DX        ; Restore dx
  425.     POP    AX        ; And ax
  426.     PUSH    SI        ; And return offset
  427.     RET            ; Near
  428.                 ;
  429. CONOUT:    MOV    AH,02H        ; Conout call
  430.     MOV    DL,AL        ; Get char
  431.     INT    21H        ; Do it
  432.     RET            ; Near
  433.                 ;
  434. BITE:    SUB    DL,AL        ; Generate checksum
  435.     PUSH    AX        ; Save
  436.     AND    AL,0F0H        ; Mask out lower nybble
  437.     ROR    AL,1        ; Get msn into lower nybble
  438.     ROR    AL,1        ;
  439.     ROR    AL,1        ;
  440.     ROR    AL,1        ; Now it's there
  441.     CALL    NYB        ; Process nybble
  442.     MOV    [DI],AL        ; Save in disk buffer
  443.     INC    BX        ; Increment count
  444.     INC    DI        ; Next location in buffer
  445.     POP    AX        ; Recover byte
  446.     AND    AL,0FH        ; Mask lsn
  447.     CALL    NYB        ; Process nybble
  448.     MOV    [DI],AL        ; Save in disk buffer
  449.     INC    BX        ; Increment count
  450.     INC    DI        ; Next location in buffer
  451.     RET            ; Near
  452.                 ;
  453.                 ; Converts lower nybble in al to ascii hex
  454. NYB:    CMP    AL,0AH        ; Letter?
  455.     JNC    NYB1        ; Yes
  456.     ADD    AL,30H        ; Add in numeric bias
  457.     RET            ; Go home (near)
  458. NYB1:    ADD    AL,37H        ; Add in letter bias
  459.     RET            ; Go home (near)
  460.                 ;
  461. INHDL:    BLKB    2        ; Storage for input file handle
  462. OUTHDL:    BLKB    2        ; Storage for output file handle
  463. ADDRESS:DW    0000H        ; Current address
  464. EXTEND:    DW    0000H        ; Current extended address
  465. INFN:    BLKB    64D        ; Plenty of room for a filename & path
  466. OUTFN:    BLKB    64D        ; Output filename
  467. INBUF:    BLKB    32D        ; Thirty two byte input buffer
  468. OUTBUF:    EQU    $        ; Output buffer
  469.                 ;
  470. HELP:                ; Called only if nothing is going to happen
  471.                 ; Otherwise, this routine is overwritten
  472.     CALL    ILPRT        ; Print help screen
  473.     DB    CR,LF,LF,'Usage:  UNLOAD86 FILENAME.TYP[/OPTIONS]'
  474.     DB    CR,LF,LF,'Where Options are:'
  475.     DB    CR,LF,'     B for BNPF instead of INTeL hex.'
  476.     DB    '(Overrides all other options!)'
  477.     DB    CR,LF,'     E to use extended addressing in INTeL hex.'
  478.     DB    CR,LF,'     P to fill output file to end of EPROM.'
  479.     DB    CR,LF,'       Uses the following subcommands:'
  480.     DB    CR,LF,'         0  32 Bytes         1  64 Bytes'
  481.     DB    CR,LF,'         2  128 Bytes        3  256 Bytes'
  482.     DB    CR,LF,'         4  512 Bytes        5  1K Bytes'
  483.     DB    CR,LF,'         6  2K Bytes         7  4K Bytes'
  484.     DB    CR,LF,'         8  8K Bytes         9  16K Bytes'
  485.     DB    CR,LF,'         A  32K Bytes        B  64K Bytes'
  486.     DB    CR,LF,'         C  *128K Bytes      D  *256K Bytes'
  487.     DB    CR,LF,'         E  *512K Bytes      F  *1Meg Bytes'
  488.     DB    CR,LF,LF,'         * Forces extended addressing'
  489.     DB    CR,LF,LF,'INTeL hex output files are .HEX'
  490.     DB    CR,LF,'BNPF output files are .BNP'
  491.     DB    CR,LF,00H    ;
  492.     JMP    FINIS        ; Terminate
  493.                 ;
  494. ATABLE:                ; Table of rom sizes for fillrom option
  495.     DW    0000H        ; Segment for 32 byter
  496.     DW    001FH        ; Address for 32 byter
  497.     DW    0000H        ; Segment for 64 byter
  498.     DW    003FH        ; Address for 64 byter
  499.     DW    0000H        ; Segment for 128 byter
  500.     DW    007FH        ; Address for 128 byter
  501.     DW    0000H        ; Segment for 256 byter
  502.     DW    00FFH        ; Address for 256 byter
  503.     DW    0000H        ; Segment for 512 byter
  504.     DW    01FFH        ; Address for 512 byter
  505.     DW    0000H        ; Segment for 1k byter
  506.     DW    03FFH        ; Address for 1k byter
  507.     DW    0000H        ; Segment for 2k byter
  508.     DW    07FFH        ; Address for 2k byter
  509.     DW    0000H        ; Segment for 4k byter
  510.     DW    0FFFH        ; Address for 4k byter
  511.     DW    0000H        ; Segment for 8k byter
  512.     DW    1FFFH        ; Address for 8k byter
  513.     DW    0000H        ; Segment for 16k byter
  514.     DW    3FFFH        ; Address for 16k byter
  515.     DW    0000H        ; Segment for 32k byter
  516.     DW    7FFFH        ; Address for 32k byter
  517.     DW    0000H        ; Segment for 64k byter
  518.     DW    0FFFFH        ; Address for 64k byter
  519.     DW    1000H        ; Segment for 128k byter
  520.     DW    0FFFFH        ; Address for 128k byter
  521.     DW    3000H        ; Segment for 256k byter
  522.     DW    0FFFFH        ; Address for 256k byter
  523.     DW    7000H        ; Segment for 512k byter
  524.     DW    0FFFFH        ; Address for 512k byter
  525.     DW    0F000H        ; Segment for 1m byter
  526.     DW    0FFFFH        ; Address for 1m byter
  527.                 ;
  528.     END            ;
  529.