mirror of
https://github.com/pnx/m16vm
synced 2026-06-16 03:44:55 +02:00
src/as/codegen.c: use symtab to get the address for J-Type instruction.
This commit is contained in:
parent
0f10c9fd38
commit
1146b925f5
1 changed files with 4 additions and 9 deletions
|
|
@ -27,19 +27,14 @@ void codegen_emit(struct ast_instr* instr, symtab_t* symbols, uint8_t* out) {
|
|||
// No operands, return
|
||||
return;
|
||||
|
||||
// J-Type (We don't have labels yet, so this is just a address)
|
||||
if (instr->operands[0].type == DATATYPE_NUMBER) {
|
||||
//if (instr->operands[0].type == DATATYPE_STRING) {
|
||||
// J-Type
|
||||
if (instr->operands[0].type == DATATYPE_STRING) {
|
||||
uint16_t addr;
|
||||
|
||||
/* if (symtab_get(symbols, instr->operands[0].s, &addr)) {
|
||||
if (symtab_get(symbols, instr->operands[0].s, &addr) >= 0) {
|
||||
out[0] |= (addr >> 8);
|
||||
out[1] = addr;
|
||||
}*/
|
||||
addr = instr->operands[0].n;
|
||||
|
||||
out[0] |= (addr >> 8);
|
||||
out[1] = addr;
|
||||
}
|
||||
}
|
||||
// R/RI or I
|
||||
else if (instr->operands[0].type == DATATYPE_REGISTER) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue