vivendi
Programmer
- May 12, 2005
- 34
Hello, i have to calculate the sum of numbers, which works great, but now i have to do this with numbers that are to big so that a carry is set.
Somehow i still have to display the real result, but i dont know how to do this when there's an overflow/carry.
I know i have to use the JC instruction to see if a carry is set, but i dont know what to do with it and how to handle after a carry is set. Can someone please help me out with this!?
I've got the following sourcecode.
Somehow i still have to display the real result, but i dont know how to do this when there's an overflow/carry.
I know i have to use the JC instruction to see if a carry is set, but i dont know what to do with it and how to handle after a carry is set. Can someone please help me out with this!?
I've got the following sourcecode.
Code:
.386
.model flat,stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc
include \masm32\include\masm32.inc
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib
includelib \masm32\lib\masm32.lib
.data
numbers dd 2000000001,2000000002,2000000003,2000000004,2000000005
message db "Total is %d",0
testmsg db "Carry is set",10,13
.data?
buffer db 100 dup(?)
.code
start:
xor eax,eax
mov edx,OFFSET numbers
mov ecx,5
Count:
add eax,DWORD PTR [edx]
add edx,4
dec ecx
jnz Count
invoke wsprintf,ADDR buffer,ADDR message,eax
invoke StdOut,ADDR buffer
invoke ExitProcess,0
END start