mirror of
https://github.com/simon987/Much-Assembly-Required.git
synced 2025-04-16 01:06:43 +00:00
Use collapse (details and summary) html tags for the long list of constants and add example using constants (print_battery)
parent
56ecc383e7
commit
2801bfaade
@ -78,11 +78,17 @@ y_is_positive:
|
||||
|
||||
POP BP ; Restore the previous stack frame
|
||||
RET 2 ; Return and POP our 2 arguments
|
||||
|
||||
```
|
||||
|
||||
Constants by hackersoup with [more contributors](https://github.com/simon987/Much-Assembly-Required/wiki/Assembly-program-examples/_history)
|
||||
```assembly
|
||||
<details>
|
||||
<summary>
|
||||
Constants by hackersoup with help from
|
||||
<a href="https://github.com/simon987/Much-Assembly-Required/wiki/Assembly-program-examples/_history">contributors</a>
|
||||
<br>
|
||||
Insert this code before the new code you write for MuchAssemblyRequired, and use a text editor like VSCode, Notepad++, Sublime, etc. for auto-complete.
|
||||
</summary>
|
||||
|
||||
```
|
||||
;; Hardware IDs
|
||||
HWID_LEGS equ 0x1
|
||||
HWID_LASER equ 0x2
|
||||
@ -249,6 +255,33 @@ FLOPPY_WRITE_SECTOR equ 3 ; Cost: 1kJ
|
||||
;; Read and write operations are synchronous. Track seeking time is 2ms.*
|
||||
;; *Seek time is added to the total execution time, which is not yet calculated as of v1.3a
|
||||
```
|
||||
</details>
|
||||
|
||||
example usage using these constants
|
||||
```assembly
|
||||
.text
|
||||
CALL print_battery
|
||||
|
||||
;;;;; void print_battery()
|
||||
; display / print remaing battery charge
|
||||
; does not require arguments from stack or register prior to calling
|
||||
; does not overwrite or alter stack or registers
|
||||
print_battery:
|
||||
PUSH A ; store A
|
||||
PUSH B ; store B
|
||||
|
||||
MOV A, BATTERY_POLL ; indicates we want to poll the battery charge when interrupt sent to battery
|
||||
HWI HWID_BATTERY ; battery remaining charge (kilo Joules)
|
||||
; is stored in B register now
|
||||
|
||||
MOV A, HOLO_DISPLAY_HEX ; HOLO_DISPLAY_HEX == BATTERY_POLL == 1
|
||||
; makes this redundant, but you get the idea
|
||||
HWI HWID_HOLO ; value in B register is displayed on your bot
|
||||
|
||||
POP B
|
||||
POP A
|
||||
RET
|
||||
```
|
||||
|
||||
Dump memory to disk
|
||||
```assembly
|
||||
|
Loading…
x
Reference in New Issue
Block a user