Protected Mode

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
Philip
Member
Member
Posts: 59
Joined: Thu Mar 06, 2008 11:37 pm
Location: Singapore

Protected Mode

Post by Philip »

A part of my code is like this:

mov eax,cr0
or eax,1
mov cr0,eax
jmp far ptr pm

pm:

but my masm 5.1 say that cr0 is undefined symbol
what's the meaning of this error message?
how can i access cr0?
pls help :?
User avatar
zaleschiemilgabriel
Member
Member
Posts: 232
Joined: Mon Feb 04, 2008 3:58 am

Post by zaleschiemilgabriel »

MASM 5.1 does not support the latest Intel Instruction set (I'm not even sure it supports 32 bit instructions). Either try using a newer MASM version or a different assembler.
I'd recommend one of these: FASM, NASM, MASM32...
DeviOuS - what a stupid name
User avatar
nekros
Member
Member
Posts: 391
Joined: Wed Mar 05, 2008 9:10 pm
Contact:

Post by nekros »

For pure ASM use FASM
For ASM and C use fasm or GAS.

MASM: ONLY for windows, I suggest not to.
User avatar
Philip
Member
Member
Posts: 59
Joined: Thu Mar 06, 2008 11:37 pm
Location: Singapore

Post by Philip »

masm 5.1 supports 32-bit register like eax,ebx,esi,edi, etc.
the directive to turn it on is ".386" and to put use16 after each segment declaration

only the control registers like cr0, cr1, etc are stated as:

Error: Symbol not define: CRO

who know why pls help me......... :?
User avatar
zaleschiemilgabriel
Member
Member
Posts: 232
Joined: Mon Feb 04, 2008 3:58 am

Post by zaleschiemilgabriel »

First, MASM 5.1 is old, dude! Get over it!

Second, the fact that you have segment declarations is kind of disturbing.
I hope you're not trying to compile that piece of code as a PE or MZ executable. :)

You don't even know how many ways you're making me want to insult you right now! I wrote about 10-20 swears/curses/insults/bad words that I erased and put this instead, but a psychologist (or a moderator) would say that's bad for my health, so please stop making me sick!
DeviOuS - what a stupid name
User avatar
Philip
Member
Member
Posts: 59
Joined: Thu Mar 06, 2008 11:37 pm
Location: Singapore

Post by Philip »

i found it out already

.386 directive does not allow access to control registers

but .386p directive allows

that was the reason
User avatar
zaleschiemilgabriel
Member
Member
Posts: 232
Joined: Mon Feb 04, 2008 3:58 am

Post by zaleschiemilgabriel »

Then that error message was not very informative, and it support what I've been trying to say: throw out MASM and get FASM or one of the others that were mentioned. You won't regret it, trust me. If you're just starting out OSDeving, do it now, before it's too late. :roll:
DeviOuS - what a stupid name
cyr1x
Member
Member
Posts: 207
Joined: Tue Aug 21, 2007 1:41 am
Location: Germany

Post by cyr1x »

Doesn't Microsoft disallow non-Windows executables created with MASM anyway?
User avatar
Philip
Member
Member
Posts: 59
Joined: Thu Mar 06, 2008 11:37 pm
Location: Singapore

Post by Philip »

this is my very simple code for switching to protected mode
Attachments
PMODE.ASM
(1.08 KiB) Downloaded 85 times
User avatar
nekros
Member
Member
Posts: 391
Joined: Wed Mar 05, 2008 9:10 pm
Contact:

Post by nekros »

Really, you shouldn't use masm.
User avatar
Philip
Member
Member
Posts: 59
Joined: Thu Mar 06, 2008 11:37 pm
Location: Singapore

Post by Philip »

i just use it to build the core of my os only
i plan to build my own assembler to run on my os
Post Reply