Files
Espresso/arch/x86/cpuid_asm.asm

54 lines
988 B
NASM
Raw Normal View History

2026-02-12 20:33:46 -06:00
global get_cpu_brand_string
2025-10-20 21:57:30 -05:00
2026-02-12 20:33:46 -06:00
section .text
; void get_cpu_brand_string(char* buffer)
2025-10-20 21:57:30 -05:00
get_cpu_brand_string:
2026-02-12 20:33:46 -06:00
pushad ; Save registers
2025-10-20 21:57:30 -05:00
2026-02-12 20:33:46 -06:00
mov edi, eax ; EAX = pointer to output buffer
2025-10-20 21:57:30 -05:00
mov eax, 0x80000000
cpuid
2026-02-12 20:33:46 -06:00
cmp eax, 0x80000004
2025-10-20 21:57:30 -05:00
jb .not_supported
2026-02-12 20:33:46 -06:00
mov esi, edi ; Buffer pointer → ESI
2025-10-20 21:57:30 -05:00
2026-02-12 20:33:46 -06:00
; ---- CPUID leaf 0x80000002 ----
2025-10-20 21:57:30 -05:00
mov eax, 0x80000002
cpuid
2026-02-12 20:33:46 -06:00
mov [esi], eax
mov [esi+4], ebx
mov [esi+8], ecx
mov [esi+12], edx
2025-10-20 21:57:30 -05:00
2026-02-12 20:33:46 -06:00
; ---- CPUID leaf 0x80000003 ----
2025-10-20 21:57:30 -05:00
mov eax, 0x80000003
cpuid
2026-02-12 20:33:46 -06:00
mov [esi+16], eax
mov [esi+20], ebx
mov [esi+24], ecx
mov [esi+28], edx
2025-10-20 21:57:30 -05:00
2026-02-12 20:33:46 -06:00
; ---- CPUID leaf 0x80000004 ----
2025-10-20 21:57:30 -05:00
mov eax, 0x80000004
cpuid
2026-02-12 20:33:46 -06:00
mov [esi+32], eax
mov [esi+36], ebx
mov [esi+40], ecx
mov [esi+44], edx
mov byte [esi+48], 0 ; Null terminator
2025-10-20 21:57:30 -05:00
jmp .done
.not_supported:
2026-02-12 20:33:46 -06:00
mov byte [edi], 0
2025-10-20 21:57:30 -05:00
.done:
popad
ret