I'm interfacing with hardware through the RS232 serial port. This time with wireless modules. I decided to use DOS as my OS over anything else because its real-time (which means no process can interrupt the operation of the serial port).
I created a critical section in which a specific character has to be received by a certain time in QuickBasic but I want to port this section to assembly (machine code) so I don't have to wait extra microseconds for QuickBasic internal processing.
This is my QuickBasic code:
start# = TIMER
DO
IF (TIMER-start#) > .1# THEN
PRINT "failure"
END
END IF
LOOP UNTIL INP(&H3F8) = &H5A
PRINT "SUCCESS"
Now I want to port this into an assembly fragment I can apply a call absolute command to in QuickBasic, except I don't know if the code I'm using will work. (is my use of the si register acceptable here?). I want the assembly code to return a 1 if there's a timeout or a 0 if the correct character is received on the serial line.
So far, I came up with the following code (based on help from Ralf Brown's Interrupt List):
push bp 'save pointer
mov bp,sp 'get copy
mov ah,00
int 1A 'get bios time
mov si,cx
mainloop:
mov ah,00
int 1A
mov ax,cx
sub ax,si
sub ax,03 'use a 3 tick timeout
jc timeout
mov dx,03F8
in dx,al
cmp al,5A
jne notfound
mov ax,0 'return 0 for got character
jmp ending
notfound:
jmp mainloop
timeout:
mov ax,1 'return 1 for timeout
ending:
mov bx,[bp+06]
mov [bx],ax
pop bp
retf 2
Am I nailing this? or do I need to make changes?