attempts at warmup exercises.

This commit is contained in:
2025-08-02 13:08:30 -04:00
parent 5bb19672a7
commit e54e352a6e
6 changed files with 153 additions and 57 deletions
+47
View File
@@ -0,0 +1,47 @@
.psx
.create "exercise_2.bin", 0x80010000
; Entry Point of Code
.org 0x80010000
; Constant declaration
BASE_ADDR equ 0x0000
; Symbol Alias Table
; Instructions
; Load
load_imm equ li ; dst_reg, immeidate value
; Store
store_word equ sw ; src_reg, dst_address
; Addition
add_s equ add ; dst_reg, reg_a, reg_b (signed)
add_u equ add ; dst_reg, reg_a, reg_b (unsigned)
add_si equ addi ; dst_reg, src_reg, immediate value (signed)
add_ui equ addiu ; dst_reg, src_reg, immediate value (unsigned)
; Branch
branch_equal equ beq ; reg, value(reg, immediate), dst_label
; Registers
; Temporaries, may be changed by subroutines
rtemp_0 equ $t0
rtemp_1 equ $t1
rtemp_2 equ $t2
main:
; TODO:
; 1. Start $t0 with the value 1 and $t1 with the value 0
; 2. Loop, incrementing $t0 until it reaches the value 10
; 3. Keep adding and accumulating all values of $t0 inside $t1
; Attempt:
load_imm rtemp_0, 1
load_imm rtemp_1, 0
loop:
add_s rtemp_1, rtemp_1, rtemp_0
add_si rtemp_0, rtemp_0, 1
branch_equal rtemp_0, 10, end
nop
j loop
end:
.close