DefAssembler

x86 x64
AT&T Intel
SYS_WRITE = 1 SYS_EXIT = 60 STDOUT_FILENO = 1 # Printing .data buffer: .string "Hello, world!\n" bufferLen = . - buffer .text mov $SYS_WRITE, %eax mov $STDOUT_FILENO, %edi mov $buffer, %esi mov $bufferLen, %edx syscall # Looping .data digit: .byte '0', '\n' .text mov $10, %bl numberLoop: mov $SYS_WRITE, %eax mov $STDOUT_FILENO, %edi mov $digit, %esi mov $2, %edx syscall incb (%rsi) dec %bl jnz numberLoop # Accessing arguments pop %rbx pop %rax argLoop: dec %ebx jz endArgLoop pop %rsi mov %rsi, %rdi mov $-1, %ecx xor %al, %al repnz scasb not %ecx movb $'\n', -1(%rsi, %rcx) mov %ecx, %edx mov $SYS_WRITE, %eax mov $STDOUT_FILENO, %edi syscall jmp argLoop endArgLoop: mov $SYS_EXIT, %eax mov $0, %edi syscall SYS_WRITE = 4 SYS_EXIT = 1 STDOUT_FILENO = 1 # Printing .data buffer: .string "Hello, world!\n" bufferLen = . - buffer .text mov $SYS_WRITE, %eax mov $STDOUT_FILENO, %ebx mov $buffer, %ecx mov $bufferLen, %edx int $0x80 # Looping .data digit: .byte '0', '\n' .text mov $10, %si numberLoop: mov $SYS_WRITE, %eax mov $STDOUT_FILENO, %ebx mov $digit, %ecx mov $2, %edx int $0x80 incb (%ecx) dec %si jnz numberLoop # Accessing arguments pop %ebp pop %eax argLoop: dec %ebp jz endArgLoop pop %esi mov %esi, %edi mov $-1, %ecx xor %al, %al repnz scasb not %ecx movb $'\n', -1(%esi, %ecx) mov %ecx, %edx mov $SYS_WRITE, %eax mov $STDOUT_FILENO, %ebx mov %esi, %ecx int $0x80 jmp argLoop endArgLoop: mov $SYS_EXIT, %eax mov $0, %ebx int $0x80 SYS_WRITE = 1 SYS_EXIT = 60 STDOUT_FILENO = 1 ; Printing section .data buffer db "Hello, world!\n" bufferLen = $ - buffer section .text mov eax, OFFSET SYS_WRITE mov edi, OFFSET STDOUT_FILENO mov esi, OFFSET buffer mov edx, OFFSET bufferLen syscall ; Looping section .data digit db '0', '\n' section .text mov bl, 10 numberLoop: mov eax, OFFSET SYS_WRITE mov edi, OFFSET STDOUT_FILENO mov esi, OFFSET digit mov edx, 2 syscall inc BYTE [rsi] dec bl jnz numberLoop ; Accessing arguments pop rbx pop rax argLoop: dec ebx jz endArgLoop pop rsi mov rdi, rsi mov ecx, -1 xor al, al repnz scasb not ecx mov BYTE [rcx + rsi - 1], '\n' mov edx, ecx mov eax, OFFSET SYS_WRITE mov edi, OFFSET STDOUT_FILENO syscall jmp argLoop endArgLoop: mov eax, OFFSET SYS_EXIT mov edi, 0 syscall SYS_WRITE = 4 SYS_EXIT = 1 STDOUT_FILENO = 1 ; Printing section .data buffer db "Hello, world!\n" bufferLen = $ - buffer section .text mov eax, OFFSET SYS_WRITE mov ebx, OFFSET STDOUT_FILENO mov ecx, OFFSET buffer mov edx, OFFSET bufferLen int 80h ; Looping section .data digit db '0', '\n' section .text mov si, 10 numberLoop: mov eax, OFFSET SYS_WRITE mov ebx, OFFSET STDOUT_FILENO mov ecx, OFFSET digit mov edx, 2 int 80h inc BYTE [ecx] dec si jnz numberLoop ; Accessing arguments pop ebp pop eax argLoop: dec ebp jz endArgLoop pop esi mov edi, esi mov ecx, -1 xor al, al repnz scasb not ecx mov BYTE [ecx + esi - 1], '\n' mov edx, ecx mov eax, OFFSET SYS_WRITE mov ebx, OFFSET STDOUT_FILENO mov ecx, esi int 80h jmp argLoop endArgLoop: mov eax, OFFSET SYS_EXIT mov ebx, 0 int 80h