-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchecklm.asm
43 lines (32 loc) · 940 Bytes
/
checklm.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
;checks to see if the processor is 64-bit or not.
checklm: ;check long mode
pusha
pushfd
pop eax
mov ecx, eax
;flip the ID bit
xor eax, 1 << 21 ;if the 21st bit of eax is different than 1, flip it to one.
push eax
popfd
pushfd
pop eax
xor eax, ecx
;return true if they're different
jz .done
mov eax, 0x80000000 ;if cpuid pulls out a value, anything greater than this value + 1, we can read extended information
cpuid
cmp eax, 0x80000001
jb .done ;jump if eax is less than 0x80000001, meaning we can't support long mode. else we can get extended info through cpuid
mov eax, 0x80000001 ;gets extended processor info
cpuid
test edx, 1 << 29 ;see if the 29th bit is equal to 1.
jz .done ;if the 29th bit is equal to zero, jump to done; long mode isn't supported.
mov si, YES_LM
call print_str
popa ;else pop all off the stack
ret ;exit subroutine
.done:
popa
mov si, NO_LM
call print_str
jmp $