A MIPS Assembler

Specially designed for Logisim Projects

there will be bugs :( ... email kwalsh when you find them



Edit MIPS code below. Your browser doesn't support file drag-and-drop, sorry.

 

program.S

Help

This assembler suppports most MIPS instructions, and most common pseudo-instructions as well. Note: All MIPS instructions are encoded in 4-bytes, but some pseudo-instructions get encoded as two separate instructions and these require 8 bytes. Also, register $1 is reserved for use by the few pseudo-instructions that need a spare temporary register.

Comments

# comment anything after a '#' is ignored

; comment anything after a ';' is ignored

// comment anything after a '//' is ignored

Register Notation

Registers can be written using GCC notation: $0, $2, $4, $5, ..., $31.

Or you can use "r" instead: r0, r2, r4, r5, ..., r31.

Or you can use mnemonics: $zero, $v0, $a0, $a1, ... $ra.

Text and Data Segments

By default, the code is assembled into the text segment, starting at address 0x00000000. The text segment is for executable instructions, and should get loaded into the MIPS circuit's program ROM. A separate data segment can hold data, and should be loaded into the MIPS circuit's data RAM.

.text 0x1234 changes so that the next code is assembled starting at address 0x1234, but still in the code segment.

.data 0x1234 changes so that the next code is assembled starting at address 0x1234, but in the data segment.

.text without an address changes so that the next code is assembled in the text segment, continuing at whatever address the last text segment left off.

.data without an address changes so that the next code is assembled in the data segment, continuing at whatever address the last data segment left off.

Labels

foo: creates a symbol that refers to this line of code. You can then use this as the target of a jump or branch, like j foo, or jal foo or, beq $3, $4, foo. Or you can use pseudo-instructions to put foo's address into a register, like this: la $7, foo.

Integer Data

.word 0xABCD1234 emits a 4-byte value (specified in either hex or decimal) directly into the data segment.

.half 0xAB12 emits a 2-byte value (specified in either hex or decimal) directly into the data segment.

.byte 0xA1 emits a 1-byte value (specified in either hex or decimal) directly into the data segment.

String Data

.asciz "Hello World!\n" emits a sequence of ascii bytes, followed by a zero byte, directly into the data segment.

.string "Hello World!\n" is exactly the same as .asciz.

.ascii "Hello World!\n" is similar, but does not include the zero byte at the end. This is probably not what you want.