mirror of
https://github.com/simon987/Much-Assembly-Required.git
synced 2025-04-19 18:46:43 +00:00
added a counting example
parent
7664174f14
commit
a81927344c
@ -48,9 +48,28 @@ HOLO_DISPLAY_COLOR EQU 4
|
|||||||
MOV A, HOLO_DISPLAY_COLOR ; MOV the constant HOLO_DISPLAY_COLOR into register A
|
MOV A, HOLO_DISPLAY_COLOR ; MOV the constant HOLO_DISPLAY_COLOR into register A
|
||||||
MOV B, 0x00FF ; MOV the (immediate) value 0x00FF into register B
|
MOV B, 0x00FF ; MOV the (immediate) value 0x00FF into register B
|
||||||
MOV C, 0x0000 ; clear register C: no green and no blue
|
MOV C, 0x0000 ; clear register C: no green and no blue
|
||||||
HWI HWID_HOLO ; this interrupt will set the color to: #0000FF [C:B] also know as red
|
HWI HWID_HOLO ; this interrupt will set the color to: #FF0000 [B:C] also know as red
|
||||||
MOV A, HOLO_DISPLAY_DEC ; MOV the constant HOLO_DISPLAY_DEC into register A
|
MOV A, HOLO_DISPLAY_DEC ; MOV the constant HOLO_DISPLAY_DEC into register A
|
||||||
MOV B, [DISPLAYED_DECIMAL] ; MOV the value that DISPLAYED_DECIMAL is pointing at into register B
|
MOV B, [DISPLAYED_DECIMAL] ; MOV the value that DISPLAYED_DECIMAL is pointing at into register B
|
||||||
HWI HWID_HOLO ; ...
|
HWI HWID_HOLO ; ...
|
||||||
BRK ; halt execution until next tick
|
BRK ; halt execution until next tick
|
||||||
```
|
```
|
||||||
|
```assembly
|
||||||
|
; Count from 42 in red
|
||||||
|
HWID_HOLO EQU 0x9 ; setup constants
|
||||||
|
HOLO_DISPLAY_DEC EQU 3
|
||||||
|
HOLO_DISPLAY_COLOR EQU 4
|
||||||
|
.data
|
||||||
|
DISPLAYED_DECIMAL: DW 42 ; create a word in memory called DISPLAYED_DECIMAL and set its value
|
||||||
|
; to 42
|
||||||
|
.text
|
||||||
|
MOV A, HOLO_DISPLAY_COLOR ; MOV the constant HOLO_DISPLAY_COLOR into register A
|
||||||
|
MOV B, 0x00FF ; MOV the (immediate) value 0x00FF into register B
|
||||||
|
MOV C, 0x0000 ; clear register C: no green and no blue
|
||||||
|
HWI HWID_HOLO ; this interrupt will set the color to: #FF0000 [B:C] also know as red
|
||||||
|
MOV A, HOLO_DISPLAY_DEC ; MOV the constant HOLO_DISPLAY_DEC into register A
|
||||||
|
MOV B, [DISPLAYED_DECIMAL] ; MOV the value that DISPLAYED_DECIMAL is pointing at into register B
|
||||||
|
HWI HWID_HOLO ; ...
|
||||||
|
ADD [DISPLAYED_DECIMAL], 1 ; adds 1 to the value pointed by DISPLAYED_DECIMAL
|
||||||
|
BRK ; halt execution until next tick
|
||||||
|
```
|
Loading…
x
Reference in New Issue
Block a user