Skip to content

Instantly share code, notes, and snippets.

@lina-bh
Created August 13, 2024 22:05
Show Gist options
  • Select an option

  • Save lina-bh/4d1a14fed78d047ab94581465cbf236b to your computer and use it in GitHub Desktop.

Select an option

Save lina-bh/4d1a14fed78d047ab94581465cbf236b to your computer and use it in GitHub Desktop.
; vim: set ft=nasm
global _main
extern _puts
section .data
hello: db "hello, "
hello_len: equ $-hello
section .text
_main:
lea rdi, [rel hello]
call _puts
call vendor
call brand
jmp exit
vendor:
sub rsp, 24
mov eax, 0
cpuid
mov [rsp], ebx
mov [rsp+4], edx
mov [rsp+8], ecx
mov byte [rsp+13], `\0`
mov rdi, rsp
call _puts
add rsp, 24
ret
brand:
sub rsp, 64
xor rsi, rsi
head:
mov rdi, 16
imul rdi, rsi
mov eax, 0x80000002
add eax, esi
cpuid
mov [rsp+rdi], eax
mov [rsp+rdi+4], ebx
mov [rsp+rdi+8], ecx
mov [rsp+rdi+12], edx
cmp esi, 3
je tail
inc esi
jmp head
tail:
mov rdi, rsp
call _puts
add rsp, 64
ret
exit:
mov eax, 0x02000001
mov edi, 0
syscall
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment