instr: support nop
This commit is contained in:
parent
cc2671e208
commit
224415c008
@ -454,6 +454,10 @@ func (c *compiler) Compile(t Token) error {
|
||||
c.Must([]byte{0xc3}) // ret
|
||||
return nil
|
||||
|
||||
case NopInstrToken:
|
||||
c.Must([]byte{0x90}) // nop
|
||||
return nil
|
||||
|
||||
default:
|
||||
return fmt.Errorf("can't compile token of type %#t", t)
|
||||
}
|
||||
|
3
lexer.go
3
lexer.go
@ -80,6 +80,9 @@ func (l *lexer) Next() (Token, error) {
|
||||
case "ret":
|
||||
return RetInstrToken{}, nil
|
||||
|
||||
case "nop":
|
||||
return NopInstrToken{}, nil
|
||||
|
||||
default:
|
||||
// If the field ends with `:`, it's a (local) label
|
||||
if strings.HasSuffix(fields[0], `:`) {
|
||||
|
Loading…
Reference in New Issue
Block a user