instr: support nop

This commit is contained in:
mappu 2023-12-11 19:31:47 +13:00
parent cc2671e208
commit 224415c008
3 changed files with 9 additions and 0 deletions

View File

@ -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)
}

View File

@ -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], `:`) {

View File

@ -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