📄 tr8086.asm
字号:
mov cx, 0FFH ; Get result from 1st length byte.
xor ah, ah ; Clear high byte of accumulator.
add cx, ax ; Add second length byte.
add cx, 2 ; Add two for CRC16 bytes.
jmp gotlngth ; Go read cx bytes of data.
doread:
xor ah, ah ; Clear high byte of accumulator.
mov cx, ax ; Get length byte in cx.
add cx, 2 ; Add two for CRC16 bytes.
gotlngth:
mov al, 0FFH ; Prepare to read a byte of data.
push cx ; Save byte counter.
push ax ; Send 0FFH to touchbyte on stack.
push cs ; Prepare for a far call.
call touchbyte ; Read byte of data from 1-wire.
call docrc16 ; Calculate cummulative CRC16.
pop cx ; Restore byte counter.
loop gotlngth ; Continue until all bytes read.
cmp CRC16, 0B001H ; Is the CRC16 good.
jne badcrc ; Set failure condition if not.
mov al, 1 ; Set success condition.
jmp npd ; Exit procedure.
badcrc:
xor al, al ; Indicate failure.
npd:
ret ; Return to caller.
readtm endp
;
; This procedure sends a 4 byte command to the 1-wire bus. the offset of
; the beginning of the command is passed in bx.
;
; Note: Original values of ax, dx are destroyed.
;
sendcomm proc near
push bx ; Save bx register.
push cx ; Save cx register.
push bx ; Save our offset to command.
mov ax, 1 ; Get port number in ax.
push ax ; Send it on stack.
push cs ; Prepare for far call.
call touchreset ; Send reset pulse to 1-wire bus.
pop bx ; Restore offset to command.
or al, al ; Test for presence pulse.
jz np1 ; If none detected, abort.
mov cx, 4 ; Prepare to send 4 bytes to bus.
nextcb:
mov ax, [bx] ; Get command byte in ax.
push bx ; Save pointer to command bytes.
push cx ; Save counter.
push ax ; Push byte to send on stack.
push cs ; Prepare for far call.
call touchbyte ; Send byte to 1-wire bus.
pop cx ; Restore counter.
pop bx ; Restore pointer.
inc bx ; Point to next byte.
loop nextcb ; Send all 4 command bytes.
mov al, 1 ; Set success condition.
np1:
pop cx ; Restore cx register.
pop bx ; Restore bx register.
ret ; Return to caller.
sendcomm endp
;
; This procedure sends the copy scratchpad or write scratchpad command to
; the 1-wire bus depending on the value passed in CB. For a copy scratchpad
; it assumes that the scratchpad has been filled so that the ending transfer
; address is 31 decimal.
;
scrcomm proc near
push bx ; Save bx register.
push cx ; Save cx register.
mov ax, 1 ; Get port number in ax.
push ax ; Send it on stack.
push cs ; Prepare for far call.
call touchreset ; Send reset pulse to 1-wire bus.
or al, al ; Test for presence pulse.
jz np2 ; If none detected, abort.
mov ax, 0CCH ; Get skip through ROM comm in ax.
push ax ; Send byte on stack.
push cs ; Prepare for far call.
call touchbyte ; Send byte to 1-wire bus.
mov al, CB ; Get copy scratchpad comm. in ax.
push ax ; Send byte on stack.
push cs ; Prepare for far call.
call touchbyte ; Send byte to 1-wire bus.
mov al, PNUM ; Get page number in al.
mov cl, 5 ; Prepare to rotate left by 5.
shl al, cl ; Get low byte starting address.
push ax ; in ax and send it on stack.
push cs ; Prepare for far call.
call touchbyte ; Send byte to 1-wire bus.
mov al, PNUM ; Get page number in al.
mov cl, 3 ; Setup to rotate al right by 3.
shr al, cl ; Get high byte starting address.
push ax ; in ax and send it on stack.
push cs ; Prepare for far call.
call touchbyte ; Send byte to 1-wire bus.
cmp CB, 0FH ; If this is a write scratchpad
je noea ; command don't send end addr.
mov al, 31 ; Get last byte of scratch in
push ax ; al and send it on stack.
push cs ; Prepare for far call.
call touchbyte ; Send byte to 1-wire bus.
noea:
mov al, 1 ; Indicate success.
np2:
pop cx ; Restore cx register.
pop bx ; Restore bx register.
ret ; Return to caller.
scrcomm endp
;
docrc16 proc near
push ax ; Save byte passed in ax.
push bx ; Save bx register.
push cx ; Save cx register.
xor bx, bx
mov ah, bh
xor ax, CRC16
xchg bl, ah
and al, al
jpe skpxor
xor bx, 0C001H
skpxor:
mov cl, 6
rol ax, cl
xor bx, ax
rol ax, 1
xor ax, bx
mov CRC16, ax
pop cx ; Restore cx register.
pop bx ; Restore bx register.
pop ax ; Restore byte passed in ax.
ret ; Return to caller.
docrc16 endp
;
RSM db 0CCH, 0F0H, 0, 0 ; Read secure memory command bytes.
;
stext db 'TOUCH MEMORY WRITE COMPLETE', CR, LF, '$'
tmessage db 'THIS IS A TEST OF THE EMERGENCY BROADCAST SYSTEM', 0, '$'
strlen equ $ - tmessage - 2
promptem db 'PLEASE TOUCH A TOUCH MEMORY, PRESS ANY KEY TO ABORT', CR, LF, '$'
;
CODE ends
;
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -