-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstring_insert.asm
65 lines (58 loc) · 1.04 KB
/
string_insert.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
%include "io.inc"
section .data
word1 db "hola mundo",0
word2 db " cruel",0
pos db 20
section .bss
result resb 100
section .text
global CMAIN
CMAIN:
mov ebp, esp; for correct debugging
xor eax, eax
xor ecx,ecx
mov cl , byte[pos]
mov eax, 0
repetir:
xor ebx,ebx
mov bl, byte[word1+eax]
mov byte[result+eax], bl
inc eax
loop repetir
xor ebx, ebx
xor ecx, ecx
mover2:
mov cl, byte[word2+ebx]
cmp cl, 0
je outt
mov [result+eax], cl
inc eax
inc ebx
jmp mover2
outt:
xor ebx, ebx
xor ecx, ecx
mov bl, byte[pos]
mover3:
mov cl, byte[word1+ebx]
cmp cl, 0
je outt2
mov [result+eax], cl
inc eax
inc ebx
jmp mover3
outt2:
jmp print
ret
print:
pusha
mov ecx, 100
mov eax, 0
repet:
xor ebx,ebx
mov bl, byte[result+eax]
inc eax
PRINT_CHAR bl
loop repet
popa
ret