home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
assemblr
/
library
/
asm_kit
/
decibin.asm
< prev
next >
Wrap
Assembly Source File
|
1985-06-21
|
1KB
|
37 lines
;DECIBIN--Program to get decimal digits from keyboard and
;convert them to binary number in BX
;
prognam segment
;
assume cs:prognam
;
mov bx,0 ;clear BX for number
;Get digit from keyboard, convert to binary
;
newchar:
mov ah,1 ;keyboard input
int 21h ;call DOS
sub al,30h ;ASCII to binary
jl exit ;jump if <0
cmp al,9h ;is it > 9d ?
jg exit ;yes, not decimal digit
cbw ;byte in AL to word in AX
;(digit is now in AX)
;
;Multiply number in BX by 10 decimal
xchg ax,bx ;trade digit & number
mov cx,10d ;put 10 decimal in CX
mul cx ;number times 10
xchg ax,bx ;trade number & digit
;
;Add digit in AX to number in BX
add bx,ax ;add digit to number
jmp newchar ;get next digit
exit:
;
int 20h
;
prognam ends
;
end