func wrapMain(funcs []*PkgSym) *Func { ret := NewFunc() // the main func // clear r0 for safety ret.AddInst(inst.Reg(arch8.XOR, 0, 0, 0, 0, 0)) for _, f := range funcs { ret.AddInst(inst.Jmp(arch8.JAL, 0)) ret.AddLink(FillLink, f) } ret.AddInst(inst.Sys(arch8.HALT, 0)) return ret }
func resolveInstJmp(p lex8.Logger, ops []*lex8.Token) (*inst, bool) { op0 := ops[0] opName := op0.Lit var op uint32 // op sym switch opName { case "j": op = arch8.J case "jal": op = arch8.JAL default: return nil, false } var pack, sym string var fill int var symTok *lex8.Token if argCount(p, ops, 1) { symTok = ops[1] if checkLabel(p, ops[1]) { sym = ops[1].Lit fill = fillLabel } else { pack, sym = parseSym(p, ops[1]) fill = fillLink } } ret := new(inst) ret.inst = asminst.Jmp(op, 0) ret.pkg = pack ret.sym = sym ret.fill = fill ret.symTok = symTok return ret, true }
func (_s) j(im int32) uint32 { return S.Jmp(A.J, im) }
func (_s) jal(im int32) uint32 { return S.Jmp(A.JAL, im) }