Modifiers

When writing MOS assembly code, it's often necessary to refer to a specific byte or short within a larger address, when the exact address is not known until code relaxation or linking. For example, code may need to refer to the low byte of a 16-bit function address: LDA [the lowest byte in the 16-bit address of QSORT] However, the address of  may not be exactly known, until your program has had relaxation and/or linking applied to it. Therefore, the lowest byte of  won't be known until then as well.

In LLVM land, that operator is referred to as a modifier. The llvm-mos project supports some MOS-specific modifiers, to refer to a specific part of a larger address. If  refers to a 16-bit address: LDA #mos16lo(QSORT) then the lowest byte in the  address is loaded into the accumulator.

The following modifiers are available for your use:

The assembly parser tries to be smart about what kinds of modifiers can be used for what purposes. For example,  returns a 16-bit address, so you can't do   because the immediate LDA instruction only accepts 8-bit values.

Much existing MOS code depends on the less-than operator  and the greater-than operator   as shorthand for the mos16lo and mos16hi functions, respectively. This functionality has been added to MOSAsmParser.cpp, so that you can use either representation in your own programs.

All MOS processors are little endian, so the lowest byte appears at the zeroth position in a 16-bit address.