August 1, 2025

Sun 3 bootrom souce - nice Vim trick

I am working on the file diag/diag.s which is 3800 lines of assembly language. It gives a myriad of error when I try to assemble it, due to differences between how the sun assember and the gnu assembler handle local labels.
The Sun assembler has code like this:
#ifdef  M25
141$:   movb    UARTBCNTL,d1            | wait for SCC to be ready
#else
141$:   movsb   UARTBCNTL, d1
#endif M25
        btst    #TXREADY, d1            | Wait for SCC to be ready
        dbne    d0, 141$                | Loop until ready or timeout

        moveq   #0xf, d0
142$:   dbra    d0, 142$
This gives errors like this:
../diag/diag.s:2951: Error: syntax error -- statement `dbne d0,141$' ignored
../diag/diag.s:2954: Error: junk at end of line, first unrecognized character is `1'
It needs to be hand edited into code like this for the gnu assembler:
#ifdef  M25
141:    movb    UARTBCNTL,d1            | wait for SCC to be ready
#else
141:    movsb   UARTBCNTL, d1
#endif M25
        btst    #TXREADY, d1            | Wait for SCC to be ready
        dbne    d0, 141b                | Loop until ready or timeout

        moveq   #0xf, d0
142:    dbra    d0, 142b

How can Vim help?

I have known about this, but never used it before. I am getting over 300 error messages for diag.s, so this seemed like a good time to learn a new Vim trick.

You can type ":make" inside vim and it will run make for you. The best part is that it reads and parses any error messages and puts them into something it calls the "quick change list". Not only that, it moves the cursor to the line that gave the first error, and shows the error message in the status line at the bottom of the window.

It is always a win not to have to jump in and out of vim. It is also a win not to have to eyeball and remember line numbers from compiler messages.

Getting automatically to the first line with an error is nice, but what about the next line? You can type the command ":cnext" for that. Not only does this take you to the next line, but it redisplays the compiler error message for the ailing line again in the status line at the bottom of the vim window. Being able to see the error message in conjunction with the line in context is wonderful!

Remember to use ":write" to save changes before invoking ":make" again.

The only complaint with all of this might be that typing ":cnext" is a bit verbose. You can shorten this to ":cn" or you can set up mappings in your .vimrc (there are plugins that include mappings for the quick change list commands). For now ":cn" will make me happy.


Feedback? Questions? Drop me a line!

Tom's Computer Info / tom@mmto.org