MIPS Short
MIPS Short
MIPS Short
MIPS assembler:
Syntax
.align n
.ascii str
Description
Align the next datum on a 2 byte boundary.
For example, .align 2 aligns the next value on a word boundary.
.align 0 turns off automatic alignment of .half, .word,
.float, and .double directives until the next .data or
.kdata directive.
Store the string in memory, but do not null-terminate it.
.asciiz str
.byte b1,..., bn
.data <addr>
The following data items should be stored in the data segment. If the
optional argument addr is present, the items are stored beginning at address
addr.
Store the n floating point double precision numbers in successive memory
locations.
Declare that the datum stored at sym is size bytes large and is a global
symbol. This directive enables the assembler to store the datum in a portion
of the data segment that is efficiently accessed via register $gp.
Store the n floating point single precision numbers in successive memory
locations.
Declare that symbol sym is global and can be referenced from other files.
Store the n 16-bit quantities in successive memory halfwords.
The following data items should be stored in the kernel data segment. If the
optional argument addr is present, the items are stored beginning at address
addr.
The next items are put in the kernel text segment. In SPIM, these items may
only be instructions or words (see the .word directive below). If the
optional argument addr is present, the items are stored beginning at address
addr.
Allocate n bytes of space in the current segment (which must be the data
segment in SPIM).
The next items are put in the user text segment. In SPIM, these items may
only be instructions or words (see the .word directive below). If the optional
argument addr is present, the items are stored beginning at address addr.
Store the n 32-bit quantities in successive memory words. SPIM does not
distinguish various parts of the data segment (.data, .rdata and
.sdata).
.double d1,...,dn
.extern sym size
.float f1,..., fn
.globl sym
.half h1,..., hn
.kdata <addr>
.ktext <addr>
.space n
.text <addr>
.word w1,..., wn
Short_MIPS _CA_Lab1_2014
Instruction
Conditional Branch
on Equality
j Label
Description
This instruction jumps unconditionally to the
instruction followed by the label Label. It is
equivalent to the goto statement in C.
This instruction branches to label Label, if
registers rs and rt have the same values. In
Register Transfer Notation (RTN), it means:
if ( R[rs] == R[rt] )
goto Label;
Conditional Branch
on Inequality
Set Register Based
on Relation
Short_MIPS _CA_Lab1_2014
Service
Print Integer
Call Code
in $v0
1
Arguments
Results
$a0=number(to be printed)
Example Code:
Print Float
li $a0, 89
li $v0, 1
syscall
$f12=number (to be printed)
Example Code:
.data
flabel: .float 3.14
Print double
Print String
$f12, dlabel
li $v0, 3
syscall
a0=address (of string in memory)
Example Code:
.data
str1: .asciiz "Hi There!"
Read Integer
Read Float
Read double
Read String
la $a0, str1
li $v0, 4
syscall
Example Code:
li $v0, 5
syscall
Example Code:
li $v0, 6
syscall
Example Code:
li $v0, 7
syscall
$a0=address (of input string in memory)
$a1=length of buffer(n bytes)
Example Code:
.data
str1: .space 80
la $a0, str1
li $a1, 80
li $v0, 8
syscall
number in
$v0
number in
$f0
Short_MIPS _CA_Lab1_2014
Sbrk
(Dynamically
allocate n-byte
of memory)
Exit
10
address in
$v0
Short_MIPS _CA_Lab1_2014
Short_MIPS _CA_Lab1_2014