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


|