Skip to content

Commit bec466c

Browse files
committed
fix: linker
1 parent 968ae5c commit bec466c

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

pkg/asm/assembler/linker.go

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -202,18 +202,22 @@ func (p *Linker) linkInstruction(insn macro.Instruction, buses map[uint]io.Bus)
202202
//
203203
return p.linkExprs(insn.Sources)
204204
case *macro.IfGoto:
205-
value, errmsg := p.getLabelValue(insn.Label)
206-
if errmsg != "" {
207-
return p.srcmap.SyntaxError(insn, errmsg)
208-
} else {
209-
insn.Constant = value
205+
if insn.Label != "" {
206+
value, errmsg := p.getLabelValue(insn.Label)
207+
if errmsg != "" {
208+
return p.srcmap.SyntaxError(insn, errmsg)
209+
} else {
210+
insn.Constant = value
211+
}
210212
}
211213
case *macro.IfThenElse:
212-
value, errmsg := p.getLabelValue(insn.Label)
213-
if errmsg != "" {
214-
return p.srcmap.SyntaxError(insn, errmsg)
215-
} else {
216-
insn.Right = value
214+
if insn.Label != "" {
215+
value, errmsg := p.getLabelValue(insn.Label)
216+
if errmsg != "" {
217+
return p.srcmap.SyntaxError(insn, errmsg)
218+
} else {
219+
insn.Right = value
220+
}
217221
}
218222
default:
219223
// continue
@@ -265,13 +269,11 @@ func (p *Linker) getLabelValue(l string) (big.Int, string) {
265269
//
266270
var ok bool
267271
//
268-
if l != "" {
269-
deats, ok = p.constmap[module.NewName(l, 1)]
270-
//
271-
if !ok {
272-
msg := fmt.Sprintf("unknown register or constant \"%s\"", l)
273-
return big.Int{}, msg
274-
}
272+
deats, ok = p.constmap[module.NewName(l, 1)]
273+
//
274+
if !ok {
275+
msg := fmt.Sprintf("unknown register or constant \"%s\"", l)
276+
return big.Int{}, msg
275277
}
276278
//
277279
return deats.Left, ""

0 commit comments

Comments
 (0)