Skip to content

Assembler

varkenvarken edited this page Jan 25, 2020 · 12 revisions

A small assembler is provided for the Robin SoC as a python program.

Because of the limited number of instructions and address modes the assembler is small. It supports expressions as well as user defined macros. Its output is a flat file of bytes or an Intel .hex file.

To give an idea of its current capabilities, a sample is shown below. Note that return and call are not actual cpu instructions but macros. A sample macro file is shown at the end. The assembler also comes with a bunch of built in aliases for registers (like tmp and link) as defined in this spreadsheet

start: 0x200

readline:   ; read characters until newline (10) into buffer pointer to by r2
    push r5
    move r4,r2,0
    move tmp,0,0
    move r5,0,0
    load r5,#10 ; newline
getcharloop:
    call #getchar
    pop link
    cmp tmp2,tmp,r5
    beq readlinedone
    stor tmp,r4,0
    move r4,r4,1
    bra getcharloop
readlinedone:
    move tmp,0,0
    stor tmp,r4,0
    pop r5
    return

Sample macros file

#define jump x
	load link,${x}
	jal link,link,0
#end

#define call x
	push link
	jump ${x}
#end

#define return
	jal 0,link,0
#end
Clone this wiki locally