Smart Branches (version 2)

Macross is a macro cross assembler for the 6502. It’s a higher level assembly language in that there you can write code like this:

    inc bleh
    if (equal) {
        inc bleh+1
    }
    do {
        lsr
    } while (!carry)

and it will generate the appropriate branches and labels. I intend to add similar high level constructs to my 816 assembler. They won’t be useful for generated lcc code, but they will be useful for hand-written assembly (which includes parts of libc and the subroutine library).

The first step is a new branch syntax as an alternative to the smart branches. Behold:

    branch condition, target

    branch cc, here
    branch signed lt, there
    branch unsigned ge, another

Condition may also be a boolean (number) for always or never.

    branch true, label
    branch false, label  ; will be optimized out!