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

Not included in output file

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

0CodErr member
Posts
201
Threads
37
Location
Unknown

Not included in output file

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:

program RAW_IMAGE 'test';

#set bits 32;

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

Result:

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

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.

Replies

Colin admin
Posts
928
Threads
49
Location
Bulgaria

Variables are not written when not in use, you can override this by declaring the variable.

e.g.

program RAW_IMAGE 'test';

#set bits 32;

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

b1; w1; d1;

as for:

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.

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

// more code here.
0CodErr member
Posts
201
Threads
37
Location
Unknown

Ok, it works fine :)

program RAW_IMAGE 'test';

#set bits 32;

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

b1; w1; d1;
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:

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

eax = some_value;

will removed or not? I think that using each time disassembler not so good.

Colin admin
Posts
928
Threads
49
Location
Bulgaria

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)

0CodErr member
Posts
201
Threads
37
Location
Unknown
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:

program RAW_IMAGE 'test';
#set bits 32;
byte b1[] = 'HelloWord!';
b1;

And this error 'Unexpected symbol ]' occures:

program RAW_IMAGE 'test';
#set bits 32;
byte b1[] = 'HelloWord!';
b1[];
Colin admin
Posts
928
Threads
49
Location
Bulgaria

you would need a set size of the data since it is not constant...

e.g.

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"

0CodErr member
Posts
201
Threads
37
Location
Unknown
block ShortString {
   char text[255];
}

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

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

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.

Colin admin
Posts
928
Threads
49
Location
Bulgaria

I will look into the issue with ShortString sample, as for temporary solution:

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:

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