Author |
Message
|
Emil_halim Ziron Beta Tester
(send private message)
Posts: 639 Topics: 104
Location: Alex, Egypt | [418] get entire line - posted: 2011-11-07 11:07:24 Hi
sometimes i need get the entire current line before i will pares it so i made this
function but it does not work.
Code:function GetFullLine()
{
global char line[2048];
H_strcpy(@line,Ziron_GetStringValue());
eax = Ziron_IsNextLineBreak();
while(eax)
{
eax = Ziron_PeekNextToken();
eax = Ziron_GetStringValue();
H_strjoin(@line,eax,' ');
eax = Ziron_IsNextLineBreak();
}
eax = @line;
}
any suggestion please.
http://www.freewebs.com/ogremagic/index.htm |
Emil_halim Ziron Beta Tester
(send private message)
Posts: 639 Topics: 104
Location: Alex, Egypt | [419] - posted: 2011-11-07 12:53:56
i have made this , but if i want to pares from start as usual , i think you can add
a push/pop function to save the current position of compilation.
Code:function GetFullLine()
{
global char line[2048];
H_strcpy(@line,Ziron_GetStringValue());
H_strcat(@line,' ');
eax = Ziron_IsNextLineBreak();
while(!eax)
{
//eax = Ziron_PeekNextToken();
eax = Ziron_getNextToken();
eax = Ziron_GetStringValue();
H_strjoin(@line,eax,' ');
eax = Ziron_IsNextLineBreak();
}
eax = @line;
}
http://www.freewebs.com/ogremagic/index.htm |
Emil_halim Ziron Beta Tester
(send private message)
Posts: 639 Topics: 104
Location: Alex, Egypt | [420] - posted: 2011-11-07 13:22:26
get access violation with this plugin
Code://******************************************************//
// //
// Mov Plugin //
// //
// By Emil Halim //
// 7 / 11 / 2011 //
// //
//******************************************************//
program WIN32DLL 'Mov PLUGIN';
#include 'zirplug/framework.zir';
//////////////////////////////
const strLoaded = 'Mov plugin has loaded!';
//////////////////////////////
function H_strlen(char* str)
{
Eax = nil;
Ebx = str;
while(char[Ebx] != 0)
{
Ebx++;
Eax++;
}
}
function H_strcpy(Dword dst,src)
{
Eax = dst;
Edx = src;
push Eax;
BL = [Edx];
while ( BL != 0)
{
[Eax] = BL;
Eax++; Edx++;
BL = [Edx];
}
[Eax] = 0;
pop Eax;
}
function H_strcat(Dword dst,src)
{
Eax = dst;
Edx = src;
push Eax;
while (byte [Eax] != 0) { Eax++; }
while (byte [Edx] != 0)
{
BL = [Edx];
[Eax] = BL;
Edx++; Eax++;
}
[Eax] = 0;
pop Eax;
}
inline procedure H_strjoin(;)
{
$temp = 1;
$to = $argc - 1;
$repeat $to:
H_strcat($arg[0],$arg[$temp]);
$temp++;
$end
}
inline procedure Ziron_ExecuteF(m_st)
{
Ziron_Execute($m_st,H_strlen($m_st));
}
function GetFullLine()
{
global char line[2048];
H_strcpy(@line,Ziron_GetStringValue());
H_strcat(@line,' ');
eax = Ziron_IsNextLineBreak();
while(!eax)
{
//eax = Ziron_PeekNextToken();
eax = Ziron_getNextToken();
eax = Ziron_GetStringValue();
H_strjoin(@line,eax,' ');
eax = Ziron_IsNextLineBreak();
}
H_strcat(@line,';');
eax = @line;
}
//
// event_mov()
// return false to allow the assembler to process this keyword internally.
// return true to tell the assembler this keyword has been processed.
//
function event_mov() {
uses edi;
char buf[2048];
Dword Len;
pointer pt;
pt = GetFullLine();
Ziron_ShowMessage(pt);
Len = H_strlen(pt);
eax = Ziron_Execute(pt,Len);
if (eax == false) {
Ziron_FatalError('Dim plugin is not compatible with this version of Ziron');
return true;
}
return true;
}
function InitPlugin(pointer pGetF) {
Ziron_LoadAll(pGetF); //use framework utility function to load all
//register our keyword
Ziron_RegisterKeyword('mov', @event_mov);
return strLoaded;
}
entry function DLLMain(DWord iDLL; DWord iReason; Pointer iResult) {
if (iReason == DLL_PROCESS_ATTACH) {
return true;
}
return false;
}
exports InitPlugin;
and here the test program
Code:program WIN32CUI 'mov plugin test';
#include 'console.zir';
mov eax,10;
print('eax = ', eax:int, '\r\n');
wait_key(nil);
ExitProcess(0);
http://www.freewebs.com/ogremagic/index.htm |
Emil_halim Ziron Beta Tester
(send private message)
Posts: 639 Topics: 104
Location: Alex, Egypt | [421] - posted: 2011-11-07 13:55:57
i got this strange output from this function
Code:function event_mov() {
uses edi;
char buf[2048];
Dword Len;
pointer pt;
pt = GetFullLine();
Ziron_ShowMessage(pt);
return true;
}
results
“ |
Ziron Compiler 1.1.27.5
Copyright (C) 2011. OverHertz Ltd. All rights reserved.
PlugSys: Emit plugin has loaded!
PlugSys: Mov plugin has loaded!
PlugSys: mov eax , value
PlugSys: mov edi , lpBuffer
PlugSys: mov [expression] , 30
PlugSys: mov [expression] , -
PlugSys: mov ecx , 3435973837
PlugSys: mov esi , edi
PlugSys: mov ebx , eax
PlugSys: mov eax , edx
PlugSys: mov [expression] , bl
PlugSys: mov [expression] , 0
PlugSys: mov al , [expression]
PlugSys: mov ah , [expression]
PlugSys: mov [expression] , al
PlugSys: mov [expression] , ah
PlugSys: mov eax , 0
PlugSys: mov eax , 10 ;
Compile OK - 201
|
http://www.freewebs.com/ogremagic/index.htm |
Admin Site Admin
(send private message)
Posts: 933 Topics: 55
Location: OverHertz Studio | [425] - posted: 2011-11-07 16:55:52 The internal handler of instructions is very complex, expressions are handled separately and can not be returned via GetStringValue - i would add an extra function for this problem, however i plan to change the internal handler over the next few releases, so it would not be a good idea.
[expression] is basically anything that is inside [] with registers.. e.g.
Code:
GetStringValue will return [expression], anyways i know a solution, i will add an extra function ExtractLine, which can extract the line from the current position.
Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message. |
Admin Site Admin
(send private message)
Posts: 933 Topics: 55
Location: OverHertz Studio | [426] - posted: 2011-11-07 17:22:10 implemented, and now your function could be changed like so:
Code:function GetFullLine() {
global char line[2048];
global int32 linelen;
linelen = Ziron_ExtractLine(@line, 2048);
eax = @line;
}
function event_mov() {
uses edi;
char buf[2048];
Dword Len;
eax = GetFullLine();
Ziron_ShowMessage(eax);
return false;
}
Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message. |
Emil_halim Ziron Beta Tester
(send private message)
Posts: 639 Topics: 104
Location: Alex, Egypt | [427] - posted: 2011-11-07 19:31:30
ok i have got that latest ver 27.6
have this error when update GetFullLine as you made.
http://www.freewebs.com/ogremagic/index.htm |
Admin Site Admin
(send private message)
Posts: 933 Topics: 55
Location: OverHertz Studio | [429] - posted: 2011-11-07 19:35:10 sorry seems i didnt update the include file - i've re-updated the package.
Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message. |