Data Types
;note how I'm using different data types here and the brackets to initialize rax
;with not the address of a variable but the absolute value
global start
section .text
_start:
xor rax,rax; nullifying rax to make sure no garbage bytes exist
mov al,1 ;syscall for write.
mov rdi,1 ;int fd, which is 1 for stdout since we are not storign the message anywhere rather printing it out
mov rsi,hello_world ; The buffer to be printed
mov rdx,length ; The length of hello world buffer we calculated in data section
syscall ; Executes the syscall 1 with arguments we gave. At this point rax will store the return value from the executed syscall
mov rax, var4 ; Loads up the var4 address in rax
mov rax, [var4] ; Loads up the value in var4 in rax
mov rax, 60 ; syscall number for exit
mov rdi, 11 ; Custom error code. Could be anything. 0 in most cases.
syscall
section .data
hello_world: db "Hello world! This is Harshit",0x0a
length: equ $-hello_world
var1: db 0x11,0x22 ; Assigns 2 bytes 0x11 and 0x22 to var1
var2: dw 0x3344 ; Assigns a word (2 bytes) to var2
var3: dd 0xaabbccdd ; Assigns a double word (4 bytes) to var3
var4: dq 0xaabbccdd11223344 ; Assigns a quad word (8 bytes) to var4
repeat_buffer: times 128 db 0xAA ; Assigns 128 bytes of 0xaa to repeat_buffer
section .bss
buffer: resb 64 ; Reserves uninitialized 64 bytes







Last updated