Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

x86 ASM --> entering protected mode.

Name: Anonymous 2008-09-20 22:32

Dear /prog/

Why does this fail?

BITS 16
        cli

        lgdt [cs:pGDT32]

        mov eax, 11h
        mov cr0, eax

        jmp far SEL_CODE:pm_start
SEL_NULL equ 0
SEL_DATA equ 1 << 3
SEL_CODE equ 2 << 3
SEL_LONG equ 3 << 3

pGDT32:
        dw 4*8-1
        dd GDT32
align 4
GDT32: 
        dq 0
        dw 0FFFFh, 0, 9200h, 08Fh
        dw 0FFFFh, 0, 9A00h, 0CFh
        dw 0FFFFh, 0, 9A00h, 0AFh
msg.woohoo:
        db "Win, baybe!", 0
BITS 32
pm_start:
        mov si, msg.woohoo
        call puts

Name: Anonymous 2008-09-20 23:26

Don't write x86 ASM, there is a reason why a compiler generates plain x86 ASM, because a human is not capable of understanding it. Write MIPS ASM instead, it is much cleaner and human readable.

Name: Anonymous 2008-09-20 23:39

>>2
More like because YOU aren't capable of understanding it amirite?

Name: Anonymous 2008-09-21 0:13

>>2
The reason it generates assembly is because the compiler author couldn't be bothered with doing manual label-to-address translation when there were perfectly good assemblers for doing this. Also, to create a human readable description of what it's actually telling the computer to do.

I'll write it in something else when you show me how to go from real to long mode in that language. Until then, why the fuck does my qemu decide to stop working when hitting that far jump? It's taken more or less straight from the amd64 documents.

Name: Anonymous 2008-09-21 2:01

qemu
amd64

Name: Anonymous 2008-09-21 2:12

>>5
qemu-system-x86_64

Name: Anonymous 2008-09-21 2:16

>>1
Do you know where things are blowing up? That would be helpful.

1. You are not updating ds and ss after jumping into protected mode.
2. I presume your 'puts' takes a string pointer in 'esi'. Why are you using only half of the register and not the full 32 bits?

>>5
qemu is dicks for debugging these sorts of problems

Name: Anonymous 2008-09-21 2:33

>>7
It fucks up on the jump.

1: As it fucks up on the jump, it never reaches puts.
2: Only half is needed.

What would you recommend in place of qemu?

Also, I just tried turning on the A20 line, didn't work.

Name: Anonymous 2008-09-21 3:17

>>8
Does your pGDT32 structure have the correct linear address for the GDT? Your address origin might be throwing it off (I presume it's at 0, if this is loaded off the boot sector you might want to fix that).

Are you positive the upper half of si isn't garbage? It probably is.

A20 line shouldn't make a difference at this point since you're not accessing memory above the 1MB mark.

bochs is OK for debugging CPU setup stuff like this. Unfortunately its emulation is more forgiving than it should be.     Maybe qemu has gotten better, but I recall it hanging a lot when the state blows up when transitioning between modes.

Name: Anonymous 2008-09-21 3:42

>>9
cs is 0, the bootloader puts the kernel at 1600h. In other examples I've seen this doesn't matter.

The file shown is included after showing some nice "Welcome to Failix! =D" messages.

But thanks thanks for the tip, I'm installing bochs now.

Name: Anonymous 2008-09-21 5:37

>>3
Stop picking on Guido.

Name: Anonymous 2008-09-21 6:50

>>1
FUCK YOU

/prog/ was having a nice programming related conversation and you come in with your memes.  gb2not this thread.

Name: Anonymous 2008-09-21 9:00

Bochs really helped.

The descriptor table wasn't in the correct format. However, I had set the code descriptor to point to a data descriptor in a wild goose chase, and later forgot about it, so I didn't find it until after I RAGE'd and wrote them in pure binary.


pGDT32:
        dw 3*8-1
        dd GDT32
align 4
GDT32:
.0:     dq 0
.1:     dq 0000000001011111100100100000000000000000000000001111111111111111b
.2:     dq 0000000001011111100110100000000000000000000000001111111111111111b


Next comes long mode, but this time armed with better tools.

Name: Anonymous 2008-09-21 20:55

You and your fancy tools. Just stick it on a floppy and boot from it.

Name: Anonymous 2008-09-21 21:25

data:application/octet-stream;base64,tAayRM0hskXNIbJTzSGyVc0hsiDNIevq

Name: Anonymous 2008-09-23 21:58

>>15
wtf is that and why won't firefox save it?

Name: Anonymous 2008-09-23 22:02

>>16
because firefox can't enter protected mode

Name: Anonymous 2008-09-24 0:17

ENTERPRISE PROTECTED MODE GENERAL DESCRIPTOR TABLE

Name: Anonymous 2008-09-24 7:28

B4 06 B2 44 CD 21 B2 45 CD 21 B2 53 CD 21 B2 55 CD 21 B2 20 CD 21 EB EA

Name: Anonymous 2008-09-24 7:32

>>15,19
DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU DESU

Name: Anonymous 2011-02-04 15:48

Name: Anonymous 2011-02-18 13:01

check 'em dubz

Don't change these.
Name: Email:
Entire Thread Thread List