Assembly Examples

Assembly syntax highlighting

Assembly Syntax Highlighting

; Simple x86 Assembly Example ; Print "Hello, World!" using Linux syscall section .data msg db 'Hello, World!', 0x0A ; message with newline len equ $ - msg ; calculate length section .bss buffer resb 64 ; reserve 64 bytes section .text global _start _start: ; write syscall mov eax, 4 ; sys_write mov ebx, 1 ; stdout mov ecx, msg ; message address mov edx, len ; message length int 0x80 ; kernel interrupt ; exit syscall mov eax, 1 ; sys_exit xor ebx, ebx ; return 0 int 0x80 ; Function to add two numbers add_numbers: push ebp mov ebp, esp mov eax, [ebp+8] ; first parameter add eax, [ebp+12] ; second parameter pop ebp ret ; Data alignment example align 4 mydata: dd 0x12345678 ; double word dw 0xABCD ; word db 0xFF ; byte