diff --git a/Assembly-program-examples.md b/Assembly-program-examples.md index 08adf07..f73f2a4 100644 --- a/Assembly-program-examples.md +++ b/Assembly-program-examples.md @@ -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 +
+ +Constants by hackersoup with help from +contributors +
+Insert this code before the new code you write for MuchAssemblyRequired, and use a text editor like VSCode, Notepad++, Sublime, etc. for auto-complete. +
+ +``` ;; 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 ``` +
+ +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