Barotrauma 潜渊症

Barotrauma 潜渊症

评价数不足
Crazy Ivan's FizzBuzz
   
奖励
收藏
已收藏
取消收藏
文件大小
发表于
399.819 KB
2020 年 11 月 1 日 下午 8:32
1 项改动说明 ( 查看 )

订阅以下载
Crazy Ivan's FizzBuzz

描述
Here's a working `computer` loaded with the well-known `FizzBuzz` program.

Features:
- 84 memory registers which, in the von Neumann style, store both variables *and* program instructions.
- Arithmetic Logic Unit with 6 instructions: Add, Set, Jump, Greater, Modulo, and And.
- A bus composed of 4 wifi channels which select a memory address and read or write to it; this makes adding additional memory cells easy via copy and paste.
- Output (and with a little modification, input) through a single terminal.
- A 1.88Hz clock controls program flow in 8 phases, which correspond to:
```
Read the next instruction and increment the location of the next instruction.
Read the operands for the instruction.
Execute the instruction.
Write the result to memory.
```

Here's the program (each step takes up 3 memory cells: an instruction and 2 variable addresses):
- Jmp sets the next instruction to the second operand if the first operand is zero.
- All other operations replace the first operand's value with the result of the operation.
- Memory conventions: InstructionType, variableAddress, CONSTANT_ADDRESS, @program_step_address //comment
```
Add counter ONE //@program_start
Set divisibleBy3 counter
Set divisibleBy5 counter
Mod divisibleBy3 THREE
Mod divisibileBy5 FIVE
Set divisibleBy3&5 divisibleBy3
And divisibleBy3&5 divisibleBy5
Jmp divisibleBy3&5 @divisible_by_3
Set output FIZZBUZZ
Jmp ZERO @loop_check
Jmp divisibleBy3 @divisible_by_5 //@divisible_by_3
Set output FIZZ
Jmp ZERO @loop_check
Jmp divisibleBy5 @else_section //@divisible_by_5
Set output BUZZ
Jmp ZERO @loop_check
Set output counter //@else_section
Set keepLooping counter //@loop_check
Gtr keepLooping LOOP_LIMIT
Jmp keepLooping @program_start
Jmp ZERO @program_end //@program_end
```

Happy to answer questions in #baro-subs !
Full video: https://youtu.be/1FwRDzWpAbU
Steam Workshop: https://psteamcommunity.yuanyoumao.com/sharedfiles/filedetails/?id=2274975394
4 条留言
Crazy Ivan  [作者] 2021 年 6 月 19 日 上午 8:53 
@Voltz 84 registers because that's exactly how many the FizzBuzz program needed.
Voltz 2021 年 6 月 17 日 上午 2:26 
You, you made a computer in a game in another a computer. a computer so advanced it uses von neumann architecture and 84 memory registers. have to ask though, why 84?
Darksteelknight 2021 年 3 月 20 日 下午 4:22 
Beautiful
Mexican Man 2021 年 1 月 2 日 下午 8:30 
holy shiiiiiiit