This repository has been archived by the owner on Nov 29, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
2.4.asm
85 lines (85 loc) · 1.67 KB
/
2.4.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
data segment
str1 db 'please input a number to a:$'
str2 db 'please input a number to b:$'
str3 db 'result c=a*b=$'
a dw ?
b dw ?
c dw ?
data ends
code segment
assume cs:code,ds:data
main proc far
start:
mov ax,data
mov ds,ax
lea dx,str1 ;ouput str1
mov ah,9h
int 21h
call input ;input a
mov a,bx
lea dx,str2 ;ouput str2
mov ah,9h
int 21h
call input ;input b
mov b,bx
lea dx,str3 ;ouput str3
mov ah,9h
int 21h
mov ax,a
aad
mov bx,ax
mov ax,b
aad
mul bx ;ax = a*b
mov word ptr c,ax ;c = a*b
mov di,0ah ;di = 10
mov cx,0
ToTen: ;convert to decimal
div di
push dx
inc cx
cmp ax,0
je print
cwd
jmp ToTen
print: ;output result
pop dx
add dl,30h
mov ah,2h
int 21h
loop print
mov ah,00h
int 21h
main endp
input proc
mov bx,0
inputa:
mov ah,1 ;first char
int 21h
sub al,30h
mov bl,al
mov ah,1 ;second char
int 21h
cmp al,0dh ;compare if al==Enter
je exit
sub al,30h
mov cl,8 ;shift operation
rol bx,cl
mov bl,al
jmp exit
exit:
call crlf
ret
input endp
;print next line
crlf proc near
mov dl,0ah
mov ah,2h
int 21h
mov dl,0dh
mov ah,2h
int 21h
ret
crlf endp
code ends
end start