Skip to content
Low-level programming · Higher-level thinking
Login Register
Forum / Requests and Feedback

using structure member inside if

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

Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

using structure member inside if

Hi Mr Colin.

i want ziron support this

#define	I386MAGIC      0x14c
#define I386AIXMAGIC   0x175

block filehdr
{
	word  f_magic;	   /* magic number             */
	word  f_nscns;     /* number of sections       */
	dword f_timdat;    /* time & date stamp	       */
	dword f_symptr;    /* file pointer to symtab   */
	dword f_nsyms;     /* number of symtab entries */
	word  f_opthdr;    /* sizeof(optional hdr)     */
	word  f_flags;     /* flags                    */
}

edi = @obj as filehdr;

if( (edi.f_magic!=I386MAGIC) and (edi.f_magic!=I386AIXMAGIC) )
{
  print('this is not obj file');
} 

also this wanted

  cmp word[edi.f_magic],I386MAGIC

http://www.freewebs.com/ogremagic/index.htm

Replies

Colin admin
Posts
928
Threads
49
Location
Bulgaria

not sure i understand this request, could you explain? what is var obj also?

0CodErr member
Posts
201
Threads
37
Location
Unknown

Maybe it was intended that it includes binary file into output file 'as is'? It would be useful i think :)

For example:

block FILEHDR {
 word  f_magic; 
 word  f_nscns; 
 dword f_timdat;
 dword f_symptr;
 dword f_nsyms; 
 word  f_opthdr;
 word  f_flags; 
}

FILEHDR MyFile = $incbin('myfile.obj'); 

Also it is possible to include not all file but only some part of it, like this:

FILEHDR MyFile = $incbin('myfile.obj', 0x100);        // includes data from file only from 0x100 offset 
FILEHDR MyFile = $incbin('myfile.obj', 0x100, 0x200); // includes 0x200 bytes from file from 0x100 offset 

For example we can directly include graphics by this way:

byte MyPicture[] = $incbin('mypicture.dat');
sysword PicSize = sizeof MyPicture; // get size of picture
Colin admin
Posts
928
Threads
49
Location
Bulgaria

Ziron 1 supported something similar, but I intended this features to be a plugin for Ziron 2, I will get around to writing a plugin to support this.