Register | Login
Forum Index > Bugs and Fixes > global variable redeclared
Author Message
Pages: 1 2 3
0CodErr
Ziron Guru
(send private message)

Posts: 199
Topics: 37

Location:
[1679] - posted: 2015-02-12 20:10:10
It would be better to do it automatically. Now using $labelref() similar to using $_uniquelabel.
I tried to compare $labelref() and $_uniquelabel
Code:
program RAW_IMAGE 'test';

#set bits 32;

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

Test_labels1();
Test_labels1();


inline procedure Test_labels2() {  
  $l1 = $_uniquelabel;
  eax = $l1; 
$_e($l1):  
}

Test_labels2();
Test_labels2();

Result:
Code:
00000000  B805000000        mov eax,0x5
00000005  B80A000000        mov eax,0xa
0000000A  B814000000        mov eax,0x14
0000000F  B81D000000        mov eax,0x1d
00000014  5F                pop edi
00000015  5F                pop edi
00000016  5F                pop edi
00000017  305F5F            xor [edi+0x5f],bl
0000001A  5F                pop edi
0000001B  3000              xor [eax],al
0000001D  5F                pop edi
0000001E  5F                pop edi
0000001F  5F                pop edi
00000020  315F5F            xor [edi+0x5f],ebx
00000023  5F                pop edi
00000024  3000              xor [eax],al
Admin
Site Admin

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[1681] - posted: 2015-02-12 20:43:01
The reason for this is because macro variables can not automatically initialized as a label else it would cause many problems later, not to mention will make it difficult in some cases especially if making a mistake.

e.g.

Code:
inline procedure ABC($asal) {
  eax = $asai;
 
  $return eax;
}


Here we have a typo which will go unnoticed because asai will automatically become a label (as a macro variable)

The other difference is $_uniquelabel returns a unique string name as a label whereas $labelref creates an entry into the label manager.

So in your case using labelref you will need to write eax = @$l1;

Code:
eax = $label; // eax is the offset of the label

eax = @$label; // eax is the absolute address


Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message.
0CodErr
Ziron Guru
(send private message)

Posts: 199
Topics: 37

Location:
[1690] - posted: 2015-02-13 18:38:23
The other difference is $_uniquelabel returns a unique string name as a label whereas $labelref creates an entry into the label manager.

Maybe it also is problem?
Code:
program RAW_IMAGE 'test';

#set bits 32;

  $l1 = $_uniquelabel;
  $l2 = $_uniquelabel;  
  
___1___0:  
$_e($l1):
$_e($l2):  

Cannot compile because
Reserved label
Admin
Site Admin

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[1691] - posted: 2015-02-13 20:18:44
This is not a problem, since this is a programmer purposely looking to break the compiler smile anyways in this case it will be better to use $labelref.

Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message.
Pages: 1 2 3
create new reply


Quick reply:

Message:



Currently Active Users:
There are currently 13 user(s) online. 0 member(s) and 13 guest(s)
Most users ever online was 1046, January 28, 2022, 2:08 pm.


Statistics:
Threads: 225 | Posts: 1848 | Members: 51 | Active Members: 51
Welcome to our newest member, yecate
const Copyright = '2011-2024 © OverHertz Ltd. All rights reserved.';
Web development by OverHertz Ltd