[Solved]error C2415: improper operand type

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
melgmry0101b
Member
Member
Posts: 109
Joined: Wed Nov 10, 2010 10:49 am

[Solved]error C2415: improper operand type

Post 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
Last edited by melgmry0101b on Tue Jul 26, 2011 9:49 am, edited 1 time in total.
gerryg400
Member
Member
Posts: 1801
Joined: Thu Mar 25, 2010 11:26 pm
Location: Melbourne, Australia

Re: error C2415: improper operand type

Post by gerryg400 »

You can't mov a value to cs. You must use a jmp, call, ret or iret instruction.
If a trainstation is where trains stop, what is a workstation ?
melgmry0101b
Member
Member
Posts: 109
Joined: Wed Nov 10, 2010 10:49 am

Re: error C2415: improper operand type

Post by melgmry0101b »

gerryg400 wrote:You can't mov a value to cs. You must use a jmp, call, ret or iret instruction.
How?
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: error C2415: improper operand type

Post 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.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
Nessphoro
Member
Member
Posts: 308
Joined: Sat Apr 30, 2011 12:50 am

Re: error C2415: improper operand type

Post by Nessphoro »

Code: Select all

jmp YourOffset:1 ; ex jmp ax:1 , or jmp 0x8:1
1:
   ret ;- or whatever 
melgmry0101b
Member
Member
Posts: 109
Joined: Wed Nov 10, 2010 10:49 am

Re: error C2415: improper operand type

Post by melgmry0101b »

Thank you Nessphoro :D
Post Reply