Basic MIPS Simulator in JavaScript (Pipeline Simulation)
by morriswmz
Assembly Source
Assemble & Load
?
# hello world program # support .data and .text .data str: .asciiz "hello world!" .text # main program main: # support basic pseudo instruction # including la, pushr, popr la $s0, str add $a0, $r0, $s0 pushr $ra la $ra, main_ret j convert nop main_ret: # debug print, not true instruction prints $s0 break nop # subroutine # convert to upper case # $a0 - address of the string convert: loop: # get byte lb $t0, 0($a0) andi $t0, $t0, 0xff beq $t0, $r0, conv_end # check range sltiu $t1, $t0, 97 bne $t1, $r0, conv_next nop addi $t1, $t0, -123 slti $t1, $t1, 0 beq $t1, $r0, conv_next nop # convert addi $t0, $t0, -32 sb $t0, 0($a0) conv_next: addi $a0, $a0, 1 j loop nop conv_end: lw $t0, 4($sp) jr $ra add $ra, $r0, $t0 # delay slot nop
0x10000000:
add $r1, $r2, $r3
CPU Status
Step
Run
Reset
No program
Pipeline
PC
0x00000000
Cycle
0
Inst
0x00000000
Stall
0
r0 / zero
0x00000000
r16 / s0
0x00000000
r1 / at
0x00000000
r17 / s1
0x00000000
r2 / v0
0x00000000
r18 / s2
0x00000000
r3 / v1
0x00000000
r19 / s3
0x00000000
r4 / a0
0x00000000
r20 / s4
0x00000000
r5 / a1
0x00000000
r21 / s5
0x00000000
r6 / a2
0x00000000
r22 / s6
0x00000000
r7 / a3
0x00000000
r23 / s7
0x00000000
r8 / t0
0x00000000
r24 / t8
0x00000000
r9 / t1
0x00000000
r25 / t9
0x00000000
r10 / t2
0x00000000
r26 / k0
0x00000000
r11 / t3
0x00000000
r27 / k1
0x00000000
r12 / t4
0x00000000
r28 / gp
0x00000000
r13 / t5
0x00000000
r29 / sp
0x00000000
r14 / t6
0x00000000
r30 / fp
0x00000000
r15 / t7
0x00000000
r31 / ra
0x00000000
Register Value Format :
Hex
Dec
IF
Inst:
nop
ID
Inst:
nop
BCond:
n/a
BTaken:
n/a
BValA:
n/a
BValB:
n/a
BValAS:
n/a
BValBS:
n/a
BTBS:
n/a
BTgt:
n/a
MWVal:
n/a
MWSrc:
n/a
EX
Inst:
nop
ALUOp:
n/a
ALUA:
n/a
ALUB:
n/a
ALUAS:
n/a
ALUBS:
n/a
MA
Inst:
nop
Op:
n/a
Addr:
n/a
Value:
n/a
WB
Inst:
nop
Op:
n/a
Src:
n/a
Dst:
n/a
Value:
n/a
Memory
Lookup
?
Output
Clear