After seeing a hello world in 64-bit, I decided to try some very simple 64-bit.
section .note.openbsd.ident
align 2
dd 8
dd 4
dd 1
db 'OpenBSD',0
dd 0
align 2
section .data
A db 22h, 69h, 6Ch, 'l', ' the', ' birds!', 7Eh, 10 ; Kill the birds!~
Abytes equ $-A
B dw 0022h, 0069h, 006Ch, 'l', ' the', ' birds!', 007Eh, 10 ; Kill the birds!~
Bbytes equ $-B
C dq 00000022h, 00000069h, 0000006Ch, 'l', ' the', ' birds!', 0000007Eh, 10 ; Kill the birds!~
Cbytes equ $-C
section .text
global _start
_start:
add byte [A], 29h
add byte [A+1], 10
add byte [A+2], 10
mov rax, 4
mov rdi, 1
mov rsi, A
mov rdx, Abytes
syscall
add dword [B], 29h
add dword [B+2], 10
add dword [B+4], 10
mov rax, 4
mov rdi, 1
mov rsi, B
mov rdx, Bbytes
syscall
add qword [C], 29h
add qword [C+8], 10
add qword [C+16], 10
mov rax, 4
mov rdi, 1
mov rsi, C
mov rdx, Cbytes
syscall
mov rax, 1
xor rdi, rdi
syscall
Using to assemble:
nasm -f elf64 -o ADD1.o ADD1.asm
ld -m elf_x86_64_obsd -o ADD1 -nopie ADD1.o
I get, as expected:
$ ADD1
Ksvl the birds!~
Ksvl the birds!~
Ksvl the birds!~
but I can use either byte or word here:
add byte [A], 29h
add byte [A+1], 10
add byte [A+2], 10
or
add word [A], 29h
add word [A+1], 10
add word [A+2], 10