mmicroprocessor.blogspot.com
.model small
.data
message1 db
'number is odd$'
message2 db
'number is even$'
.code
.startup
call readh
push ax
mov dl,0ah
mov ah,02h
int 21h
pop ax
mov bl,01h
and al,bl
jz evn
mov dx,offset
message1
mov ah,09h
int 21h
jmp label1
evn:
mov dx,offset
message2
mov ah,09h
int 21h
label1:
mov dl,0ah
mov ah,02h
int 21h
mov ah,4ch
int 21h
readh proc near
mov cl,4
mov si,2
mov bl,00h
readh1:
mov ah,1
int 21h
call conv
shl bl,cl
add bl,al
dec si
jnz readh1
mov al,bl
ret
readh endp
conv proc near
cmp al,'9'
jbe conv2
cmp al,'a'
jb conv1
sub al,20h
conv1:
sub al,7
conv2:
sub al,30h
ret
conv endp
end
Output:
22
number is even
No comments:
Post a Comment