Refactor levels to YAML, remove icons, add vite-plugin-yaml

This commit is contained in:
2026-04-07 10:25:02 +01:00
parent bab0bb0c6b
commit 247cf85e57
17 changed files with 650 additions and 433 deletions

View File

@@ -0,0 +1,53 @@
id: 6
title: 移位操作
subtitle: 位的舞蹈
description: 学习 LSL 和 LSR 指令
tutorial:
- title: LSL —— 逻辑左移
text: >
所有位向左移右边补0。**左移1位 = 乘以2**左移3位 = 乘以8
code: |
; 5 = 00000101
LSL R0, R0, #1 ; 00001010 = 10 (×2)
LSL R0, R0, #1 ; 00010100 = 20 (×2)
- title: LSR —— 逻辑右移
text: >
所有位向右移左边补0。**右移1位 = 除以2**
code: |
MOV R0, #40
LSR R0, R0, #1 ; 20 (÷2)
LSR R0, R0, #2 ; 5 (÷4)
- title: 程序员的技巧
text: >
在真实的 ARM 处理器中,移位比乘除快得多!
`LSL R0, R0, #3` 比 `MUL R0, R0, #8` 高效。
goal: R0 = **5**,只用**移位操作**把它变成 **40**40 = 5 × 8 = 5 ×
initialState:
registers:
R0: 5
testCases:
- init: {}
expected:
registers:
R0: 40
hints:
- "8 = 2³乘以8就是左移3位"
- "LSL R0, R0, #3"
- "就这一条指令!"
starThresholds: [2, 3, 5]
blockedOps: [MUL, DIV]
starterCode: |
; R0 = 5
; 用 LSL 让 R0 变成 40不能用 MUL
HLT
showMemory: false