Not exactly, but I do know it's CPUID that is causing the problem. Maybe I have to check bit 21 in EFLAGS first to see if instruction is even supported in legacy mode with this processor
Machine: Intel Q6600 Quad core running Ubuntu 12.04 LTS 3.0 gig memory. Emulator qemu
Having just begun programming at this level, meaning BOOT, BIOS and ultimately kernel development, but no stranger to assembly, I haven't yet amassed the resources yet to drill into my code to see what's going on. Hencse this question. I hammered together a small test bed elf64 that is identical to snippet addresses 19H - 36H and the result was exactly as expected. Even this MBR works the way it is supposed to and drops into second stage @ 42H when 19H - 37H are omitted.
I have three drives on my computer and /dev/sda is what I use to emulate real life senarios. Otherwise qemu and as I have to invoke it kvm -hda boot do not have similar behaviours. I've even qualified the emulator with -cpu 486, -cpu kvm64, with no change. Can anyone shed some light on why this snippet does not think I have 64 bits, when a elf64 app in gdb works just fine with the exact same code.
It seems as though this legacy mode and 32 bit code just don't like one another.
Code: Select all
ADDR
--------------------------------------------
00 FA cli
01 31C0 xor ax,ax
03 8ED0 mov ss,ax
05 BC007C mov sp,0x7c00
08 8ED8 mov ds,ax
0A 8EC0 mov es,ax
0C FB sti
0D B80300 mov ax,0x3
10 CD10 int 0x10
12 BEF07C mov si,0x7cf0
15 E86000 call word 0x78
18 56 push si
19 66B800000080 mov eax,0x80000000
1F 6650 push eax
21 0FA2 cpuid
23 6659 pop ecx
25 6639C8 cmp eax,ecx
28 761D jna 0x47
2A B101 mov cl,0x1
2C 6689C8 mov eax,ecx
2F 0FA2 cpuid
31 660FBAE21D bt edx,0x1d
36 730F jnc 0x47
38 BEE07C mov si,0x7ce0
3B B80042 mov ax,0x4200
3E CD13 int 0x13
40 7205 jc 0x47
42 EA00000001 jmp word 0x100:0x0
47 5E pop si
48 E82D00 call word 0x78
4B 31C0 xor ax,ax
4D CD16 int 0x16
4F CD19 int 0x19
51