Skip to content

Commit 3505018

Browse files
committed
Fix parsing of inline jump operands
1 parent ac16eef commit 3505018

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

Changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ Version 7.4.0
22
- Fixed some errors in C __pasm parsing
33
- Fixed compile time calculations of QLOG and QEXP (thanks to Ada)
44
- Fixed many incorrect address calculations for Spin2 ^x variables
5+
- Fixed parsing of large immediate addresses for inline asm call/jmp
56
- Improved some nucode peephole optimizations
67
- Some longfill optimizations and bug fixes (thanks to Ada)
78

backends/asm/assemble_ir.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ doPrintOperand(struct flexbuf *fb, Operand *reg, int useimm, enum OperandEffect
152152
ERROR(NULL, "internal error, pcrelative operand found");
153153
break;
154154
case IMM_INT:
155-
if (useabsaddr || (reg->val >= 0 && reg->val <= maximm)) {
155+
if (useabsaddr || (maximm < 0) || (reg->val >= 0 && reg->val <= maximm)) {
156156
flexbuf_addstr(fb, "#");
157157
if (useabsaddr) {
158158
flexbuf_addstr(fb, "\\");
@@ -274,6 +274,12 @@ doPrintOperand(struct flexbuf *fb, Operand *reg, int useimm, enum OperandEffect
274274
}
275275
}
276276

277+
static void
278+
PrintOperandJmpSrc(struct flexbuf *fb, Operand *reg, enum OperandEffect effect)
279+
{
280+
doPrintOperand(fb, reg, 1, effect, -1);
281+
}
282+
277283
static void
278284
PrintOperandSrc(struct flexbuf *fb, Operand *reg, enum OperandEffect effect)
279285
{
@@ -1302,11 +1308,14 @@ DoAssembleIR(struct flexbuf *fb, IR *ir, Module *P)
13021308
switch (ir->instr->ops) {
13031309
case NO_OPERANDS:
13041310
break;
1311+
case P2_JUMP:
1312+
flexbuf_addstr(fb, "\t");
1313+
PrintOperandJmpSrc(fb, ir->dst, ir->dsteffect);
1314+
break;
13051315
case JMP_OPERAND:
13061316
case SRC_OPERAND_ONLY:
13071317
case DST_OPERAND_ONLY:
13081318
case CALL_OPERAND:
1309-
case P2_JUMP:
13101319
case P2_JINT_OPERANDS:
13111320
case P2_DST_CONST_OK:
13121321
flexbuf_addstr(fb, "\t");

0 commit comments

Comments
 (0)