-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIntToString- Procedura
95 lines (83 loc) · 1.23 KB
/
IntToString- Procedura
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
TITLE MASM Template (main.asm)
INCLUDE Irvine32.inc
.data
PrevedeneCislo DB 10 dup (?)
Medzivysledok DW 0
Desat DW 10
.code
IntToStr PROC USES eax ebx ecx edx esi edi paCislo,paAdresa
mov esi, paCislo
mov ebx, paAdresa
cmp esi,0
jle L1
mov byte ptr [ebx],byte ptr '+'
Jmp L2
L1:neg esi
mov byte ptr [ebx],byte ptr '-'
L2:
mov edi,1
Cyklus:
mov eax,1
mov ecx,edi
Vnutro:
mul Desat
loop Vnutro
cmp eax, esi
jae Dalej
inc edi
jmp Cyklus
Dalej:
cmp edi,1
jne Pokracovanie
cmp esi,10
jne Nedesiatka
mov byte ptr [ebx + 1],'1'
mov byte ptr [ebx + 2],'0'
mov byte ptr [ebx + 3],0
jmp Koniec
Nedesiatka:
mov eax,esi
add eax,48
mov byte ptr [ebx + 1],al
mov byte ptr [ebx + 2],0
jmp Koniec
Pokracovanie:
dec edi
mov ecx,edi
mov edi,1
mov edx,esi
Prevod:
mov eax,1
mov esi,ecx
push edx
Nasobenie:
mul Desat
loop Nasobenie
pop edx
push ebx
mov ebx,eax
mov eax,edx
xor edx,edx
div ebx
add eax,48
pop ebx
mov byte ptr [ebx + edi],al
inc edi
mov ecx,esi
loop Prevod
add edx,48
mov byte ptr [ebx + edi],dl
inc edi
mov byte ptr [ebx + edi],0
Koniec:
ret
IntToStr ENDP
main PROC
call ReadInt
mov edx, OFFSET PrevedeneCislo
INVOKE IntToStr,eax,edx
mov edx, OFFSET PrevedeneCislo
call WriteString
exit
main ENDP
END main