Monthly Archive for February, 2009

Website updates

These things are being updated:

  • Adding content to old posts, fixing them to go with the general blog style
  • Theme updates (mostly messages, and I want spacing between posts)
  • Tagging all project-related posts, and putting them onto projects page

WireOS scheme #08

Unfinished, some thoughs on regsiter mapping/distribution.

Size troubles (HybriC)

Question: how many bytes will be written into sum? Will everything crash?

int sum;

mov [sum],10;
add [sum],50;

Answer: no idea. This is very bad situation, because “10″ is 1 byte, so mov/add will use only lower 1 byte of sum variable.

How to properly do it:

mov [sum],64bit 10;
add [sum],64bit 50;

HybriC assembler isn’t smart. You are.

32bit int var; int sum;

mov [var],r0; //ERROR: R0 is 8 bytes, not 4
mov [var],r0.32[0]; //R0.32 are 4-byte registers
mov [var],[sum]; //UNDEFINED SITUATION. if "sum" pointer is 64-bit, then 8 bytes
      are copied. if "sum" pointer is 32-bit, then 4 bytes are copied. Etc.

These are some dangers waiting for those who wish code on low level of virutal machine. Standart opcodes always assume size of operation equals to size of second operand.

WireOS scheme #07 (okay, not really)

HybriC 3

HybriC now compiles into actual bytecode. Most of it’s internals are finished, and it’s ready for adding actual syntax rules and expression parser.

Also, I think FIXME is very useful, except I still have a lot of such comments:

WireOS scheme #06 (virtual machine)

Some raw notes for me on machine code structure.

HybriC 2

Added lexical analysis/thing that separates tokens. It works perfectly now, and it also properly detects integer/floating point constants (and converts them to double/int64).

The source code is now 18KB, and I did more in 2 days using C than I did in past month using C++

ZHybriC

I restarted ZHybriC again, sort of. Now I’m writing it in pure C, so porting it will be a lot easier in future (porting it to itself, so it can compile itself).

I must say writing in C is actually a lot more productive than in C++. It took me 1 hour, and I have a fully working preprocessor now, which supports #include, #ifdef…#else…#endif, #define, and soon will also support #undef, #ifndef, #elseif. It does valid checks, and it works good with strings.

Although it made the code more hard and fun to write, here’s snippet of “#include” macro.
Continue reading ‘ZHybriC’