Initial commit

This commit is contained in:
2025-06-17 00:35:40 +08:00
commit 07c0b18e4c
33 changed files with 2300 additions and 0 deletions

35
program.asm Normal file
View File

@@ -0,0 +1,35 @@
// 1. (Register Loading Test)
lu12i.w $r4, 0x12300 // r4 = 0x12300000
addi.w $r4, $r4, 0x456 // r4 = 0x12300456
lu12i.w $r5, 0x88800 // r5 = 0x88800000 (negative high part)
addi.w $r5, $r5, -1 // r5 = 0x887FFFFF
// 2. / (Arithmetic/Logic Test)
add.w $r6, $r4, $r5 // r6 = 0x12300456 + 0x887FFFFF = 0x9AB00455
sub.w $r7, $r4, $r5 // r7 = 0x12300456 - 0x887FFFFF = 0x89B00457
slt $r8, $r4, $r5 // r4 > r5 (signed), r8 = 0
sltu $r9, $r4, $r5 // r4 < r5 (unsigned), r9 = 1
and $r10, $r4, $r5 // r10 = 0x12300456 & 0x887FFFFF = 0x00300456
or $r11, $r4, $r5 // r11 = 0x12300456 | 0x887FFFFF = 0x9A7FFFFF
nor $r12, $r10, $r11 // r12 = ~(r10 | r11) = ~0x9A7FFFFF = 0x65800000
// 3. 访 (Memory Access Test)
addi.w $r1, $r0, 100 // r1 = 100 (Address base)
st.w $r4, $r1, 0 // M[100] = r4 (0x12300456)
st.w $r5, $r1, 4 // M[104] = r5 (0x887FFFFF)
ld.w $r13, $r1, 0 // r13 = M[100]
ld.w $r14, $r1, 4 // r14 = M[104]
// 4. (Branching Test)
// BEQ: r13 == r4 is true, should jump
beq $r13, $r4, 8 // Branch to 'skip' label (PC+8)
addi.w $r15, $r0, 1 // This should NOT be executed
// 'skip:' label is here
// BLT: r7 is negative, r6 is positive, r7 < r6 is true, should jump
blt $r7, $r6, 8 // Branch to 'end' label (PC+8)
addi.w $r16, $r0, 1 // This should NOT be executed
// 'end:' label is here
// 5. :
// Unconditional Jump: Create an infinite loop to end the program
b -4 // Infinite loop: jump to itself