-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcopy_16bits_vetor_movsw_stosw.asm
163 lines (122 loc) · 2.35 KB
/
copy_16bits_vetor_movsw_stosw.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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
.model small
.stack 100H
.data
destino dw 5 dup(?)
origem dw 5 dup(?)
CR EQU 13 ;
LF EQU 10 ;
.code
LER_CHAR proc
mov AH, 7
int 21H
ret
endp
ESC_CHAR proc
push AX
mov AH, 2
int 21H
pop AX
ret
endp
ESC_UINT16 proc
push AX
push BX
push CX
push DX
mov BX, 10
xor CX, CX
LACO_DIV:
xor DX, DX
div BX
push DX
inc CX
cmp AX, 0
jnz LACO_DIV
LACO_ESCDIG:
pop DX
add DL, '0'
call ESC_CHAR
loop LACO_ESCDIG
pop DX
pop CX
pop BX
pop AX
ret
endp
LER_UINT16 proc
push BX
push CX
push DX
xor AX, AX
xor CX, CX
mov BX, 10
LER_UINT16_SALVA:
push AX
LER_UINT16_LEITURA:
call LER_CHAR
cmp AL, CR
jz LER_UINT16_FIM
cmp AL, '0'
jb LER_UINT16_LEITURA
cmp AL, '9'
ja LER_UINT16_LEITURA
mov DL, AL
call ESC_CHAR
mov CL, AL
sub CL, '0'
pop AX
mul BX
add AX,CX
jmp LER_UINT16_SALVA
LER_UINT16_FIM:
pop AX
mov DL, CR
call ESC_CHAR
mov DL, LF
call ESC_CHAR
pop DX
pop CX
pop BX
ret
endp
COPIAVETOR16 proc
push DI
push SI
push CX
push AX
cld
rep movsw
pop DI
pop SI
pop AX
pop CX
ret
endp
INICIO:
mov AX, @DATA
mov DS, AX
mov ES, AX
mov DI, offset origem
mov CX, 5
LACO_PRINCIPAL:
call LER_UINT16
stosw
loop LACO_PRINCIPAL
mov SI, offset origem
mov DI, offset destino
mov CX, 5
call COPIAVETOR16
mov CX, 5
mov SI, offset destino
ESCREVE_VETOR:
mov AX, [SI]
call ESC_UINT16
add SI, 2
mov DL, CR
call ESC_CHAR
mov DL, LF
call ESC_CHAR
loop ESCREVE_VETOR
mov ah, 4ch
int 21h
end INICIO