Code Comments
Programming Forum and web based access to our favorite programming groups.On Mar 26, 6:49_am, "Rod Pemberton" <spamt...@crayne.org> wrote: > "junkoi" <spamt...@crayne.org> wrote in message > > news:94d18289-183c-4a52-9770-48fa230d2943@i12g2000prf.googlegroups.com... > > > > > > > > > I don't think it's critical, but I'm assuming the var is in a ".data" > section. > > Yes, they are functionally equivalent. _"movl var,ecx" will mov the value at > var's address into ecx, i.e., 0xf1234. _If you wanted to mov the address o f > var into ecx [like another responder claimed you were doing...], that'd be > "movl $var,ecx". > > Are you linking the .o file? _If not, a zero (0) value placeholder for the > memory address will be in the .o code for "movl var, %ecx". _The placehold er > is not filled in with the address of var until linked using "ld". _Then, t he > code should be functionally equivalent. _Is this the problem? _Typically, ld > is used like this, after assembled with AS or GCC: > > _ ld --oformat binary --Ttext 0x7C00 -o mybootcode.bin mybootcode.o > > Although very unlikely, you might need to adjust the address size or > segment: > > _ addr32 movl var, %ecx > _ movl %es:var, %ecx > > You can use these for mixed code: > > .code16gcc > .code16 > .code32 > .code64 > .data > .text > .att_syntax > .intel_syntax > data16 _- operand size override > data32 _- operand size override > addr16 _- address size override > addr32 _- address size override > > Let us know... > > Rod Pemberton Thank you, Rod. Your post gave me some hints, and I solved my problem. Actually I want to move the value of "var" to %ecx, not its address. And "var" is in .code section, not .data. So I fixed my code with: movl %cs:var, %ecx // i.e movl $0xf1234, %ecx and it works now, as expected. Thanks a lot, folks! Best, J
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.