CS代考 FIT1008 and FIT2085

Call code ($v0)
Print integer Print string
Input integer
Allocate memory Exit

Copyright By PowCoder代写 加微信 powcoder

Table 1: System calls Returns
value is signed
string must be termi- nated with ’\0’ value is signed
ends simulation
MIPS reference sheet for FIT1008 and FIT2085
$a0 = value to print
$v0 = entered integer
$v0 = address of first byte –
$a0 = address of string to print –
$a0 = number of bytes –
Input string
$a0 = address at which the string will be stored
$a1 = maximum number of characters in the string
returns if $a1-1 char- acters or Enter typed, the string is termi- nated with ’\0’
Table 2: General-purpose registers
On function call:
On function return:
saves value of $ra on stack saves value of $fp on stack copies $sp to $fp
allocates local variables on stack
clears arguments off stack
restores temporary registers off stack uses return value in $v0
Number R00
R02, R03 R04–R07 R08–R15 R16–R23 R24, R25 R28
R29 R30 R31
$sp $fp $ra
provides constant zero
reserved for assembler
system call code, return value system call and function arguments temporary storage (caller-saved) temporary storage (callee-saved) temporary storage (caller-saved) pointer to global area
stack pointer
frame pointer
return address
.word w1[, w2, …] .space n
.ascii ”string” .asciiz ”string”
Table 3: Assembler directives assemble into data segment
assemble into text (code) segment
allocate word(s) with initial value(s)
allocate n bytes of uninitialized, unaligned space allocate ASCII string, do not terminate
allocate ASCII string, terminate with ’\0’
Table 4: Function calling convention
saves temporary registers on stack passes arguments on stack
calls function using jal fn label
sets $v0 to return value clears local variables off stack restores saved $fp off stack restores saved $ra off stack returns to caller with jr $ra

Table 5: A partial instruction set is provided below. The following conventions apply. Instruction Format column
Rsrc, Rsrc1, Rsrc2: register source operand(s) – must be the name of a register Rdest: register destination – must be the name of a register
Addr: address in the form offset(Rsrc), that is, absolute address = Rsrc + offset label: label of an instruction
**: pseudoinstruction
Immediate Form column
Associated instruction where Rsrc2 is an immediate. Symbol – appears if there is no immediate form. Unsigned or overflow column
Associated unsigned (or overflow) instruction for the values of Rsrc1 and Rsrc2. Symbol – if no such form.
Table 6: Allowed MIPS instruction (and pseudoinstruction) set
Instruction format
add Rdest, Rsrc1, Rsrc2 sub Rdest, Rsrc1, Rsrc2 mult Rsrc1, Rsrc2
div Rsrc1, Rsrc2
and Rdest, Rsrc1, Rsrc2 or Rdest, Rsrc1, Rsrc2 xor Rdest, Rsrc1, Rsrc2 nor Rdest, Rsrc1, Rsrc2 sllv Rdest, Rsrc1, Rsrc2 srlv Rdest, Rsrc1, Rsrc2
srav Rdest, Rsrc1, Rsrc2
mfhi Rdest
mflo Rdest
lw Rdest, Addr
sw Rsrc, Addr
la Rdest, Addr(or label) **
beq Rsrc1, Rsrc2, label bne Rsrc1, Rsrc2, label slt Rdest, Rsrc1, Rsrc2
j label jal label
jr Rsrc jalr Rsrc
Meaning Add Subtract Multiply Divide
Bitwise AND Bitwise OR Bitwise XOR Bitwise NOR Shift Left Logical
Operation Immediate
Unsigned or Overflow addu (no overflow trap) subu (no overflow trap) mulu
– – – – – –
sltu , sltiu
Shift Right Shift Right
Logical Arithmet.
Rdest = Rsrc1 + Rsrc2 Rdest = Rsrc1 – Rsrc2 Hi:Lo = Rsrc1 * Rsrc2 Lo = Rsrc1/Rsrc2;
Hi = Rsrc1 % Rsrc2 Rdest = Rsrc1 & Rsrc2 Rdest = Rsrc1 | Rsrc2 Rdest = Rsrc1 ∧ Rsrc2 Rdest = ∼(Rsrc1 | Rsrc2) Rdest = Rsrc1 << Rsrc2 Rdest = Rsrc1 >> Rsrc2 (MSB=0)
Rdest = Rsrc1 >> Rsrc2 (MSB preserved)
Rdest = Hi
Rdest = Lo
Rdest = mem32[Addr] mem32[Addr] = =Addr (or Rdest=label)
if (Rsrc1 == Rsrc2)
PC = label
if (Rsrc1 != Rsrc2)
PC = label
if (Rsrc1 < Rsrc2) else Rdest = 0 PC = label $ra = PC + 4; PC = label $ra = PC + 4; depends on the value of $v0 andi ori xori - sll srl printing strings) Branch if equal Branch if not equal Set if less than Jump and link Jump register Jump and link register system call from from word word Address (for 程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com