-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLab4.asm
87 lines (73 loc) · 1.05 KB
/
Lab4.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
86
87
;filename: Lab4.asm
.model small
.data
str1 db "A*B", 10, 13, "$"
A dw 340dh
B dw 5h
D dw 0ff00h
counter db 0h
result db 4 dup(?),'$'
nextLine db 10, 13, "$"
.stack 100h
.code
main proc
mov ax, @data
mov ds, ax
mov dx, offset str1
mov ah, 09h
int 21h
mov sp, A
mov ax, B
mul sp
mov bx, dx
Transfer:
mov cl, 4
mov dl, bh
shr dl, cl
add dl, 30h
mov result[0], dl
mov dl, bh
shl dl, cl
shr dl, cl
add dl, 30h
mov result[1], dl
mov dl, bl
shr dl, cl
add dl, 30h
mov result[2], dl
mov dl, bl
shl dl, cl
shr dl, cl
add dl, 30h
mov result[3], dl
mov cx, ax
mov dx, offset result
mov ah, 09h
int 21h ;print
add counter, 01h
cmp counter, 01h
je Second
cmp counter, 02h
je DProcess
cmp counter, 03h
je Exit_Proc
Second:
mov bx, cx
jmp Transfer
DProcess:
mov sp, A
mov ax, B
imul sp
mov bx, D
idiv bx
mov sp, dx
mov dx, offset NextLine
mov ah, 09h
int 21h
mov bx, sp
jmp Transfer
Exit_Proc:
mov ax, 4c00h
int 21h
main endp
end main