# Bachelor thesis logbook Camil Staps ### 2016-09-18 Made a Vim plugin for ABC code highlighting (camilstaps/vim-abc). ARM/Thumb-2 mode switches are expensive, and since a Clean program continuously switches between the RTS and the program itself, it is not viable to have the RTS run in ARM mode and the code generator generate Thumb-2 code. Hence, I started to rewrite the RTS for Thumb-2. Mostly minor, trivial changes: - Invisible registers for some instructions (auxiliary register needed) Started to make changes to the code generator: - Added `.thumb`, `.syntax unified` to the top of each generated file - Added `.thumb_func` before each code label - Fix for the `str pc,[sp,#-4]!` and similar instructions, since `pc` cannot be the `Rd` operand in a `str` instruction: copy to scratch register first. **Question**: Is there an interface to get an auxiliary register in the code generator? For example, to swap to registers a third is necessary (or the stack, but then the PC and SP cannot be modified). In `w_as_jsr_instruction`, the PC is stored on the stack, but PC cannot be `Rd` for `str`. Therefore we need an auxiliary register (`8c91384` does this for some cases). *Answer on 09-19*. ### 2016-09-19 Talked to John: - (*Answer to question from 09-18*) Registers R14 (LR) and probably also R12 are scratch registers and can be used at any time. - When the program counter is stored on the stack in ARM (`str pc,[sp,#-4]!`), the value pushed is actually the PC + 8, which gives space for a call after storing the PC. On Thumb-2 this is different, so this should be checked.