LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   what_where? (https://www.linuxquestions.org/questions/programming-9/what_where-505629/)

strycnine 11-28-2006 02:06 PM

what_where?
 
%include "io.mac"

.HEI
mesaj db 'Acest program va printa de la 1 la cat introduci tuh!', 0
bah db 'Baga in numar:', 0
mesaj_dupa db 'Ce vrei? Sunt incepator!', 0


.CODI
.SHTART
PutStr mesaj
nwln
PutStr bah
GetInt CX
mov AL, 0
nwln
de_aici:
inc AL
cmp CX, AL
mov BX, AL
jl scrie

jmp shtop

scrie:
PutInt BX
nwln
jmp de_aici

shtop:
PutStr mesaj_dupa
nwln
.EXIT

$ nasm -f elf prog.asm
$my_.asm:3: error: attempt to define a local label before any non-local labels

I don't get it, what I'm doing wrong?
New to assembly, want to learn asswmbly.
thx

cupubboy 11-28-2006 03:11 PM

Hey,

I almost forgot all my nasm theory .. but

labels are for example: "start" and local labels are ".start" as in local labels have a dot before them. There's probably a solid rule why you shouldn't have a local label before a label .. but I can't remember it. Bottom line is local labels help you to prevent naming conflicts; that's because you can use the same local lable name in a different part of your program as long as it is under a normal label - that is local lables are valid in one context (under one label) until the next (non local label)

for example:
Code:

start:
...
...
.somePoint
..
..
middle:
..
..
.somePoint
..
..

If somepoint was a non local lable you'd get a name conflict

I hope this was clear .. if it was not then it's probably because of my bad explanation .. let us know

Cheers

P.S: Why do you need .HEI or the next two labels to be local? (wich is obviously ilegal you need a non local label first)


All times are GMT -5. The time now is 07:58 PM.