本帖最后由 褐眼睛 于 27-7-2021 04:30 PM 编辑
以下这个本来是写给Windows的,后来把它转换去Linux x64:
大家如果感兴趣,可以自行下载Flat Assembler for Linux,然后复制以下代码来编译试一试:
- format ELF64 executable 3
- segment readable executable
- entry $
- mov eax, 0x80000002
- cpuid
- mov dword [cpu], eax
- mov dword [cpu + 4], ebx
- mov dword [cpu + 8], ecx
- mov dword [cpu + 12], edx
- mov eax, 0x80000003
- cpuid
- mov dword [cpu + 16], eax
- mov dword [cpu + 20], ebx
- mov dword [cpu + 24], ecx
- mov dword [cpu + 28], edx
- mov eax, 0x80000004
- cpuid
- mov dword [cpu + 32], eax
- mov dword [cpu + 36], ebx
- mov dword [cpu + 40], ecx
- mov dword [cpu + 44], edx
- mov byte [cpu + 48],0xA ;Append line feed
- mov edx,49
- lea rsi,[cpu]
- mov edi,1 ; STDOUT
- mov eax,1 ; sys_write
- syscall
- xor edi,edi ; exit code 0
- mov eax,60 ; sys_exit
- syscall
- segment readable writeable
- cpu rb 49
复制代码
CPU名称只有48字节,这个小程序就是将BIOS预设好的CPU名称显示在终端窗口里。
|