📄 mon88.asm
字号:
MOV AL,'>'
JMP DISPCH
RXBYTE: XCHG BH,AH ; save AH register
CALL RXNIB
MOV AH,AL
SHL AH,1 ; Can't use CL
SHL AH,1
SHL AH,1
SHL AH,1
CALL RXNIB
OR AL,AH
ADD BL,AL ; Add to check sum
XCHG BH,AH ; Restore AH register
RET
RXNIB: CALL RXCHARNE ; Get Hex Character in AL
CMP AL,'0' ; Check to make sure 0-9,A-F
JB ERROR ;ERRHEX
CMP AL,'F'
JA ERROR ;ERRHEX
CMP AL,'9'
JBE SUB0
CMP AL,'A'
JB ERROR ; ERRHEX
SUB AL,07h ; Convert to hex
SUB0: SUB AL,'0' ; Convert to hex
RET
ERROR: MOV AL,'E'
DISPCH: CALL TXCHAR
WAITLDS: CALL RXCHARNE ; Wait for ':'
CMP AL,':'
JNE WAITLDS
XOR CX,CX ; CL=Byte count
XOR BX,BX ; BL=Checksum
CALL RXBYTE ; Get length in CX
MOV CL,AL
CALL RXBYTE ; Get Address HIGH
MOV AH,AL
CALL RXBYTE ; Get Address LOW
MOV DI,AX ; DI=Store Address
CALL RXBYTE ; Get Record Type
CMP AL,EOF_REC ; End Of File Record
JE GOENDLD
CMP AL,DATA_REC ; Data Record?
JE GOLOAD
CMP AL,EAD_REC ; Extended Address Record?
JE GOEAD
CMP AL,SSA_REC ; Start Segment Address Record?
JE GOSSA
JMP ERROR ;ERRREC
GOSSA: MOV CX,2 ; Get 2 word
NEXTW: CALL RXBYTE
MOV AH,AL
CALL RXBYTE
PUSH AX ; Push CS, IP
LOOP NEXTW
CALL RXBYTE ; Get Checksum
SUB BL,AL ; Remove checksum from checksum
NOT AL ; Two's complement
ADD AL,1
CMP AL,BL ; Checksum held in BL
JNE ERROR ;ERRCHKS
RETF ; Execute loaded file
GOENDLD: CALL RXBYTE
SUB BL,AL ; Remove checksum from checksum
NOT AL ; Two's complement
ADD AL,1
CMP AL,BL ; Checksum held in BL
JNE ERROR ;ERRCHKS
JMP LOADOK
GOCHECK: CALL RXBYTE
SUB BL,AL ; Remove checksum from checksum
NOT AL ; Two's complement
ADD AL,1
CMP AL,BL ; Checksum held in BL
JNE ERROR ;ERRCHKS
MOV AL,'.' ; After each successful record print a '.'
JMP DISPCH
GOLOAD: CALL RXBYTE ; Read Bytes
STOSb ; ES:DI <= AL
LOOP GOLOAD
JMP GOCHECK
GOEAD: CALL RXBYTE
MOV AH,AL
CALL RXBYTE
MOV ES,AX ; Set Segment address (ES)
JMP GOCHECK
;ERRCHKS: MOV SI,OFFSET LD_CHKS_MESS ; Display Checksum error
; JMP EXITLD ; Exit Load Command
;ERRREC: MOV SI,OFFSET LD_REC_MESS ; Display unknown record type
; JMP EXITLD ; Exit Load Command
LOADOK: MOV SI,OFFSET LD_OK_MESS ; Display Load OK
; JMP EXITLD
;ERRHEX: MOV SI,OFFSET LD_HEX_MESS ; Display Error hex value
EXITLD: CALL PUTS
JMP CMD ; Exit Load Command
;----------------------------------------------------------------------
; Disassembler
; Compiled, Disassembled from disasm.c
; wcl -c -0 -fpc -mt -s -d0 -os -l=COM disasm.c
; wdis -a -s=disasm.c -l=disasm.lst disasm.obj
;----------------------------------------------------------------------
get_byte_:
push si
push di
push bp
mov bp,sp
push ax
mov si,ax
mov word ptr -2[bp],dx
mov ax,bx
mov bx,cx
mov di,word ptr [si]
mov dl,byte ptr ES:[di]
mov di,word ptr -2[bp]
mov byte ptr [di],dl
inc word ptr [si]
test ax,ax
je L$2
test cx,cx
je L$2
mov dl,byte ptr [di]
xor dh,dh
push dx
mov dx,offset L$450
push dx
add ax,word ptr [bx]
push ax
call near ptr esprintf_
add sp,6
add word ptr [bx],ax
L$2:
mov sp,bp
pop bp
pop di
pop si
ret
get_bytes_:
push si
push di
push bp
mov bp,sp
sub sp,6
mov di,ax
mov word ptr -4[bp],dx
mov word ptr -6[bp],bx
mov word ptr -2[bp],cx
xor si,si
L$3:
cmp si,word ptr 8[bp]
jge L$4
mov dx,word ptr -4[bp]
add dx,si
mov cx,word ptr -2[bp]
mov bx,word ptr -6[bp]
mov ax,di
call near ptr get_byte_
inc si
jmp L$3
L$4:
mov sp,bp
pop bp
pop di
pop si
ret 2
L$5:
DW offset L$16
DW offset L$18
DW offset L$7
DW offset L$7
DW offset L$7
DW offset L$7
DW offset L$7
DW offset L$7
DW offset L$8
DW offset L$18
DW offset L$11
DW offset L$15
DW offset L$18
DW offset L$18
DW offset L$18
DW offset L$18
DW offset L$18
DW offset L$18
DW offset L$18
DW offset L$18
DW offset L$19
DW offset L$19
DW offset L$19
DW offset L$19
DW offset L$19
DW offset L$19
DW offset L$19
DW offset L$19
DW offset L$19
DW offset L$19
DW offset L$19
DW offset L$19
DW offset L$19
DW offset L$19
DW offset L$19
DW offset L$19
DW offset L$19
DW offset L$19
L$6:
DW offset L$26
DW offset L$62
DW offset L$29
DW offset L$30
DW offset L$31
DW offset L$35
DW offset L$35
DW offset L$33
DW offset L$33
DW offset L$36
DW offset L$39
DW offset L$40
DW offset L$62
DW offset L$62
DW offset L$62
DW offset L$43
DW offset L$45
DW offset L$46
DW offset L$46
DW offset L$46
DW offset L$46
DW offset L$46
DW offset L$46
DW offset L$46
DW offset L$46
DW offset L$46
DW offset L$46
DW offset L$46
DW offset L$46
DW offset L$46
DW offset L$46
DW offset L$46
DW offset L$49
DW offset L$49
DW offset L$49
DW offset L$49
DW offset L$49
DW offset L$49
DW offset L$49
DW offset L$49
DW offset L$62
DW offset L$62
DW offset L$62
DW offset L$62
DW offset L$62
DW offset L$62
DW offset L$50
DW offset L$51
DW offset L$52
DW offset L$50
DW offset L$53
DW offset L$54
DW offset L$50
DW offset L$62
DW offset L$55
DW offset L$55
DW offset L$62
DW offset L$58
DW offset L$52
DW offset L$59
DW offset L$60
DW offset L$61
disasm_:
push cx
push si
push di
push bp
mov bp,sp
sub sp,3aH
push dx
push bx
xor di,di
mov word ptr -1aH[bp],di
mov word ptr -12H[bp],di
mov word ptr -0eH[bp],di
mov word ptr -18H[bp],ax
mov word ptr -10H[bp],offset _opcode1
mov word ptr -6[bp],di
mov word ptr -8[bp],di
jmp L$14
L$7:
mov al,byte ptr [si]
xor ah,ah
mov bx,ax
shl bx,1
push word ptr _seg_regs-4[bx]
mov ax,offset L$451
push ax
mov ax,word ptr -3cH[bp]
add ax,di
push ax
call near ptr esprintf_
add sp,6
jmp L$13
L$8:
cmp word ptr -8[bp],0
jne L$9
mov ax,1
jmp L$10
L$9:
xor ax,ax
L$10:
mov word ptr -8[bp],ax
jmp L$14
L$11:
mov dx,offset L$452
L$12:
push dx
push ax
call near ptr esprintf_
add sp,4
L$13:
add di,ax
L$14:
lea cx,-1aH[bp]
mov bx,word ptr -3eH[bp]
lea dx,-4[bp]
lea ax,-18H[bp]
call near ptr get_byte_
mov al,byte ptr -4[bp]
xor ah,ah
mov cl,3
shl ax,cl
mov si,word ptr -10H[bp]
add si,ax
test byte ptr 7[si],80H
je L$20
mov al,byte ptr [si]
cmp al,25H
ja L$18
xor ah,ah
mov bx,ax
shl bx,1
mov ax,word ptr -3cH[bp]
add ax,di
jmp word ptr cs:L$5[bx]
L$15:
mov dx,offset L$453
jmp L$12
L$16:
mov ax,offset L$454
L$17:
push ax
push word ptr -3cH[bp]
call near ptr esprintf_
add sp,4
jmp near ptr L$63
L$18:
mov ax,offset L$455
jmp L$17
L$19:
mov word ptr -12H[bp],1
L$20:
test byte ptr 7[si],10H
je L$21
lea cx,-1aH[bp]
mov bx,word ptr -3eH[bp]
lea dx,-2[bp]
lea ax,-18H[bp]
call near ptr get_byte_
cmp word ptr -12H[bp],0
je L$21
mov al,byte ptr [si]
xor ah,ah
mov cl,6
shl ax,cl
sub ax,500H
mov si,offset _opcodeg
add si,ax
mov al,byte ptr -2[bp]
xor ah,ah
mov cl,3
sar ax,cl
xor ah,ah
and al,7
shl ax,cl
add si,ax
L$21:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -