Skip to content
Low-level programming · Higher-level thinking
Login Register
Forum / Bugs and Fixes

global variable redeclared

A community discussion post from the original code:zIRON forum.

Replies

0CodErr member
Posts
201
Threads
37
Location
Unknown

Could you also make this for labels?

program RAW_IMAGE 'test';

#set bits 32;

inline function SomeInlineFunction1() {
SomeInlineFunction2();
next:
}

inline function SomeInlineFunction2() {
next:
}

SomeInlineFunction1();
next:
Colin admin
Posts
928
Threads
49
Location
Bulgaria

Macros must allow placing already used label since it is an inline piece of code.

If you want to create unique labels, you must use the macro function $uniquelabel. Please check ziron.zir under emacro try() { ...

It has a good example of unique labels.

0CodErr member
Posts
201
Threads
37
Location
Unknown
If you want to create unique labels, you must use the macro function $uniquelabel.

I actually want specific label but not only unique.

For better explanation i mean macro-local labels like in NASM.

I think that it way will make code more easy to understand and readable. Instead of write like:

$exceptlbl = $_uniquelabel; 
$_e($exceptlbl):
Colin admin
Posts
928
Threads
49
Location
Bulgaria

OK, I will add this to my todo list. Thanks.

0CodErr member
Posts
201
Threads
37
Location
Unknown

Actually $_uniquelabel not so unique :)

Because it is possible to write:

program RAW_IMAGE 'test';

#set bits 32;

const REP_COUNT = 1024*16;

___7777___0:

$repeat REP_COUNT: 
  $a = $_uniquelabel; 
  $_e($a): 
$end

And after that we get error:

Reserved label ___7777___0

In our documentation nothing about that. It would be better if there will written about format such labels to prevent use them.

Colin admin
Posts
928
Threads
49
Location
Bulgaria

I've fixed issue with unique label and I have made it possible to declare global variables locally.

I have also added localized macro labels:

$mylabel:
	nop
goto $mylabel
0CodErr member
Posts
201
Threads
37
Location
Unknown
I have also added localized macro labels

Cannot compile:

program RAW_IMAGE 'test';

#set bits 32;

inline procedure Test_labels() {  
  eax = $l1; 
$l1:  
}

$repeat 64:
  Test_labels();
$end
Unexpected symbol $
Colin admin
Posts
928
Threads
49
Location
Bulgaria

I have added new function $labelref() for next release which allows macros to have forward declaration labels.

e.g.

inline procedure Test_labels() {  
	$l1 = $labelref();

	eax = $l1; 
$l1:  
}