1
0
Fork 0
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:
Henrik Hautakoski 2018-12-10 23:11:58 +01:00
parent 0f10c9fd38
commit 1146b925f5
No known key found for this signature in database
GPG key ID: 839F3A7EAFAEAFAA

View file

@ -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) {