Reputation: 29
I saw this code to generate and display a square wave on a CRO.
data segment
base_add equ 0ef40h
porta equ base_add+0
portb equ base_add+1
portc equ base_add+2
control_word equ base_add+3
data ends
code segment
assume cs:code, ds:data
start : mov ax, data
mov ds, ax
mov dx, control_word
mov al, 80h
out dx, al
up2:
mov cx, 000ffh
mov al, 00h
mov dx, portb
mov al, 00h
here1: out dx,
loop here1
mov cx, 00ffh
mov al, 0ffh
here2: out dx, al
loop here2
mov ah, 0bh ; LINE1
int 21h
or al, al ; LINE2
jz up2
mov ah, 4ch
int 21h
code ends
end start
Towards the end, what is the use of mov ah, 0Bh
interrupt and or al, al
?
Isn't or al, al
basically just al
? What is the need to explicitly mention it?
I even tried to find out what 0Bh interrupt does, but I could not make sense out of what I read. Any help on this would be appreciated.
Thanks!
Upvotes: 1
Views: 2454
Reputation: 32953
That's MSDOS assembly code.
mov ah, 0Bh ; LINE1
int 21h
Calls DOS to check whether a character is available on standard input. This call will return 0 if no char available, 0xFF when a character is available. The return value will be given back via the al
register, so
or al, al ; LINE2
jz up2
will test whether a character is available (or al, al
will only be zero when al
is zero to begin with), and jump to up2 if there's nothing to read.
Tip: if you're working with DOS, go grab a copy of Ralf Brown's Interrupt list
Upvotes: 2