On September 11, 2015 6:40:07 PM CDT, Sean Conner <sean@xxxxxxxxxx> wrote:
It was thus said that the Great Ryan Gonzalez once stated:
On Fri, Sep 11, 2015 at 6:14 PM, Sean Conner <sean@xxxxxxxxxx> wrote:trying
It was thus said that the Great Ryan Gonzalez once stated:
Well, I asked this once, and got pretty much NO feedback. So I'm
RUNTIME??to
word it more simply this time.
Basically, is it possible to have something like:
| mov a, b
where I figure out if 'a' is a register or memory location at
preprocessor to get
Define what you mean by "runtime."
First, there is the source code (step 1):
Then, you run this through DynASM and get (step 2):
During compilation, this code then goes through the C
(step 4).(step 3):
Which is finally compiled into an executable, which is then run
to doIs runtime step 2, 3 or 4?
Step 4. I know I can do something like:
switch (op->type) {
case MEMORY:
| mov [op->base*op->m+op->off], 1
break;
case REGISTER:
| mov Rq(op->reg), 1
break;
}
But doing this for every single instruction is kind of tedious... :)
I think once I ended up defining this super-crazy, huge DynAsm macro
it. Which kind of worked, but it was insanely ugly!
It's either the tedious C code at runtime method, or the insanely ugly
DynASM macro. I know I had a similar issue with some code I've been
playing
aound with [1] and I ended up doing:
switch(oper.value)
{
case '+':
if (token.type == TOKEN_NUMBER)
| add ax,token.value
else
| add ax,[g_vars + token.value]
break;
case '-':
if (token.type == TOKEN_NUMBER)
| sub ax,token.value
else
| sub ax,[g_vars + token.value]
break;
case '*':
if (token.type == TOKEN_NUMBER)
| imul ax,token.value
else
| imul ax,[g_vars + token.value]
break;
case '/':
if (token.type == TOKEN_NUMBER)
| mov bx,token.value
else
| mov bx,[g_vars + token.value]
| cwd
| idiv bx
break;
case '%':
if (token.type == TOKEN_NUMBER)
| mov bx,token.value
else
| mov bx,[g_vars + token.value]
| cwd
| idiv bx
| mov ax,dx
break;
default:
break;
}
Annoying, but at some point the decision has to be made.
-spc
[1] http://boston.conman.org/2015/09/05.2