1
0
mirror of https://github.com/adambard/learnxinyminutes-docs.git synced 2025-08-06 14:56:54 +02:00

Fix off-by-one error

Iterate from 0..9, i.e. while $t0 is < 10
This commit is contained in:
xnumad
2023-03-24 21:43:38 +01:00
committed by GitHub
parent f1a149c860
commit d1d1c4af86

View File

@@ -213,8 +213,9 @@ gateways and routers.
# instruction to continue its execution # instruction to continue its execution
li $t0, 0 li $t0, 0
while: while:
bgt $t0, 10, end_while # While $t0 is less than 10, bgt $t0, 9, end_while # While $t0 is less than 10,
# keep iterating # keep iterating
#actual loop content would go here
addi $t0, $t0, 1 # Increment the value addi $t0, $t0, 1 # Increment the value
j while # Jump back to the beginning of j while # Jump back to the beginning of
# the loop # the loop