Tuesday, 22 July 2008

Out with opcodes, in with functions

OK, time for my second post. I was on a vacation last week, without my computer, therefore I haven't been able to get any further. However, I was able to think(!), and I decided to do a change in the inner workings of Topaz. At first, I had many opcodes, e.g. 0x21, ADD. Now I've decided to instead use functions, and only create the opcodes necessary to invoke a function (which still is a lot). For example, this 0x11, {topaz.vm.T_LOCALREF, 'VAL'}, {topaz.vm.T_FLOAT, 1}, -- MOV eax, 1 0x21, {topaz.vm.T_LOCALREF, 'VAL'}, {topaz.vm.T_FLOAT, 2}, -- ADD eax, 2 0x23, {topaz.vm.T_LOCALREF, 'VAL'}, {topaz.vm.T_FLOAT, 3}, -- MUL eax, 3 0xF1, {topaz.vm.T_LOCALREF, 'VAL'}, {0, 0}, -- PRINT eax becomes 0x11, {'INT', 1}, nil, -- PUSH (INT)1 0x11, {'INT', 2}, nil, -- PUSH (INT)2 0x22, '__add', nil, -- THISCALL __add 0x22, '__mul', nil -- THISCALL __mul 0x11, 'print', nil -- PRINT But the details are far from finished, and I would like some feedback.

0 comments: