;-------------------------------------- ; HEX/ASCII file dump v1.1 ; (c) 24-01-1994 by Jan Laitenberger ;-------------------------------------- JMP @Start @X: DB ; cursor X pos. @mod: DB ; DIV-Rest @Byte: DB ; used for HEX output @Len: DB ; length of file DB @Name: DB 15h, 00 DB "-- F I L E N A M E --", 0 @Msg: DB "file not found!" @CRLF: DB 13,10,"$" @EText: DB 13,10,"HEX/ASCII file dump v1.1" DB 13,10,13,10,"$" @IText: DB "filename: $" INCLUDE WHex.INC INCLUDE Params.INC @gfn: MOV AH, 9 ; get filename MOV DX, ?@EText INT 21h ; display text CALL @CntPar ; count parameters (in Params.INC) CMP AX, 0 JE @readfn ; read filename from keyboard MOV AH, 15h ; max len of parameter MOV AL, 1 ; first parameter MOV DX, OFFSET @name+2; same pos in string as in DOS MOV DI, DX CALL @GetPar ; get parameter (in Params.INC) JMP SHORT @exit ; got it @readfn:MOV AH, 9 MOV DX, ?@IText INT 21h ; display text MOV AH, 0Ah MOV DX, OFFSET @Name MOV DI, DX ; DI points to the first ADD DI, 2 ; character of input string INT 21h ; read string MOV AH, 9 MOV DX, ?@CRLF INT 21h ; output new line XOR BX, BX ; BX := MOV BL, [?@Name+1] ; length of input string @exit: MOV BYTEPTR [BX+DI],0 ; mark string end with #0 RET @err: MOV AH, 9 ; critical error handling MOV DX, ?@Msg INT 21h ; display text INT 20h ; end program ; load file with name starting at OFFSET @Name+2 @load: MOV DX, ?@Name+2 MOV AX, 3D00h ; file ... INT 21h ; ... open JB @err MOV BX, AX MOV AH, 3Fh MOV CX, F000h ; max. 60 kB MOV DX, ?@file INT 21h ; ... read JB @err MOV [?@Len], AX MOV AH, 3Eh INT 21h ; ...close RET ; set cursor to X position of actual line @CurX: PUSH AX ; save regs PUSH BX PUSH CX XOR BX, BX ; screen page 0 MOV AH, 3 INT 10h ; get X,Y position MOV AH, 2 MOV DL, [?@X] INT 10h ; set old Y- and new X-pos POP CX ; restore regs POP BX POP AX RET @output:XOR BX, BX ; adr := 0 MOV SI, ?@file @3: PUSH DX ; calculate adr MOD 8 MOV AX, BX XOR DX, DX MOV CX, 8 DIV CX MOV [?@mod], DL ; and save in [?@mod] POP DX CMP BYTEPTR [?@mod],0 JNE @4 PUSH AX ; new line after MOV AH, 9 ; output of 8 bytes MOV DX, ?@CRLF INT 21h MOV [?@byte], BH ; output adr CALL @HEX MOV [?@byte], BL CALL @HEX MOV AH, 2 MOV DL, "³" INT 21h ; display char MOV [?@X], BYTE PTR 1Eh CALL @CurX ; start position for ASCII output MOV DL, "³" INT 21h ; display char POP AX @4: ; calculate pos for actual char MOV DL, [?@mod] ADD DL, 1Fh MOV [?@X], DL CALL @CurX ; set position LODSB ; get byte MOV [?@byte], AL MOV DL, AL CMP DL, " " JGE @5 MOV DL, "." @5: MOV AH, 2 ; display char INT 21h MOV DL, 3 ; calculate pos for HEX value MOV AL, [?@mod] MUL DL ADD AX, 6 MOV [?@X], AL CALL @CurX ; set position CALL @HEX ; output HEX value INC BX CMP BX, [?@Len] JE @6 ; EOF ? JMP @3 ; next byte @6: RET @Start: ; main() CALL @gfn CALL @load CALL @output MOV AH, 9 MOV DX, ?@CRLF INT 21h ; output new line INT 20h ; THE END @file: ; >>> space to load file >>>