]>
wirehaze git hosting - MS-DOS.git/blob - v1.25/source/HEX2BIN.ASM
2 ; Converts Intel hex format files to straight binary
26 ;Get load offset (default is -100H)
27 MOV CL,4 ;Needed for shifts
29 MOV SI,FCB
+11H
;Scan second FCB for offset
31 CMP AL," " ;Check if offset present
33 MOV B
,[SIGN
],0 ;Assume positive sign for now
35 JZ GETOFF
;Get a positive offset
37 JNZ GETOFF1
;If not + or -, then not signed
38 MOV B
,[SIGN
],1 ;Flag as negative offset
42 CALL HEXCHK
;Check for valid hex character
43 JC HAVOFF
;No offset if not valid
44 XOR BX,BX ;Intialize offset sum to 0
46 SHL BX,CL ;Multiply current sum by 16
47 OR BL,AL ;Add in current hex digit
49 CALL HEXCHK
;And convert it to binary
50 JNC CONVOFF
;Loop until all hex digits read
51 TEST B
,[SIGN
],-1 ;Check if offset was to be negative
59 ADD DX,AX ;Compute load segment
64 MOV CX,[6] ;Get size of segment
71 STOW
;Fill entire segment with zeros
78 MOV [FCB
+14],BUFSIZ
;Set record size to buffer size
83 MOV DX,FCB
;All set up for sequential reads
84 MOV SI,BUFFER
+BUFSIZ
;Flag input buffer as empty
87 CMP AL,":" ;Search for : to start line
89 CALL GETBYT
;Get byte count
93 CALL GETBYT
;Get high byte of load address
95 CALL GETBYT
;Get low byte of load address
97 ADD BX,[OFFSET
] ;Add in offset
99 CALL GETBYT
;Throw away type byte
103 CALL GETBYT
;Get data byte
105 CMP DI,BP ;Check if this is the largest address so far
107 MOV BP,DI ;Save new largest
169 MOV [FCB
+9],4F00H
+"C" ;"CO"
178 MOV [FCB
+35],AX ;Set RR field
180 MOV [FCB
+14],AX ;Set record size
184 POP DS ;Get load segment
202 ERRMES: DB "Error in HEX file--conversion aborted$"
203 NOFILE: DB "File not found$"
204 ADDR: DB "Address out of range--conversion aborted$"
205 DIRFUL: DB "Disk directory full$"
213 STARTSEG EQU
(START
+15)/16