Page 1 of 2
MASM can not support QWORD ?
Posted: Wed Jan 14, 2009 9:27 pm
by david
Code:
......
GDTR DQ 02000h
......
mov bx, offset cs:GDTR
lgdt qword ptr cs:[bx]
then I masm it
I:\SVN\OS\Loader>masm Loader.asm
Microsoft (R) MASM Compatibility Driver
Copyright (C) Microsoft Corp 1993. All rights reserved.
Invoking: ML.EXE /I. /Zm /c /Ta Loader.asm
Microsoft (R) Macro Assembler Version 6.11
Copyright (C) Microsoft Corp 1981-1993. All rights reserved.
Assembling: Loader.asm
Loader.asm(240): error A2024: invalid operand size for instruction
The error line is "lgdt qword ptr cs:[bx]".
I tried ml 8.0, It also has the error.
how to solve it ?
Re: MASM can not support QWORD ?
Posted: Wed Jan 14, 2009 9:32 pm
by Troy Martin
Try MASM32. And developing OSes is against the MASM license, by the way.
Re: MASM can not support QWORD ?
Posted: Wed Jan 14, 2009 9:35 pm
by david
I think each tool can develop OS.
I am also want to using GAS, but I don't use it before.
I have used MASM a year and half, I am good at it.
so..
Re: MASM can not support QWORD ?
Posted: Wed Jan 14, 2009 9:38 pm
by Troy Martin
Against license =/= inability
MASM and MASM32 license wrote:You cannot use the MASM32 Project to write software for Non-Microsoft Operating Systems.
An operating system you wrote is not an M$ operating system. Therefore, it is against the license.
Re: MASM can not support QWORD ?
Posted: Wed Jan 14, 2009 9:44 pm
by JohnnyTheDon
Have you tried:
I'm not sure if lgdt allows explicit segments, but I'm pretty sure it doesn't allow you to say the GDTR is a qword, since it isn't. Look at the wiki for GDT, it shows that the GDTR is 6 bytes (or 10 bytes for x64). You don't need a operand size prefix.
Re: MASM can not support QWORD ?
Posted: Wed Jan 14, 2009 9:54 pm
by david
to Troy Martin :
I don't care that.
my OS is just for fun, not for bussiness.
and my own os doesn't need to support MASM.
I just use it in windows.
Re: MASM can not support QWORD ?
Posted: Wed Jan 14, 2009 9:56 pm
by Troy Martin
david wrote:and my own os doesn't need to support MASM. I use it in windows.
/facepalm
That's not the point, the point is it's illegal to write an OS or stuff for another OS with MASM. Get NASM, it's got a similar syntax AND is portable.
Or FASM, which is written in assembly so it's even easier to port to an asm OS.
Re: MASM can not support QWORD ?
Posted: Wed Jan 14, 2009 10:00 pm
by david
to JohnnyTheDon :
I have tried it before.
Assembling: Loader.asm
Loader.asm(240): error A2023: instruction operand must have size
Re: MASM can not support QWORD ?
Posted: Wed Jan 14, 2009 10:08 pm
by JohnnyTheDon
try
Code: Select all
mov bx, cs
mov cx, ds
mov ds, bx
lgdt [ax]
mov ds, cx
That way you don't need cs: . lgdt implies ds, that may be your problem.
Do you really need to load the GDTR from a register? If this is start up code, why can't you just use the label of the GDT.
Re: MASM can not support QWORD ?
Posted: Wed Jan 14, 2009 10:23 pm
by david
Assembling: Loader.asm
Loader.asm(240): error A2031: must be index or base register
you can not use [AX],
we can only use [BX] [SI] [DI] [BP].
Re: MASM can not support QWORD ?
Posted: Wed Jan 14, 2009 10:25 pm
by JohnnyTheDon
okay, then just switch around the registers:
Code: Select all
mov ax, cs
mov cx, ds
mov ds, ax
lgdt [bx]
mov ds, cx
Use bx to hold the address of the GDTR.
Re: MASM can not support QWORD ?
Posted: Wed Jan 14, 2009 10:38 pm
by david
Assembling: Loader.asm
Loader.asm(240): error A2023: instruction operand must have size
Re: MASM can not support QWORD ?
Posted: Wed Jan 14, 2009 10:39 pm
by david
maybe I should read the book again.
Re: MASM can not support QWORD ?
Posted: Wed Jan 14, 2009 10:40 pm
by JohnnyTheDon
Just get NASM. It is easier, many tutorials use it, and it doesn't result in Microsoft taking all your money and internal organs.
Re: MASM can not support QWORD ?
Posted: Wed Jan 14, 2009 10:51 pm
by david
I used NASM a little before, but I am familiar with MASM more than NASM.
I guess microsoft uses MASM to develop Windows, they can do, I think I can do, but a little difficult.