mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-26 22:31:05 +00:00
[gamecode] Add instructions for stack adjust, nop, and ldconst
ldconst isn't implemented yet but the plan is to load various constants (eg, 0, 1, 2, pi, e, ...). Stack adjust is useful for adding an offset to the stack pointer without having to worry about finding it (and it checks for alignment). nop is just that :)
This commit is contained in:
parent
616a52efb5
commit
3df46d197f
2 changed files with 42 additions and 0 deletions
|
@ -5,6 +5,9 @@ bitmap_txt = """
|
||||||
0 0011 mmss pop
|
0 0011 mmss pop
|
||||||
0 1ccc ttss compare
|
0 1ccc ttss compare
|
||||||
0 0000 00nn
|
0 0000 00nn
|
||||||
|
0 0000 0000 noop
|
||||||
|
0 0000 0001 adjstk
|
||||||
|
0 0000 0010 constant
|
||||||
0 1011 nnnn
|
0 1011 nnnn
|
||||||
0 1111 nnnn
|
0 1111 nnnn
|
||||||
|
|
||||||
|
@ -75,6 +78,14 @@ etype_tt = ["ev_int", "ev_float", "ev_long", "ev_double"]
|
||||||
unsigned_t = ["ev_uint", "ev_ulong"]
|
unsigned_t = ["ev_uint", "ev_ulong"]
|
||||||
float_t = ["ev_float", "ev_double"]
|
float_t = ["ev_float", "ev_double"]
|
||||||
|
|
||||||
|
adjstk_formats = {
|
||||||
|
"opcode": "OP_ADJSTK",
|
||||||
|
"mnemonic": "adjstk",
|
||||||
|
"opname": "adjstk",
|
||||||
|
"format": "%sa, %sb",
|
||||||
|
"widths": "0, 0, 0",
|
||||||
|
"types": "ev_short, ev_short, ev_invalid",
|
||||||
|
}
|
||||||
bitops_formats = {
|
bitops_formats = {
|
||||||
"opcode": "OP_{op_bit[oo].upper()}_{bit_type[t]}_{ss+1}",
|
"opcode": "OP_{op_bit[oo].upper()}_{bit_type[t]}_{ss+1}",
|
||||||
"mnemonic": "{op_bit[oo]}",
|
"mnemonic": "{op_bit[oo]}",
|
||||||
|
@ -157,6 +168,14 @@ compare2_formats = {
|
||||||
"cmp_types": unsigned_t,
|
"cmp_types": unsigned_t,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
constant_formats = {
|
||||||
|
"opcode": "OP_LDCONST",
|
||||||
|
"mnemonic": "ldconst",
|
||||||
|
"opname": "ldconst",
|
||||||
|
"format": "%sa, %sb, %gc",
|
||||||
|
"widths": "0, 0, -1",
|
||||||
|
"types": "ev_short, ev_short, ev_void",
|
||||||
|
}
|
||||||
convert_formats = {
|
convert_formats = {
|
||||||
"opcode": "OP_CONV",
|
"opcode": "OP_CONV",
|
||||||
"mnemonic": "conv",
|
"mnemonic": "conv",
|
||||||
|
@ -268,6 +287,14 @@ move_formats = {
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
noop_formats = {
|
||||||
|
"opcode": "OP_NOP",
|
||||||
|
"mnemonic": "nop",
|
||||||
|
"opname": "nop",
|
||||||
|
"format": "there were plums...",
|
||||||
|
"widths": "0, 0, 0",
|
||||||
|
"types": "ev_invalid, ev_invalid, ev_invalid",
|
||||||
|
}
|
||||||
push_formats = {
|
push_formats = {
|
||||||
"opcode": "OP_PUSH_{op_mode[mm]}_{ss+1}",
|
"opcode": "OP_PUSH_{op_mode[mm]}_{ss+1}",
|
||||||
"mnemonic": "push",
|
"mnemonic": "push",
|
||||||
|
@ -473,11 +500,13 @@ with_formats = {
|
||||||
}
|
}
|
||||||
|
|
||||||
group_map = {
|
group_map = {
|
||||||
|
"adjstk": adjstk_formats,
|
||||||
"bitops": bitops_formats,
|
"bitops": bitops_formats,
|
||||||
"branch": branch_formats,
|
"branch": branch_formats,
|
||||||
"call": call_formats,
|
"call": call_formats,
|
||||||
"compare": compare_formats,
|
"compare": compare_formats,
|
||||||
"compare2": compare2_formats,
|
"compare2": compare2_formats,
|
||||||
|
"constant": constant_formats,
|
||||||
"convert": convert_formats,
|
"convert": convert_formats,
|
||||||
"hops": hops_formats,
|
"hops": hops_formats,
|
||||||
"jump": jump_formats,
|
"jump": jump_formats,
|
||||||
|
@ -486,6 +515,7 @@ group_map = {
|
||||||
"mathops": mathops_formats,
|
"mathops": mathops_formats,
|
||||||
"memset": memset_formats,
|
"memset": memset_formats,
|
||||||
"move": move_formats,
|
"move": move_formats,
|
||||||
|
"noop": noop_formats,
|
||||||
"push": push_formats,
|
"push": push_formats,
|
||||||
"pushregs": pushregs_formats,
|
"pushregs": pushregs_formats,
|
||||||
"pop": pop_formats,
|
"pop": pop_formats,
|
||||||
|
|
|
@ -2766,6 +2766,18 @@ pr_exec_ruamoko (progs_t *pr, int exitdepth)
|
||||||
pr_opcode_e st_op = st->op & OP_MASK;
|
pr_opcode_e st_op = st->op & OP_MASK;
|
||||||
switch (st_op) {
|
switch (st_op) {
|
||||||
// 0 0000
|
// 0 0000
|
||||||
|
case OP_NOP:
|
||||||
|
break;
|
||||||
|
case OP_ADJSTK:
|
||||||
|
if (st->a || (st->b & 3)) {
|
||||||
|
PR_RunError (pr, "invalid stack adjustment: %d, %d",
|
||||||
|
st->a, (short) st->b);
|
||||||
|
}
|
||||||
|
*pr->globals.stack += (short) st->b;
|
||||||
|
break;
|
||||||
|
case OP_LDCONST:
|
||||||
|
PR_RunError (pr, "OP_LDCONST not implemented");
|
||||||
|
break;
|
||||||
case OP_LOAD_B_1:
|
case OP_LOAD_B_1:
|
||||||
case OP_LOAD_C_1:
|
case OP_LOAD_C_1:
|
||||||
case OP_LOAD_D_1:
|
case OP_LOAD_D_1:
|
||||||
|
|
Loading…
Reference in a new issue