Author Topic: Please tell me how to use "LGDT"  (Read 11870 times)

nobody

  • Guest
Please tell me how to use "LGDT"
« on: April 13, 2006, 01:35:20 AM »
Hi.

Please tell me how to use "lgdt".

I wrote a progoram below.

......................
    ......................
    lgdt    gdtr
    ......................
    ......................
gdtr
    dw      2048 - 1
    dd      gdt
    ......................
    ......................

Running nasm gave me the message,

"os.asm:47: error: invalid combination of opcode and operands"

I rewrote my program,

lgdt    [gdtr]

and I got no error message this time, but why ?

nobody

  • Guest
Re: Please tell me how to use "LGDT"
« Reply #1 on: April 13, 2006, 02:47:50 PM »
Ummm, 'cause that's the correct syntax?

"LGDT" (and "LIDT") take a "mem" operand (not "imm"). In Nasm's syntax, "[foo]" is a memory operand, "foo" is a plain immediate number. Same idea as:

mov [foo], eax ; okay
mov foo, eax ; BZZZT!

Now, as to the contents of that memory area... best consult the Intel/AMD manual... or perhaps you already know that...

Best,
Frank

Shiozaki Tetsurou

  • Guest
Re: Please tell me how to use "LGDT"
« Reply #2 on: April 13, 2006, 11:56:49 PM »
Dear Frank

Thank you for your answer.
Well...."'cause that is the correct syntax"...

Yes, I know that from the reference manual of
Intel.But I feel "LGDT [GDTR]" that's a little bit of strange....

Any way thank you very much.

Shiozaki Tetsurou