Refactor levels to YAML, remove icons, add vite-plugin-yaml
This commit is contained in:
53
frontend/src/lib/levels/06.yaml
Normal file
53
frontend/src/lib/levels/06.yaml
Normal 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 × 2³)
|
||||
|
||||
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
|
||||
Reference in New Issue
Block a user