[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Libjit-developers] My second attempt at libjit.
From: |
manoloohara |
Subject: |
[Libjit-developers] My second attempt at libjit. |
Date: |
Thu, 24 Feb 2005 11:59:36 -0500 (EST) |
My second attempt.
It doesn't compile and again, I don't know why.
Thank you so much for your pacience.
Here is the code:
#include <stdio.h>
#include <jit/jit-plus.h>
class register_class
{
private: jit_ubyte msb,lsb;
public: void msb_write(jit_ubyte new_value)
{msb=new_value; }
jit_ubyte *msb_address(void)
{return (&msb); }
void lsb_write(jit_ubyte new_value)
{lsb=new_value; }
jit_ubyte *lsb_address(void)
{return (&lsb);}
void print(void)
{printf("msb= %d lsb=%d\n",msb,lsb);
}
};
class ld_zero_function : public jit_function
{
public: register_class AX;
jit_function_t function;
ld_zero_function(jit_context& context) : jit_function(context)
{create();}
void print(void);
protected:
virtual jit_type_t create_signature();
virtual void build();
};
void ld_zero_function::print(void)
{AX.print();}
jit_type_t ld_zero_function::create_signature()
{ return signature_helper (jit_type_void, end_params);
// Return type, terminated with "end_params".
}
void ld_zero_function::build()
{// Put 0 in AX.msb;
jit_value_t zero_ubyte,y,temp1;
jit_type_t type_ptr_ubyte;
AX.msb_write(1); //AX.msb=1
AX.lsb_write(2); //AX.lsb=2
type_ptr_ubyte=jit_type_create_pointer(jit_type_ubyte,1);
//y=address of AX.msb
y=jit_value_create_nint_constant(jit_function_t(),type_ptr_ubyte,(jit_nint)AX.msb_address());
//zero_ubyte= constant 0
zero_ubyte=jit_value_create_nint_constant(jit_function_t(),jit_type_ubyte,(jit_ubyte)0);
//(y+0)=zero_byte
temp1=jit_insn_store_relative(jit_function_t(),y,(jit_nint)(0),zero_ubyte);
};
int main(int argc, char **argv)
{ void *dummy_args[0];
// Create a context to hold the JIT's primary state.
jit_context context;
// Create the function object.
ld_zero_function ld_zero(context);
// Execute the function.
ld_zero.apply(dummy_args,dummy_args);
// Print AX
ld_zero.print(); //it MUST print msb=0 lsb=2
/* Finished */
return 0;
}
_______________________________________________
No banners. No pop-ups. No kidding.
Make My Way your home on the Web - http://www.myway.com
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Libjit-developers] My second attempt at libjit.,
manoloohara <=