-
Notifications
You must be signed in to change notification settings - Fork 0
/
ex2.asm
116 lines (102 loc) · 1.85 KB
/
ex2.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
data segment
n db 3,?,?
array db 100 dup(?)
space db ' ','$'
data ends
stack segment stack
db 100 dup(?)
stack ends
code segment
assume cs:code,ss:stack,ds:data
start:
mov ax,data
mov ds,ax
lea dx,n
mov ah,0ah
int 21h
mov dl,n+2
mov ah,02h
int 21h
add dl,-48
mov n+2,dl
mov al,n+2
;add al,-48
mov ah,00h
mov cx,ax ;循环次数
;mov dl,al ;dl保存n的值
;mov dh,00h
xor dx,dx
xor di,di ;dl为计数器
xor bx,bx ;基址
inicol:
xor si,si ;变址
save:
cmp si,ax
jz nextrow
push bx
inc dl
mul bl
mov bl,al
mov al,n+2
;add al,-48
mov ah,00h
mov array[bx+si],dl
pop bx
mov bh,00h
inc si
jmp save
nextrow:
inc bl
cmp bl,al
jz print
loop inicol ;
print:
mov dl,0ah
mov ah,02h
int 21h
mov ax,n+2
mov ah,00h
mov di,0
add di,ax
mov ax,0
mov cx,0
mov si,0
loopout:
cmp cx,di
jz endout
xor si,si
loopin:
cmp si,di
jz endin
cmp si,cx
ja endin
mov ax,cx
mul n+2
mov bx,ax
mov al,array[bx+si];al to be print
mov dl,10
div dl
mov dl,al
add dl,48
push ax
mov ah,02h
int 21h
pop ax
mov dl,ah
add dl,48
mov ah,02h
int 21h
mov dl,space
int 21h
inc si
jmp loopin
endin:
mov dl,0ah
int 21h
inc cx
jmp loopout
endout:
mov ah,4ch
int 21h
code ends
end start