Page 1 of 1

[Solved]error C2415: improper operand type

Posted: Fri Jul 22, 2011 5:00 am
by melgmry0101b
Hi everyone, :D
I am compiling my OS in MSVC 2005.
Now i want to modify the value of Code Selector (CS) to fit my needs.
When i use this code in inline assembly in MSVC 2005 :

Code: Select all

mov ax, 0x33 ; the value that i want
mov cs, ax   ; moving the value to Code Selector < here is the error >
the error list in MSVC shows this error to me :

error C2415: improper operand type

and i read the documents of MSVC on MSDN , and it shows that i should use /G1 or /G2 in the command line.
I used it but i still get the error.

Can anyone help me to repair this problem?
------------------------------------------------------------------
Thanks in advance :D

Re: error C2415: improper operand type

Posted: Fri Jul 22, 2011 5:30 am
by gerryg400
You can't mov a value to cs. You must use a jmp, call, ret or iret instruction.

Re: error C2415: improper operand type

Posted: Fri Jul 22, 2011 5:51 am
by melgmry0101b
gerryg400 wrote:You can't mov a value to cs. You must use a jmp, call, ret or iret instruction.
How?

Re: error C2415: improper operand type

Posted: Fri Jul 22, 2011 5:52 am
by Combuster
This deserves no other reply than RTFM. Especially since you can't have done that properly in the time you posted the reply.

Re: error C2415: improper operand type

Posted: Fri Jul 22, 2011 12:48 pm
by Nessphoro

Code: Select all

jmp YourOffset:1 ; ex jmp ax:1 , or jmp 0x8:1
1:
   ret ;- or whatever 

Re: error C2415: improper operand type

Posted: Tue Jul 26, 2011 9:44 am
by melgmry0101b
Thank you Nessphoro :D