mirror of
https://github.com/simon987/Much-Assembly-Required.git
synced 2025-04-21 03:26:44 +00:00
Annoted examples + fixed val
into *val
parent
f96f2017bf
commit
8832bdbc6e
@ -20,54 +20,58 @@ Note that the Hologram Projector will clear itself at the end of the tick, it is
|
|||||||
### Usage examples
|
### Usage examples
|
||||||
```assembly
|
```assembly
|
||||||
; Displaying the hexadecimal 0x000A
|
; Displaying the hexadecimal 0x000A
|
||||||
HWID_HOLO EQU 0x9
|
HWID_HOLO EQU 0x9 ;; setup constants
|
||||||
HOLO_DISPLAY_HEX EQU 1
|
HOLO_DISPLAY_HEX EQU 1
|
||||||
.data
|
.data
|
||||||
DISPLAYED_HEX EQU 0X000A
|
DISPLAYED_HEX EQU 0X000A ;; create a word in memory called DISPLAYED_HEX and set its value to
|
||||||
|
;; 0x000A
|
||||||
.text
|
.text
|
||||||
MOV A, HOLO_DISPLAY_HEX
|
MOV A, HOLO_DISPLAY_HEX ;; MOV the constant HOLO_DISPLAY_HEX into register A
|
||||||
MOV B, DISPLAYED_HEX
|
MOV B, [DISPLAYED_HEX] ;; MOV the value inside the memory spot DISPLAYED_HEX into register B
|
||||||
HWI HWID_HOLO
|
HWI HWID_HOLO ;; create an hardware interrupt which will do the magic of displaying
|
||||||
BRK
|
BRK ;; halt execution for the rest of this tick
|
||||||
```
|
```
|
||||||
```assembly
|
```assembly
|
||||||
; Displaying the string "hello!"
|
; Displaying the string "hello!"
|
||||||
HWID_HOLO EQU 0x9
|
HWID_HOLO EQU 0x9 ;; setup constants
|
||||||
HOLO_DISPLAY_STRING EQU 2
|
HOLO_DISPLAY_STRING EQU 2
|
||||||
.data
|
.data
|
||||||
DISPLAYED_STRING: DW "hello!", 0
|
DISPLAYED_STRING: DW "hello!", 0 ;; create a string in memory and point to it by DISPLAYED_STRING
|
||||||
|
;; the ',0' is a null word. This represents the end of the string
|
||||||
.text
|
.text
|
||||||
MOV A, HOLO_DISPLAY_STRING
|
MOV A, HOLO_DISPLAY_STRING ;; MOV the constant HOLO_DISPLAY_STRING into register A
|
||||||
MOV X, DISPLAYED_STRING
|
MOV X, DISPLAYED_STRING ;; MOV the pointer of DISPLAYED_STRING into register B
|
||||||
HWI HWID_HOLO
|
HWI HWID_HOLO ;; do the magic
|
||||||
BRK
|
BRK ;; halt execution until the next tick
|
||||||
```
|
```
|
||||||
```assembly
|
```assembly
|
||||||
; Displaying the decimal 42
|
; Displaying the decimal 42
|
||||||
HWID_HOLO EQU 0x9
|
HWID_HOLO EQU 0x9 ;; setup constants
|
||||||
HOLO_DISPLAY_DEC EQU 3
|
HOLO_DISPLAY_DEC EQU 3
|
||||||
.data
|
.data
|
||||||
DISPLAYED_DECIMAL EQU 42
|
DISPLAYED_DECIMAL EQU 42 ;; create a word in memory called DISPLAYED_DECIMAL and set its value
|
||||||
|
;; to 42
|
||||||
.text
|
.text
|
||||||
MOV A, HOLO_DISPLAY_DEC
|
MOV A, HOLO_DISPLAY_DEC ;; MOV the constant HOLO_DISPLAY_DEC into register A
|
||||||
MOV B, DISPLAYED_DECIMAL
|
MOV B, DISPLAYED_DECIMAL ;; MOV the value inside the memory spot DISPLAYED_HEX into register B
|
||||||
HWI HWID_HOLO
|
HWI HWID_HOLO ;; more magic
|
||||||
BRK
|
BRK ;; halt execution until next tick
|
||||||
```
|
```
|
||||||
```assembly
|
```assembly
|
||||||
; Displaying the decimal 42 in red
|
; Displaying the decimal 42 in red
|
||||||
HWID_HOLO EQU 0x9
|
HWID_HOLO EQU 0x9 ;; setup constants
|
||||||
HOLO_DISPLAY_DEC EQU 3
|
HOLO_DISPLAY_DEC EQU 3
|
||||||
HOLO_DISPLAY_COLOR EQU 4
|
HOLO_DISPLAY_COLOR EQU 4
|
||||||
.data
|
.data
|
||||||
DISPLAYED_DECIMAL EQU 42
|
DISPLAYED_DECIMAL EQU 42 ;; create a word in memory called DISPLAYED_DECIMAL and set its value
|
||||||
|
;; to 42
|
||||||
.text
|
.text
|
||||||
MOV A, HOLO_DISPLAY_COLOR
|
MOV A, HOLO_DISPLAY_COLOR ;; MOV the constant HOLO_DISPLAY_COLOR into register A
|
||||||
MOV B, 0x00FF
|
MOV B, 0x00FF ;; MOV the (immediate) value 0x00FF into register B
|
||||||
MOV C, 0x0000
|
MOV C, 0x0000 ;; clear register C
|
||||||
HWI HWID_HOLO
|
HWI HWID_HOLO ;; this interrupt will set the color to: #0000FF [C:B] also know as red
|
||||||
MOV A, HOLO_DISPLAY_DEC
|
MOV A, HOLO_DISPLAY_DEC ;; MOV the constant HOLO_DISPLAY_DEC into register A
|
||||||
MOV B, DISPLAYED_DECIMAL
|
MOV B, [DISPLAYED_DECIMAL] ;; MOV the value that DISPLAYED_DECIMAL is pointing at into register B
|
||||||
HWI HWID_HOLO
|
HWI HWID_HOLO ;; ...
|
||||||
BRK
|
BRK ;; halt execution until next tick
|
||||||
```
|
```
|
Loading…
x
Reference in New Issue
Block a user