Register | Login
Forum Index > Bugs and Fixes > Not included in output file
Author Message
Pages: 1 2
0CodErr
Ziron Guru
(send private message)

Posts: 199
Topics: 37

Location:
[1515] Not included in output file - posted: 2015-01-25 13:33:17

Code:
program RAW_IMAGE 'test';

#set bits 32;

byte  b1 = 0b1011;
word  w1 = 0b1011;
dword d1 = 0b1011;

Creates 0 bytes output file.

As for 'emit' seems works:
Code:
program RAW_IMAGE 'test';

#set bits 32;

emit byte  0b1011;
emit word  0b1011;
emit dword 0b1011;

Result:
Code:
00000000  0B0B              or ecx,[ebx]
00000002  000B              add [ebx],cl
00000004  0000              add [eax],al
00000006  00                db 0x00


Also similar 0 bytes effect with
Code:
program RAW_IMAGE 'test';

#set bits 32;

eax = eax; ax = ax; ah = ah; al = al;

May be this because some optimizations but this is assembler. And should be possible get what we write.
Admin
Site Admin

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[1520] - posted: 2015-01-25 17:20:33
Variables are not written when not in use, you can override this by declaring the variable.

e.g.

Code:
program RAW_IMAGE 'test';

#set bits 32;

byte b1 = 0b1011;
word w1 = 0b1011;
dword d1 = 0b1011;

b1; w1; d1;


as for:

Code:
eax = eax; ax = ax; ah = ah; al = al;


Again this is removed as it the instructions are useless, however I may add a directive to prevent optimising in such cases.


EDIT: OK, I have added a directive, but it is experimental.

Code:
#set optimise off;
eax = eax; ax = ax; ah = ah; al = al;
#set optimise on;

// more code here.


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:
[1521] - posted: 2015-01-25 18:46:07
Ok, it works fine smile
Code:
program RAW_IMAGE 'test';

#set bits 32;

byte b1 = 0b1011;
word w1 = 0b1011;
dword d1 = 0b1011;

b1; w1; d1;


Code:
eax = eax; ax = ax; ah = ah; al = al;

this is removed as it the instructions are useless

It seems for me that programmer better knows for what he needs such instructions. Are you really suggesting to remove all NOP's? How it possible to know for programmer which NOP's were removed?

For example:
Code:
dword some_value = 100500;

eax = some_value;
ebx++; -ecx; ~edx;
eax = some_value;
ebx++; -ecx; ~edx;
eax = some_value;
ebx++; -ecx; ~edx;

Whether last 2 lines of Code:
eax = some_value;
will removed or not? I think that using each time disassembler not so good.
Admin
Site Admin

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[1522] - posted: 2015-01-25 19:37:02
No, I have not went as far as complete optimization of such things.

But things like alignment should be done in a way that keeps the code readable and for a high level assembler, this should be in some way automated or via a separate syntax. This makes it easier for newbies to learn and understand what is really going on in the source. (keeping it readable)

But it is understandable to use such things, in which case with new release you can disable optimisations.

(which actually, you have give me a good idea for a new feature, thanks)

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:
[1555] - posted: 2015-01-30 17:50:59
Variables are not written when not in use, you can override this by declaring the variable.
And how about data arrays?

For example this outputs only 1 byte:
Code:
program RAW_IMAGE 'test';
#set bits 32;
byte b1[] = 'HelloWord!';
b1;


And this error 'Unexpected symbol ]' occures:
Code:
program RAW_IMAGE 'test';
#set bits 32;
byte b1[] = 'HelloWord!';
b1[];
Admin
Site Admin

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[1556] - posted: 2015-01-30 22:46:36
you would need a set size of the data since it is not constant...

e.g.

Code:
block ShortString {
   char text[255];
}

ShortString b1[] = ['Hello World!', 'Etc'];
b1;


 // or...

byte b1[] = ['H','e','l','l','o'];
b1;


but, maybe I will add this to my list to allow assigning string to array to separate into "parts"

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:
[1559] - posted: 2015-01-30 23:07:30
Code:
block ShortString {
   char text[255];
}

ShortString b1[] = ['Hello World!', 'Etc'];
b1;

Are you tried to compile this? I have very strange result smile

Code:
byte b1[] = ['H','e','l','l','o'];
b1;

As for second variant it is not so convenient to split the string into single characters. String may be not so short.
Admin
Site Admin

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[1564] - posted: 2015-01-31 00:43:29
I will look into the issue with ShortString sample, as for temporary solution:

Code:
inline procedure DeclareByteArray($b, $t) {
  $out = '';  
  $len = sizeof $t - 1;
  
  $i = 1;
  
  $repeat $len:
    $c = $substr($t, $i, 1);
    
    $out = $strcat($out, '\'');
    $out = $strcat($out, $c);
    $out = $strcat($out, '\'');
    
    $if $i < $len:
      $out = $strcat($out, ',');
    $end;
      
    $i = $i + 1;
  $end;
  
  // I need to improve strcat functionality....
  $code = 'byte ';
  $code = $strcat($code, tokentext($b));
  $code = $strcat($code, '[] = [');
  $code = $strcat($code, $out);
  $code = $strcat($code, '];');
  
  $eval($code);
}


then your code:

Code:
DeclareByteArray(b1, 'Hello World!');
b1;


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


Quick reply:

Message:



Currently Active Users:
There are currently 6 user(s) online. 0 member(s) and 6 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