On 2010-07-02, at 4:13 PM, chevalma@iro.umontreal.ca wrote:
I'm really hoping we'll be manually writing the least amount of x86-specific code as possible. I think you need to be careful and try to keep the JavaScript code intuitive and "safe".
I'm not sure it's a good idea to define names like $, _, _16, ESP, EAX etc. as global values. Those names are very short and not very distinctive. We probably want something like x86Reg.EAX, or a.regs.EAX (in the assembler object), etc.
I generally agree with Maxime. Although your idea is clever, I think that it is not important to have (almost) *exactly* the same syntax as AT&T. What is important is that it generally has the same structure. So this would be fine:
a.add(a.lit(-8), a.ESP);
and
a.add(a.EAX, a.mem(22, a.ESP, a.EAX, 4));
Also, I'm not sure the *identifier* _16 is generalizable (what if you want an offset of 1749?).
Besides that, returning the "this" in each instruction function is a good idea. This is what is done in C++ stream objects (e.g.: iostream).
I agree here too, so that instructions can be chained.
Marc