I am writing a toy OS, which is supposed to be a command line. I have tried adding CPUID to my functionality, and I get weird results when I call CPUID in consecutive order, i.e. 80000002h
, 80000003h
, 80000004h
. If I call it in any other order, it works fine.
Consecutive order
Another order:
This is the offending part of the code.
prcpuinf:
push dx
mov eax, 80000002h
cpuid
mov [es:cpuinfo+0], eax
mov [es:cpuinfo+4], ebx
mov [es:cpuinfo+8], ecx
mov [es:cpuinfo+12], edx
mov eax, 80000003h
cpuid
mov [es:cpuinfo+16], eax
mov [es:cpuinfo+20], ebx
mov [es:cpuinfo+24], ecx
mov [es:cpuinfo+28], edx
mov eax, 80000004h
cpuid
; jmp prnt
mov [es:cpuinfo+32], eax
mov [es:cpuinfo+36], ebx
mov [es:cpuinfo+40], ecx
mov [es:cpuinfo+44], edx
nop
prnt:
mov ah, 13h
mov ecx, 48;cpulen
mov bh, 0
mov bl, 0x07
mov dh, 3
mov dl, 3
mov bp, cpuinfo
int 10h
pop dx
mov ecx, 1
ret
The code behaves this way even if I don't copy the last part of the CPU Brand String, i.e. when uncommenting `jmp prnt.
Because this part works normally in a file by itself, I have posted my entire code here.
Please note, I am not looking for a solution, but rather for an explanation to what is happening.