News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

EIP register - Newbie question

Started by PeterRod, September 22, 2008, 01:38:00 AM

Previous topic - Next topic

PeterRod

I am reading a text by K P Irvine in which he states that the EIP register cannot be a destination operand in a MOV instruction.
Implying that it can be the source operand.

However when I try any MOV instruction with eip it fails.
Mov eax,eip    ; this fails.   The assembler doesnt recognize eip as a register! It thinks its an undefined symbol!

can the contents of eip be moved to another register?

Sorry for this basic question!! .... but I need to know

BogdanOntanu

Quote from: PeterRod on September 22, 2008, 01:38:00 AM
I am reading a text by K P Irvine in which he states that the EIP register cannot be a destination operand in a MOV instruction.
Implying that it can be the source operand.

I can not believe  that the author states this "implying" stuff above.
Honestly it is more likely that you have made this up in your mind as "wishful thinking" or speculation.

Quote
However when I try any MOV instruction with eip it fails.
Mov eax,eip    ; this fails.   The assembler doesnt recognize eip as a register! It thinks its an undefined symbol!

That is correct because there is no such instruction.

One can speculate that a "JMP target_of_jump" instruction is somehow a  kind of "MOV EIP,target_of_jump" instruction.

Quote
can the contents of eip be moved to another register?

NO, at least not directly.
However there are many indirect ways to do this.
Why do you need to do this?

Quote
Sorry for this basic question!! .... but I need to know

Basic newbie questions should be placed in "The Campus" sub-forum but otherwise they are OK, there is no need to be sorry for this.

However "I need to know" kind of statement is not a good enough motive for obtaining an answer. Impatience does not help either.
Ambition is a lame excuse for the ones not brave enough to be lazy.
http://www.oby.ro

hutch--

Peter,

The EIP register is the instruction pointer so its not in the simple sense and ordinary register. In 32 bit you modify the instruction pointer by either a jump or a call which changes the IP to a new location. The CALL mnemonic also stores the return address to return to after the next RET.

64 bit hardware has the RIP register, (64 bit version of EIP) which has additional capacity to the 32 bit version but you would need to look p the Intel x64 instructions to see what it can do.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

PeterRod

Thanks for the quick replies.
Just to clear the air.
I am trying to teach myself ASM with the Irvine textbook using MASM via Visual Studio 2005 editor/debugger/assembler/linker.

So when I run into questions that I cannot find an answer for I usually come to this forum.

I really didnt expect such harsh words from BogdanOntanu.

Thank you Hutch for your kinder explanation

Regards
Peter

jj2007

#4
Peter,
Here is a little app that does the job.

Edit: Replaced chr$("Title") by addr AppName

include \masm32\include\masm32rt.inc

.code
AppName db "Getting EIP:", 0


start:

; int 3 ; in case you want to watch it in a debugger

mov eax, $
invoke MessageBox, 0, hex$(eax), addr AppName, MB_OK
exit

end start



Quote from: PeterRod on September 22, 2008, 02:12:57 AM
I really didnt expect such harsh words from BogdanOntanu.

Everybody here in the Forum expects such harsh words from Bogdan :green
Once he has understood that you are not a kid trying to get your homework done by others, he can give quite reasonable advice.

hutch--

Pete,

Bogdan's answer was a bit more technical than my own but its part of the advantage of having a range of people to answer a question. You get multiple answers that at times see the question in different ways. It just happened to be that we posted at the same time.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

PeterRod

Thanks jj and Hutch.
Well that little puzzle is solved. <...until the next one comes along.>
Guess I should do some reading on MASM directives/symbols/operators.
Regards
Peter

P1

Quote from: PeterRod on September 22, 2008, 02:12:57 AMI am trying to teach myself ASM with the Irvine textbook using MASM via Visual Studio 2005 editor/debugger/assembler/linker.

So when I run into questions that I cannot find an answer for I usually come to this forum.

I really didnt expect such harsh words from BogdanOntanu.
We help programmers help themselves.  Sometimes it seems, just because a programmer goes into "new" area of programming, that the skills learn from the last language, simply goes into the "noob" bucket of it does not matter.

You would save a bunch of time in properly using help documentation and the search functions on this board.

Should I even dare say "search engine" and ask where you got the skills to use that from?

Quote from: CampusA protected forum where programmers learning assembler can ask questions in a sensible and safe atmosphere without being harassed or insulted. This is also targetted at experienced programmers from other languages learning assembler that don't want to be treated like kids. Note that 16 bit code or questions will be moved to the 16 bit forum.

You should have posted in Campus by the recommendations of this board.  Have you read them yet?

What is "harsh", is the criticism of the help you received.  It appears that there was little appreciation of the free instruction you received from your post.

Be a real programmer and stick to the coding/learning issues that you have.  We are not paid here.  If we were paid instructors, they don't put up with poor learning skills in their classrooms.   Criticise a paid instructor and see what you get in the classroom, it shows lack of respect.

Regards,  P1   :8)