home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Unsorted BBS Collection
/
thegreatunsorted.tar
/
thegreatunsorted
/
programming
/
asm_programming
/
DUMP.LST
< prev
next >
Wrap
File List
|
1990-10-04
|
10KB
|
282 lines
Microsoft (R) Macro Assembler Version 5.10 10/4/90 04:18:49
Page 1-1
; DUMP.ASM: Dump Utility
; ------Macros--------------------------
doscall macro x
mov ah,x
int 21h
endm
outchar macro x
mov dl,x
doscall 2
endm
0000 code segment
0100 org 100h
assume cs:code,ds:code
0100 EB 23 90 start: jmp begin
; ------Variables----------------------
0103 0000 fcount dw 0
0105 00 eofflag db 0
0106 46 69 6C 65 20 6E fnfmsg db 'File not Found$'
6F 74 20 46 6F 75
6E 64 24
0115 30 31 32 33 34 35 hexchar db '0123456789ABCDEF'
36 37 38 39 41 42
43 44 45 46
; ----- main loop -------------
0125 BA 005C begin: mov dx,5ch ; fcb prepared
by DOS
doscall 0fh ; open file
0128 B4 0F 1 mov ah,0fh
012A CD 21 1 int 21h
012C 3C FF cmp al,0ffh ; if ffh then
012E 75 0A jne d1 ; file not foun
d
0130 BA 0106 R mov dx,offset fnfmsg
doscall 9 ; display messa
ge
0133 B4 09 1 mov ah,9
0135 CD 21 1 int 21h
0137 EB 1E 90 jmp exit ; end
; if file is present begin by reading
; data in DTA at offset 80h
013A BA 005C d1: mov dx,5ch
doscall 14h ; read data blo
ck (128 bytes)
013D B4 14 1 mov ah,14h
Microsoft (R) Macro Assembler Version 5.10 10/4/90 04:18:49
Page 1-2
013F CD 21 1 int 21h
0141 3C 01 cmp al,1 ; if end of fil
e
0143 74 12 je exit ; end
0145 3C 03 cmp al,3 ; if partial bl
ock
0147 75 04 jne d2 ; display file
and end
0149 FE 06 0105 R inc eofflag
014D E8 0159 R d2: call outrec ; display 128 b
ytes of DTA
0150 80 3E 0105 R 01 cmp eofflag,1 ; EOF?
0155 75 E3 jne d1 ; if not, jump
to top
0157 CD 20 exit: int 20h
0159 outrec proc near
0159 BD 0080 mov bp,80h ; bp points to
beginning of DTA
015C E8 018C R or1: call outcnt
015F E8 01A7 R call outhex
0162 E8 01CD R call outasci
outchar 13
0165 B2 0D 1 mov dl,13
0167 B4 02 2 mov ah,2
0169 CD 21 2 int 21h
outchar 10
016B B2 0A 1 mov dl,10
016D B4 02 2 mov ah,2
016F CD 21 2 int 21h
0171 83 C5 10 add bp,16 ; position base
pointer
0174 83 06 0103 R 10 add fcount,16 ; and file coun
ter
0179 81 FD 0100 cmp bp,100h ; finished afte
r 128 bytes
017D 75 DD jne or1
outchar 13
017F B2 0D 1 mov dl,13
0181 B4 02 2 mov ah,2
0183 CD 21 2 int 21h
outchar 10
0185 B2 0A 1 mov dl,10
0187 B4 02 2 mov ah,2
0189 CD 21 2 int 21h
018B C3 ret
018C outrec endp
018C outcnt proc near ; outcnt displa
ys the memory address
018C A1 0103 R mov ax,fcount ; in hex as MSB
LSB:
018F 8A C4 mov al,ah ; switch for di
splay
Microsoft (R) Macro Assembler Version 5.10 10/4/90 04:18:49
Page 1-3
0191 E8 01E7 R call outbyte
0194 A1 0103 R mov ax,fcount
0197 E8 01E7 R call outbyte
outchar ':' ; separate with
:
019A B2 3A 1 mov dl,':'
019C B4 02 2 mov ah,2
019E CD 21 2 int 21h
outchar ' '
01A0 B2 20 1 mov dl,' '
01A2 B4 02 2 mov ah,2
01A4 CD 21 2 int 21h
01A6 C3 ret
01A7 outcnt endp
01A7 outhex proc near ; outhex displa
ys a hex dump
01A7 BE 0000 mov si,0
01AA 8A 02 oh1: mov al,[bp+si] ; read byte
01AC E8 01E7 R call outbyte ; and display
outchar ' '
01AF B2 20 1 mov dl,' '
01B1 B4 02 2 mov ah,2
01B3 CD 21 2 int 21h
01B5 46 inc si
01B6 83 FE 08 cmp si,8 ; add extra spa
ce between
01B9 75 06 jne oh2 ; bytes 7 and 8
for clarity
outchar ' '
01BB B2 20 1 mov dl,' '
01BD B4 02 2 mov ah,2
01BF CD 21 2 int 21h
01C1 83 FE 10 oh2: cmp si,16 ; if si = 16 th
en return
01C4 75 E4 jne oh1
outchar ' ' ; separate with
a space
01C6 B2 20 1 mov dl,' '
01C8 B4 02 2 mov ah,2
01CA CD 21 2 int 21h
01CC C3 ret
01CD outhex endp
01CD outasci proc near ; outasci displ
ays the ASCII characters
01CD BE 0000 mov si,0 ; prepare oa1 l
oop
01D0 8A 12 oa1: mov dl,[bp+si] ; read characte
r
01D2 80 E2 7F and dl,7fh ; set MSB = 0
01D5 80 FA 20 cmp dl,20h ; if char can b
e printed then
01D8 73 02 jae oa2 ; jump to oa2
Microsoft (R) Macro Assembler Version 5.10 10/4/90 04:18:49
Page 1-4
01DA B2 2E mov dl,'.' ; else print .
01DC oa2: doscall 2 ; print charact
er
01DC B4 02 1 mov ah,2
01DE CD 21 1 int 21h
01E0 46 inc si
01E1 83 FE 10 cmp si,16 ; when performe
d 16 times, end
01E4 75 EA jne oa1
01E6 C3 ret
01E7 outasci endp
01E7 outbyte proc near ; output char.
to screen
01E7 BB 0115 R mov bx,offset hexchar
01EA 50 push ax
01EB 24 F0 and al,0f0h
01ED B1 04 mov cl,4
01EF D2 C0 rol al,cl
01F1 D7 xlat ; translate int
o hex
01F2 8A D0 mov dl,al
doscall 2 ; display
01F4 B4 02 1 mov ah,2
01F6 CD 21 1 int 21h
01F8 58 pop ax
01F9 24 0F and al,0fh
01FB D7 xlat ; translate int
o hex
01FC 8A D0 mov dl,al
doscall 2 ; display
01FE B4 02 1 mov ah,2
0200 CD 21 1 int 21h
0202 C3 ret
0203 outbyte endp
0203 code ends
end start
Microsoft (R) Macro Assembler Version 5.10 10/4/90 04:18:49
Symbols-1
Macros:
N a m e Lines
DOSCALL . . . . . . . . . . . . 2
OUTCHAR . . . . . . . . . . . . 2
Segments and Groups:
N a m e Length Align Combine Class
CODE . . . . . . . . . . . . . . 0203 PARA NONE
Symbols:
N a m e Type Value Attr
BEGIN . . . . . . . . . . . . . L NEAR 0125 CODE
D1 . . . . . . . . . . . . . . . L NEAR 013A CODE
D2 . . . . . . . . . . . . . . . L NEAR 014D CODE
EOFFLAG . . . . . . . . . . . . L BYTE 0105 CODE
EXIT . . . . . . . . . . . . . . L NEAR 0157 CODE
FCOUNT . . . . . . . . . . . . . L WORD 0103 CODE
FNFMSG . . . . . . . . . . . . . L BYTE 0106 CODE
HEXCHAR . . . . . . . . . . . . L BYTE 0115 CODE
OA1 . . . . . . . . . . . . . . L NEAR 01D0 CODE
OA2 . . . . . . . . . . . . . . L NEAR 01DC CODE
OH1 . . . . . . . . . . . . . . L NEAR 01AA CODE
OH2 . . . . . . . . . . . . . . L NEAR 01C1 CODE
OR1 . . . . . . . . . . . . . . L NEAR 015C CODE
OUTASCI . . . . . . . . . . . . N PROC 01CD CODE Length = 001A
OUTBYTE . . . . . . . . . . . . N PROC 01E7 CODE Length = 001C
OUTCNT . . . . . . . . . . . . . N PROC 018C CODE Length = 001B
OUTHEX . . . . . . . . . . . . . N PROC 01A7 CODE Length = 0026
OUTREC . . . . . . . . . . . . . N PROC 0159 CODE Length = 0033
START . . . . . . . . . . . . . L NEAR 0100 CODE
@CPU . . . . . . . . . . . . . . TEXT 0101h
@FILENAME . . . . . . . . . . . TEXT dump
@VERSION . . . . . . . . . . . . TEXT 510
Microsoft (R) Macro Assembler Version 5.10 10/4/90 04:18:49
Symbols-2
126 Source Lines
174 Total Lines
27 Symbols
47812 + 283623 Bytes symbol space free
0 Warning Errors
0 Severe Errors