diff --git a/compile.go b/compile.go index 0b1c64e..3852667 100644 --- a/compile.go +++ b/compile.go @@ -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) } diff --git a/lexer.go b/lexer.go index 215d8f3..56063cd 100644 --- a/lexer.go +++ b/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], `:`) { diff --git a/token.go b/token.go index 1373340..854e8d4 100644 --- a/token.go +++ b/token.go @@ -23,6 +23,8 @@ type SyscallInstrToken struct{} type RetInstrToken struct{} +type NopInstrToken struct{} + type DataVariableInstrToken struct { VarName string Sizeclass string // sz, u8, u16, u32, u64