From 61024bb13387c734b76486e6c4cd086cfbe09899 Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Thu, 27 Jun 2024 16:05:23 +0200 Subject: [PATCH] Added assembler syntax highlighting --- src/build/Function.go | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/build/Function.go b/src/build/Function.go index 8815d26..819479a 100644 --- a/src/build/Function.go +++ b/src/build/Function.go @@ -227,21 +227,27 @@ func (f *Function) TokenToRegister(t token.Token, register cpu.Register) error { // PrintAsm shows the assembly instructions. func (f *Function) PrintAsm() { - ansi.Bold.Println(f.Name) - ansi.Dim.Println("╭────────────────────────────────────────────────────────────") + ansi.Dim.Println("╭────────────────────────────────────────────────╮") for _, x := range f.Assembler.Instructions { ansi.Dim.Print("│ ") - fmt.Print(x.Mnemonic.String()) - if x.Data != nil { - fmt.Print(" " + x.Data.String()) + if x.Mnemonic == asm.LABEL { + ansi.Yellow.Printf("%-46s", x.Data.String()+":") + } else { + ansi.Green.Printf("%-8s", x.Mnemonic.String()) + + if x.Data != nil { + fmt.Printf("%-38s", x.Data.String()) + } else { + fmt.Printf("%-38s", "") + } } - fmt.Print("\n") + ansi.Dim.Print(" │\n") } - ansi.Dim.Println("╰────────────────────────────────────────────────────────────") + ansi.Dim.Println("╰────────────────────────────────────────────────╯") } // String returns the function name.