mirror of
https://github.com/pnx/m16vm
synced 2026-07-02 11:33:40 +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
|
// No operands, return
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// J-Type (We don't have labels yet, so this is just a address)
|
// J-Type
|
||||||
if (instr->operands[0].type == DATATYPE_NUMBER) {
|
if (instr->operands[0].type == DATATYPE_STRING) {
|
||||||
//if (instr->operands[0].type == DATATYPE_STRING) {
|
|
||||||
uint16_t addr;
|
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[0] |= (addr >> 8);
|
||||||
out[1] = addr;
|
out[1] = addr;
|
||||||
}*/
|
}
|
||||||
addr = instr->operands[0].n;
|
|
||||||
|
|
||||||
out[0] |= (addr >> 8);
|
|
||||||
out[1] = addr;
|
|
||||||
}
|
}
|
||||||
// R/RI or I
|
// R/RI or I
|
||||||
else if (instr->operands[0].type == DATATYPE_REGISTER) {
|
else if (instr->operands[0].type == DATATYPE_REGISTER) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue