388b505e0b
- 后端 FastAPI 重写为 axum + rusqlite (musl static, 2.8MB) - 前端原样搬运 (Vue3 + Vite + Pinia + vue-router + vite-plugin-yaml) - k8s: cube-simpleasm ns + 1Gi PVC (k3s local-path) + Recreate strategy - CI: 复刻 deploy-cube.yml,按 apps/simpleasm/** 触发 - cube 门户里 simpleasm 状态从 pending 改成 live - 数据冷启 (Fam 拍板不带历史进度)
53 lines
1.3 KiB
YAML
53 lines
1.3 KiB
YAML
id: 9
|
|
title: Loops
|
|
subtitle: The power of repetition
|
|
description: Use branches to build a loop
|
|
|
|
tutorial:
|
|
- title: What is a loop?
|
|
text: >
|
|
A loop runs the same code **over and over**. In assembly, a loop is just
|
|
**branching back to a label**!
|
|
- title: Loop structure
|
|
text: >
|
|
① initialize ② do work ③ update the counter ④ test + branch back:
|
|
code: |
|
|
MOV R4, #0 ; ① initialize
|
|
loop: ; loop start
|
|
ADD R4, R4, #1 ; ②③ counter += 1
|
|
CMP R4, #5 ; ④ reached 5?
|
|
BLE loop ; not yet, jump back
|
|
XHLT
|
|
- title: Watch out!
|
|
text: >
|
|
Forget to update the counter and you've made an **infinite loop**
|
|
(don't worry — execution stops automatically after 10000 steps).
|
|
|
|
goal: Compute **1+2+3+...+10** into **R0** (the answer is 55)
|
|
|
|
initialState: {}
|
|
|
|
testCases:
|
|
- init: {}
|
|
expected:
|
|
registers:
|
|
R0: 55
|
|
|
|
hints:
|
|
- "R0 accumulates the sum, R4 is the counter (1 to 10)"
|
|
- "Loop body: ADD R0, R0, R4 / ADD R4, R4, #1 / CMP R4, #10 / BLE loop"
|
|
- "Full: MOV R0, #0 / MOV R4, #1 / loop: ADD R0, R0, R4 / ADD R4, R4, #1 / CMP R4, #10 / BLE loop / XHLT"
|
|
|
|
starThresholds: [7, 9, 12]
|
|
|
|
starterCode: |
|
|
; Compute 1+2+3+...+10
|
|
; Result goes in R0
|
|
;
|
|
; Tip: use a register as the counter
|
|
|
|
|
|
XHLT
|
|
|
|
showMemory: false
|