Hieronder een Assembly routine om de trein aan te sturen zoals gebruikt in mijn programma.
; LOC(Loc Adres, Speed, Data6)
; DX = Loc Adres
; AX = Speed
; BX = Data6
; pokes value as 1-byte integer
; segment = SPACE(4) && hexadecimal string
; offset = number < 65536 or hexadecimal string
; value = number or hexadecimal string
; Returns: .F. if less than three parameters passed
; .T. otherwise
;
;--------------
LOC PROC FAR
PUSH BP
MOV BP,SP
PUSH DS
PUSH ES
PUSH BX
PUSH DX
PUSH SI
CALL _TR_POKE_PARMS ; Loc Adres in DL, Speed in AL
PUSH AX
PUSH DX
MOV AX,3
PUSH AX
CALL __PARNI
ADD SP,2
MOV BX,AX ; Data6 in BL
POP DX
POP AX
CALL FAR [LOC1]
MOV AH,000h
JMP POKEBYTE_EXIT ; and we're done
LOC1:
PUSH BX
PUSH AX
PUSH DX
CALL FAR [CHECKZEND] ; Check Zend Buffer
MOV DX,000h ; Com1
MOV AL,058h ; x dec 88
MOV AH,001h ; Transmit Opcode
INT 14h
MOV DX,000h ; Com1
MOV AL,080h ; XLok (080h) - length = 1+4 bytes
MOV AH,001h ; Transmit Opcode
INT 14h
POP DX ; Loc Adres in DL
MOV AL,DL ; Loc Adres Low Byte
MOV DX,000h ; Com1
MOV AH,001h ; Transmit Opcode
INT 14h
MOV AL,00h ; Loc adres High Byte
MOV DX,000h ; Com1
MOV AH,001h ; Transmit Opcode
INT 14h
POP AX ; Speed in AL
MOV DX,000h ; Com1
MOV AH,001h ; Transmit Opcode
INT 14h
POP BX ; Data6 in BL
MOV AL,BL
MOV DX,000h ; Com1
MOV AH,001h ; Transmit Opcode
INT 14h
ONTVANG:
MOV DX,000h ; Com1
MOV AH,003h ; Status Opcode
INT 14h ; Check ontvangst buffer
TEST AH,01h ; Als Bit 1 = 1 dan verder (Data Available)
JZ ONTVANG ; Geen karakter ontvangen
MOV DX,000h ; Com1
MOV AH,002h ; Receive Opcode
INT 14h
RETF
CHECKZEND:
MOV DX,000h ; Com1
MOV AH,003h ; Status Opcode
INT 14h ; Check Zend Buffer
TEST AH,20h ; Is TX leeg? Als Bit 6 = 0 dan verder
JZ CHECKZEND ; Geen karakter ontvangen
RETF
POKEBYTE_EXIT:
POP SI
POP DX
POP BX
POP ES
POP DS
POP BP
PUSH AX
CALL __RETNI
ADD SP,2
RET
LOC ENDP