assembly language! please help me! thanks in advance!
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Get real, please.
You have multiple queries with the same subject and no details. What assembler? What CPU? Business or Pleasure?
Quote:
mov esi,OFFSET array+4
mov esi,array+4
In many assemblers, OFFSET would be taken as a variable. So your instruction would be seen as
mov esi $OFFSET
and array+4 on that line would produce a syntax error about an extra operand. I would expect every assembler I have used to barf on mov esi,array+4 as a syntax error.
Get real, please.
You have multiple queries with the same subject and no details. What assembler? What CPU? Business or Pleasure?
In many assemblers, OFFSET would be taken as a variable. So your instruction would be seen as
mov esi $OFFSET
and array+4 on that line would produce a syntax error about an extra operand. I would expect every assembler I have used to barf on mov esi,array+4 as a syntax error.
oh sorry! my assembler is nasm(intel syntax).and yours is GAS(AT&T syntax),right? for pleaseure.thanks
This is one of those quirky x86-isms. Its been a while since I've done any assembler coding there, but here goes. The OFFSET assembler directive tells the assembler to use the specified address as an OFFSET (duh..) for the start of the default segment. This is distinct from the actual address, since the segment may get loaded such that its segment register is not zero-based. It is one of those things that seems to have turned a lot of people off of the whole x86 family.
This is one of those quirky x86-isms. Its been a while since I've done any assembler coding there, but here goes. The OFFSET assembler directive tells the assembler to use the specified address as an OFFSET (duh..) for the start of the default segment. This is distinct from the actual address, since the segment may get loaded such that its segment register is not zero-based. It is one of those things that seems to have turned a lot of people off of the whole x86 family.
--- rod.
thanks,but i am not quite understand what you are saying,could you say it more in detail?thanks very much!
I might be able to, but it sounds like you lack some of the background knowledge to understand it. To write enough to build all of that would be beyond the scope of this forum. Do you understand the relationship between the segment registers, the pointer registers, and the linker in building assembly language object code? With a thorough understanding of these concepts, you should be able to understand my original answer. Having said that, in practical terms, there are few cases where the use of the OFFSET directive adds anything.
The OFFSET directive is only used in the Microsoft Assembler to disambiguate between specification of an address and the content of an address. Since you are using NASM, this is already done by the assembler enforcing the use of the [square_bracket] notation to specify an address content. Example:
Code:
mov esi, myLabel ; makes esi point to address 'myLabel'
; (but, in MASM, it might do like below)
mov esi, [myLabel] ; loads the word stored at ds:myLabel into register esi
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,339
Rep:
Quote:
Originally Posted by theNbomr
It is one of those things that seems to have turned a lot of people off of the whole x86 family.
--- rod.
But its still better then the backwards syntax and useless % of at&t syntax.
-
I could be wrong since ASM is not my specialty but I think that the second one copies the value and the first copies the offset of the segmentffset pair.
Last edited by smeezekitty; 03-19-2011 at 08:19 PM.
Reason: Stupid error on my part
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.