So, I want to print a square triangular numbers, you can see at here.
This is code I wrote :
global main
extern printf
section .data
format db "%u ", 0
section .text
main:
mov ecx, 8
square_triangular:
xor edx, edx
mov eax, 0
call print ; just print zero in early
mov ebx, 1
mov eax, ebx
jecxz .done
.loop:
call print
imul eax, 34
sub eax, edx
add eax, 2
mov edi, eax
add edx, 1
sub edx, 1
xchg ebx, edx
mov ebx, edi
mov eax, eax ; store in eax
loop .loop
.done:
ret
print:
pushad
push eax
push format
call printf
add esp, 8
popad
ret
The result correct value is iteration from 0 - 7
but at iteration 8
not correct value.
0 1 36 1225 41616 1413721 48024900 1631432881 3881085504
^
|
here (this is wrong)
So you can help me to fix this if possible ?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…