It is my first assembly program.
Can anyone please help to make it run successfully.
I am seeing below compilation error.
Why it do not recognize the ?
and @data
?
I am trying to swap two variables in assembly.
I am executing the following command
nasm -f elf swap.asm
But I get this error:
swap.asm:6: error: symbol `?' undefined
swap.asm:12: error: symbol `@data' undefined
swap.asm:15: error: invalid combination of opcode and operands
swap.asm:21: error: invalid combination of opcode and operands
swap.asm:22: error: invalid combination of opcode and operands
This is my code:
section .data
C equ 15
var1 db 12
section .bss
var2 db ?
section .code
global _start
_start:
mov ax, @data
mov ds, ax
mov var2, C
; swap var1 and var2
mov al, var1
mov bl, var2
mov var2, al
mov var1, bl
; now print the swapped values
mov eax, 4 ; 4 = sys_write
mov ebx, 1 ; 1 - std out FD
mov ecx, var1
mov edx, 8
int 80h
mov eax, 4 ; 4 = sys_write
mov ebx, 1 ; 1 - std out FD
mov ecx, var2
mov edx, 8
int 80h
; exit the program
mov eax, 1 ; 1 = sys_exit
mov ebx, 0
int 80h