Register | Login
Forum Index > Source Help > porting op macro to ziron2
Author Message
Pages: 1 2
Emil_halim
Ziron Beta Tester

avatar

(send private message)

Posts: 639
Topics: 104

Location:
Alex, Egypt
[1420] porting op macro to ziron2 - posted: 2014-12-05 11:17:34

as the title says , how to port this op macro to ziron 2

Code:
//sample of implementing the opcode or
//todo reg1:REGISTER
inline op procedure _or($reg1, $reg2) { 
  $expect sizeof $reg1 as sizeof $reg2: 'Operands must be equal size';

  $if sizeof $reg1 == 32:
    blob 1,0x0B 1,0xC0 + (($reg1*8)+$reg2); 
  $elseif sizeof $reg1 == 16:
    blob 1,0x66 1,0x0B 1,0xC0+(($reg1*8)+$reg2);
  $else
    blob 1,0x0A 1,0xC0+(($reg1*8)+$reg2);
  $end
}


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

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[1421] - posted: 2014-12-06 16:49:54
Hi Emil,

blob is no longer supported, I am currently porting the emit plugin, and will get back to you soon with a new beta release.

Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message.
Emil_halim
Ziron Beta Tester

avatar

(send private message)

Posts: 639
Topics: 104

Location:
Alex, Egypt
[1426] - posted: 2014-12-08 13:04:28

okay , with new emit plugin we can emit to exe buffer, but what about other macros in the above example?

http://www.freewebs.com/ogremagic/index.htm
Emil_halim
Ziron Beta Tester

avatar

(send private message)

Posts: 639
Topics: 104

Location:
Alex, Egypt
[1427] - posted: 2014-12-08 19:22:19

BTW , where are those symbols defined

Code:
 IDENT_TYPE
 TOKEN_NUMBER 
 TOKEN_FLOAT
 ....
 .... 


also could you please explain the plugin functions by examples.

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

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[1428] - posted: 2014-12-09 03:09:25
Hi Emil

The definitions can be found in ziron.zir

As for op macros, they're still supported, but ideally, better to use the plugin system.

I am in progress of upgrading the plugin and macro system, once done I will be making some examples, and hopefully start updating the documentation.

Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message.
Emil_halim
Ziron Beta Tester

avatar

(send private message)

Posts: 639
Topics: 104

Location:
Alex, Egypt
[1429] - posted: 2014-12-09 19:34:04

i think there was a bug in op macro

try this

Code:
//sample of implementing the opcode or
//todo reg1:REGISTER
inline op procedure _or($reg1, $reg2) { 
  $expect sizeof $reg1 as sizeof $reg2: 'Operands must be equal size';

  $if sizeof $reg1 == 32:
    emit 1,0x0B 1,0xC0 + (($reg1*8)+$reg2); 
  $elseif sizeof $reg1 == 16:
    emit 1,0x66 1,0x0B 1,0xC0+(($reg1*8)+$reg2);
  $else
    emit 1,0x0A 1,0xC0+(($reg1*8)+$reg2);
  $end
}


 _or eax,eax


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

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[1430] - posted: 2014-12-10 22:23:39
Hi Emil,

I have just finished fixing a bug with the plugin system. Please re-download the beta:

Download Here

$expect is no longer supported (for now), however you can easily implement this through a macro or plugin.

Ported version:

Code:
inline op procedure _or($reg1, $reg2) { 
  $if sizeof $reg1 != sizeof $reg2:
    $raise 'Operands must be equal size';
  $end;

  $rp = 0xC0 + ((ord($reg1)*8)+ord($reg2));
  $if sizeof $reg1 == 4:
    emit byte 0x0B, $rp;
  $elseif sizeof $reg1 == 2:
    emit byte 0x66,0x0B, $rp;
  $else
    emit byte 0x0A, $rp;
  $end;
}


_or edx, ecx;


creating an expect equal macro:

Code:
inline procedure expectEqual($p1, $p2, $err) {
  $if $p1 != $p2:
    $raise $err;
  $end
}


usage:

Code:
  expectEqual(sizeof $reg1, sizeof $reg2, 'Operands must be equal size');


Using $If is more logically and easier for programmers to understand.

Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message.
Emil_halim
Ziron Beta Tester

avatar

(send private message)

Posts: 639
Topics: 104

Location:
Alex, Egypt
[1431] - posted: 2014-12-11 20:11:32

nice work Mr. Colin,

actually , i did net like $expect in old Ziron ,and agree with you $if is much better.

i have another question , in old plugin we used FileEntry to pares the buffer of code and
change it as we need , so how we can make that with new Ziron.

for example , see this
Code:
procedure FileEntry(DWord handle; char* strCode) {
  
     uses edi;
     eax = strOffset(strCode, '#define');
     while (char[eax] <> 0) {
            char[eax] = "_";
            eax = strOffset(eax, '#define');
     }
    
}


http://www.freewebs.com/ogremagic/index.htm
Pages: 1 2
create new reply


Quick reply:

Message:



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