Hello,
I was wondering how you would add 64 bit numbers in MASM with adc. Can someone show me a few SIMPLE examples ( I am a beginner).
onlycurious,
Hello, and welcome. Here is an example:
.386
.MODEL FLAT,STDCALL
OPTION CASEMAP:NONE
INCLUDE windows.inc
INCLUDE kernel32.inc
INCLUDE user32.inc
INCLUDELIB kernel32.lib
INCLUDELIB user32.lib
.DATA
QW1 QWORD 4294967296
QW2 QWORD 2147483648
QW3 QWORD 0
.CODE
start:
; Add QWORDs (QW1 + QW2 = QW3)
mov eax, DWORD PTR [QW1+0] ; Low DWORD of QW1
mov edx, DWORD PTR [QW1+4] ; High DWORD of QW1
add eax, DWORD PTR [QW2+0] ; Low DWORD of QW2
adc edx, DWORD PTR [QW2+4] ; High DWORD of QW2
mov DWORD PTR [QW3+0], eax
mov DWORD PTR [QW3+4], edx
; Subtract QWORDS (QW1 - QW2 = QW3)
mov eax, DWORD PTR [QW1+0] ; Low DWORD of QW1
mov edx, DWORD PTR [QW1+4] ; High DWORD of QW1
sub eax, DWORD PTR [QW2+0] ; Low DWORD of QW2
sbb edx, DWORD PTR [QW2+4] ; High DWORD of QW2
mov DWORD PTR [QW3+0], eax
mov DWORD PTR [QW3+4], edx
INVOKE ExitProcess, 0
END start