Answer the question
In order to leave comments, you need to log in
Assembler (linux x64 nasm) how to return the value obtained by subtracting from one variable to another?
Here is what I wrote:
section .bss
num1 resb 2
num2 resb 2
global _start
section .text
_start:
mov [num1], dword 500
mov [num2], dword 300
sub [num1], dword num2
mov ebx, num1
mov eax, 1
int 80h
Answer the question
In order to leave comments, you need to log in
I suspect (not a nasm expert) that the instruction
does not do what you want. Most likely, dword num2 takes the address num2, since in x86 there is no opcode "subtract from the number at address ___ the number at address ___", only the subtraction of a constant.
You need something like:
mov ebx, [num1]
mov ecx, [num2]
sub ebx, ecx
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question