Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Assembly x86 > Re: Nasm labels
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 7 of 9 Topic 4567 of 4729
Post > Topic >>

Re: Nasm labels

by syl <spamtrap@[EMAIL PROTECTED] > Mar 12, 2008 at 04:19 PM

On 12 mar, 20:26, Frank Kotler  <spamt...@[EMAIL PROTECTED]
> wrote:
> syl wrote:
> > hello guys.
>
> > I'm using nasm and I've got a strange problems with labels.
> > I do this code and compile it with nasm -f code.S :
>
> > [BITS 16]
> > global  print
> > global  foreverloop
>
> > print:
> >         push    ax
> >         push    bx
> >         jmp     .toto
> > .toto:
> >         loadsb
> >         cmp     al, 0
> >         jz      .end
> >         mov     ah, 0x0e
> >         mov     bh, 0x00
> >         mov     bl, 0xa7
> >         int     0x10
> >         jmp     .toto
> > .end:
> >         pop     bx
> >         pop     ax
> >         ret
>
> > But during the assembling I've got this errors :
>
> > UTIL.S:22: error: symbol `.toto' undefined
> > UTIL.S:31: error: phase error detected at end of assembly.
>
> > But for me the label .toto is defined. Do you know why I've
> > got this errors?
>
> Whoop! This is a gem! Sorry... I'm not laughing at you, but I'm
laughing!!!
>
> Nasm's "local" labels have a "scope" from the previous "non-local" label
> to the next. This can be a "maintainance" problem... if you introduce a
> new non-local label between previously-working local labels... boom!
>
> Nasm versions 0.98.xx do not require a colon on labels. A "supperrsible
> warning" existed "label alone on a line without a colon might be in
> error". By default, however, this warning was off - "-w+orphan-labels"
> turned it on. Latest versions of Nasm have this warning "on" by default.
> (this convinces me that this was a correct decision, even if Nasm
> belches a lot of warnings on existing code - Nasm assembles it, it just
> "warns" a lot)
>
> Nasm doesn't "force" you to use colons on labels, but the new versions
> "encourage" it. This serves as a sort of "spell checker" for mnemonics
> with no operands, which Nasm otherwise thinks is a label... such as
> "loadsb"! Make that "lodsb", and your code will assemble. I'm still
> chuckling...
>
> Actually, if you'd used non-local labels, Nasm would have assembled it
> without complaint, but it wouldn't have worked, because the intended
> "lodsb" wouldn't have been there. Probably a harder-to-find bug.
>
> This may be a "good reason" to upgrade to latest Nasm (2.02 and
> growing), even if you don't need the 64-bit stuff...
>
> http://nasm.sf.net
>
> Best,
> Frank

Thanks for the help.
I am very confused by my mistake.
I promise that next time I would must read 100 times
my code before posting bad stuff like that :)

--

Gallon sylvestre
Astek méchant / Assistant Cisco
Rathaxes Core Developper / LSE researcher
kernel developer for adeneo and OpenBSD fan
http://devsyl.blogspot.com/
| www.rathaxes.eu
 




 9 Posts in Topic:
Nasm labels
syl <spamtrap@[EMAIL   2008-03-12 06:43:24 
Re: Nasm labels
Frank Kotler <spamtra  2008-03-12 19:26:14 
Re: Nasm labels
"Maarten Kronenburg&  2008-03-12 19:39:15 
Re: Nasm labels
Alex Buell <spamtrap@  2008-03-12 20:07:04 
Re: [Clax86list] Nasm labels
Charles Crayne <spamt  2008-03-12 15:10:57 
Re: Nasm labels
"Maarten Kronenburg&  2008-03-12 22:50:06 
Re: Nasm labels
syl <spamtrap@[EMAIL   2008-03-12 16:19:33 
Re: Nasm labels
Frank Kotler <spamtra  2008-03-13 02:39:25 
Re: [Clax86list] Nasm labels
Charles Crayne <spamt  2008-03-13 14:00:01 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Jul 25 14:45:20 CDT 2008.