2023-11-20 20:33:51 -05:00
|
|
|
|
2023-11-20 19:24:45 -05:00
|
|
|
.data
|
2023-11-20 20:33:51 -05:00
|
|
|
data_pointer: .word 0
|
2023-11-20 19:24:45 -05:00
|
|
|
.text
|
|
|
|
setup:
|
|
|
|
li $v0, 9
|
|
|
|
li $a0, 30000
|
|
|
|
syscall
|
|
|
|
|
2023-11-20 20:33:51 -05:00
|
|
|
la $t1, data_pointer
|
2023-11-20 19:24:45 -05:00
|
|
|
sw $v0, ($t1)
|
|
|
|
|
|
|
|
# t0 - current address (data_pointer)
|
|
|
|
move $t0, $v0
|
|
|
|
bf:
|
|
|
|
lb $t1, ($t0)
|
2023-11-20 20:33:51 -05:00
|
|
|
addi $t1, $t1, 8
|
2023-11-20 19:24:45 -05:00
|
|
|
sb $t1, ($t0)
|
|
|
|
lb $t1, ($t0)
|
|
|
|
beqz $t1, BF_CLOSE_1
|
|
|
|
BF_OPEN_1:
|
|
|
|
addi $t0, $t0, 1
|
|
|
|
lb $t1, ($t0)
|
2023-11-20 20:33:51 -05:00
|
|
|
addi $t1, $t1, 4
|
2023-11-20 19:24:45 -05:00
|
|
|
sb $t1, ($t0)
|
|
|
|
lb $t1, ($t0)
|
|
|
|
beqz $t1, BF_CLOSE_2
|
|
|
|
BF_OPEN_2:
|
|
|
|
addi $t0, $t0, 1
|
|
|
|
lb $t1, ($t0)
|
2023-11-20 20:33:51 -05:00
|
|
|
addi $t1, $t1, 2
|
2023-11-20 19:24:45 -05:00
|
|
|
sb $t1, ($t0)
|
|
|
|
addi $t0, $t0, 1
|
|
|
|
lb $t1, ($t0)
|
2023-11-20 20:33:51 -05:00
|
|
|
addi $t1, $t1, 3
|
2023-11-20 19:24:45 -05:00
|
|
|
sb $t1, ($t0)
|
|
|
|
addi $t0, $t0, 1
|
|
|
|
lb $t1, ($t0)
|
2023-11-20 20:33:51 -05:00
|
|
|
addi $t1, $t1, 3
|
2023-11-20 19:24:45 -05:00
|
|
|
sb $t1, ($t0)
|
|
|
|
addi $t0, $t0, 1
|
|
|
|
lb $t1, ($t0)
|
|
|
|
addi $t1, $t1, 1
|
|
|
|
sb $t1, ($t0)
|
2023-11-20 20:33:51 -05:00
|
|
|
subi $t0, $t0, 4
|
2023-11-20 19:24:45 -05:00
|
|
|
lb $t1, ($t0)
|
|
|
|
subi $t1, $t1, 1
|
|
|
|
sb $t1, ($t0)
|
|
|
|
lb $t1, ($t0)
|
|
|
|
bnez $t1, BF_OPEN_2
|
|
|
|
BF_CLOSE_2:
|
|
|
|
addi $t0, $t0, 1
|
|
|
|
lb $t1, ($t0)
|
|
|
|
addi $t1, $t1, 1
|
|
|
|
sb $t1, ($t0)
|
|
|
|
addi $t0, $t0, 1
|
|
|
|
lb $t1, ($t0)
|
|
|
|
addi $t1, $t1, 1
|
|
|
|
sb $t1, ($t0)
|
|
|
|
addi $t0, $t0, 1
|
|
|
|
lb $t1, ($t0)
|
|
|
|
subi $t1, $t1, 1
|
|
|
|
sb $t1, ($t0)
|
2023-11-20 20:33:51 -05:00
|
|
|
addi $t0, $t0, 2
|
2023-11-20 19:24:45 -05:00
|
|
|
lb $t1, ($t0)
|
|
|
|
addi $t1, $t1, 1
|
|
|
|
sb $t1, ($t0)
|
|
|
|
lb $t1, ($t0)
|
|
|
|
beqz $t1, BF_CLOSE_3
|
|
|
|
BF_OPEN_3:
|
|
|
|
subi $t0, $t0, 1
|
|
|
|
lb $t1, ($t0)
|
|
|
|
bnez $t1, BF_OPEN_3
|
|
|
|
BF_CLOSE_3:
|
|
|
|
subi $t0, $t0, 1
|
|
|
|
lb $t1, ($t0)
|
|
|
|
subi $t1, $t1, 1
|
|
|
|
sb $t1, ($t0)
|
|
|
|
lb $t1, ($t0)
|
|
|
|
bnez $t1, BF_OPEN_1
|
|
|
|
BF_CLOSE_1:
|
2023-11-20 20:33:51 -05:00
|
|
|
addi $t0, $t0, 2
|
2023-11-20 19:24:45 -05:00
|
|
|
li $v0, 11
|
|
|
|
lb $a0, ($t0)
|
|
|
|
syscall
|
|
|
|
addi $t0, $t0, 1
|
|
|
|
lb $t1, ($t0)
|
2023-11-20 20:33:51 -05:00
|
|
|
subi $t1, $t1, 3
|
2023-11-20 19:24:45 -05:00
|
|
|
sb $t1, ($t0)
|
|
|
|
li $v0, 11
|
|
|
|
lb $a0, ($t0)
|
|
|
|
syscall
|
|
|
|
lb $t1, ($t0)
|
2023-11-20 20:33:51 -05:00
|
|
|
addi $t1, $t1, 7
|
2023-11-20 19:24:45 -05:00
|
|
|
sb $t1, ($t0)
|
|
|
|
li $v0, 11
|
|
|
|
lb $a0, ($t0)
|
|
|
|
syscall
|
|
|
|
lb $t1, ($t0)
|
2023-11-20 20:33:51 -05:00
|
|
|
addi $t1, $t1, 3
|
2023-11-20 19:24:45 -05:00
|
|
|
sb $t1, ($t0)
|
|
|
|
li $v0, 11
|
|
|
|
lb $a0, ($t0)
|
|
|
|
syscall
|
2023-11-20 20:33:51 -05:00
|
|
|
addi $t0, $t0, 2
|
2023-11-20 19:24:45 -05:00
|
|
|
li $v0, 11
|
|
|
|
lb $a0, ($t0)
|
|
|
|
syscall
|
|
|
|
subi $t0, $t0, 1
|
|
|
|
lb $t1, ($t0)
|
|
|
|
subi $t1, $t1, 1
|
|
|
|
sb $t1, ($t0)
|
|
|
|
li $v0, 11
|
|
|
|
lb $a0, ($t0)
|
|
|
|
syscall
|
|
|
|
subi $t0, $t0, 1
|
|
|
|
li $v0, 11
|
|
|
|
lb $a0, ($t0)
|
|
|
|
syscall
|
|
|
|
lb $t1, ($t0)
|
2023-11-20 20:33:51 -05:00
|
|
|
addi $t1, $t1, 3
|
2023-11-20 19:24:45 -05:00
|
|
|
sb $t1, ($t0)
|
|
|
|
li $v0, 11
|
|
|
|
lb $a0, ($t0)
|
|
|
|
syscall
|
|
|
|
lb $t1, ($t0)
|
2023-11-20 20:33:51 -05:00
|
|
|
subi $t1, $t1, 6
|
2023-11-20 19:24:45 -05:00
|
|
|
sb $t1, ($t0)
|
|
|
|
li $v0, 11
|
|
|
|
lb $a0, ($t0)
|
|
|
|
syscall
|
|
|
|
lb $t1, ($t0)
|
2023-11-20 20:33:51 -05:00
|
|
|
subi $t1, $t1, 8
|
2023-11-20 19:24:45 -05:00
|
|
|
sb $t1, ($t0)
|
|
|
|
li $v0, 11
|
|
|
|
lb $a0, ($t0)
|
|
|
|
syscall
|
2023-11-20 20:33:51 -05:00
|
|
|
addi $t0, $t0, 2
|
2023-11-20 19:24:45 -05:00
|
|
|
lb $t1, ($t0)
|
|
|
|
addi $t1, $t1, 1
|
|
|
|
sb $t1, ($t0)
|
|
|
|
li $v0, 11
|
|
|
|
lb $a0, ($t0)
|
|
|
|
syscall
|
|
|
|
addi $t0, $t0, 1
|
|
|
|
lb $t1, ($t0)
|
2023-11-20 20:33:51 -05:00
|
|
|
addi $t1, $t1, 2
|
2023-11-20 19:24:45 -05:00
|
|
|
sb $t1, ($t0)
|
|
|
|
li $v0, 11
|
|
|
|
lb $a0, ($t0)
|
|
|
|
syscall
|
2023-11-20 20:33:51 -05:00
|
|
|
li $v0, 11
|
|
|
|
lb $a0, ($t0)
|
|
|
|
syscall
|