[gamecode] Add format for addressing modes and use in return

This fixes Ruamoko's return format string. It looks like it's producing
the correct address (but doesn't show all the information it should),
but the rest of the debug code needs work locals.
This commit is contained in:
Bill Currie 2022-01-27 13:29:38 +09:00
parent 4b4cb60c65
commit de974fdd3f
3 changed files with 48 additions and 1 deletions

View file

@ -463,7 +463,7 @@ return_formats = {
"mnemonic": "return",
"opname": "return",
"widths": "-1, -1, 0", # width specified by st->c
"format": "FIXME",
"format": "%Mc5",
"types": "ev_void, ev_void, ev_void",
}
vecops_formats = {

View file

@ -1629,6 +1629,7 @@ PR_PrintStatement (progs_t *pr, dstatement_t *s, int contents)
const char *str;
char mode = fmt[1], opchar = fmt[2];
unsigned param_ind = 0;
pr_uint_t shift = 0;
pr_uint_t opval;
qfot_type_t *optype = &res->void_type;
pr_func_t func;
@ -1640,6 +1641,15 @@ PR_PrintStatement (progs_t *pr, dstatement_t *s, int contents)
if (param_ind >= PR_MAX_PARAMS)
goto err;
}
if (mode == 'M' || mode == 'm') {
if (!isxdigit (fmt[3])) {
goto err;
}
shift = fmt[3];
shift = (shift & 0xf)
+ (((shift & 0x40) >> 3) | ((shift & 0x40) >> 5));
fmt++; // M/m have one extra item
}
switch (opchar) {
case 'a':
@ -1732,6 +1742,34 @@ PR_PrintStatement (progs_t *pr, dstatement_t *s, int contents)
s->a, s->b, str);
}
break;
case 'M':
case 'm':
{
pr_ptr_t ptr = 0;
pr_int_t offs = 0;
switch ((opval >> shift) & 3) {
case 0:
ptr = s->a + PR_BASE (pr, s, A);
break;
case 1:
break;
case 2:
ptr = s->a + PR_BASE (pr, s, A);
ptr = G_POINTER (pr, ptr);
offs = (short) s->b;
break;
case 3:
ptr = s->a + PR_BASE (pr, s, A);
ptr = G_POINTER (pr, ptr);
offs = s->b + PR_BASE (pr, s, B);
offs = G_INT (pr, offs);
break;
}
ptr += offs;
str = global_string (&data, ptr, optype,
mode == 'M');
}
break;
default:
goto err;
}

View file

@ -54,10 +54,19 @@
// F function (must come before any P)
// R return value
// E entity + field (%Eab)
// M addressing mode, contents
// m addressing mode, no contents
// takes operand (a,b,c,o (opcode)) and right shift(hex). always masked
// by 3
// %Mc5 -> contents, operand c, shift right 5 bits
// %mo2 -> no contents, opcode, shift right 2 bits
// %mo0 -> no contents, opcode, no shift
// always uses a and b for the address calculation (Ruamoko convention))
//
// a operand a
// b operand b
// c operand c
// o opcode
// x place holder for P (padding)
// 0-7 parameter index (for P)
VISIBLE const v6p_opcode_t pr_v6p_opcodes[] = {