From a81927344ce363dd96720e96b8aafdda49349389 Mon Sep 17 00:00:00 2001 From: Arthur Paulino Date: Fri, 5 Jan 2018 20:32:13 -0300 Subject: [PATCH] added a counting example --- Learn-by-Examples.md | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/Learn-by-Examples.md b/Learn-by-Examples.md index bdf371d..f5b4b93 100644 --- a/Learn-by-Examples.md +++ b/Learn-by-Examples.md @@ -48,9 +48,28 @@ HOLO_DISPLAY_COLOR EQU 4 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: #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 B, [DISPLAYED_DECIMAL] ; MOV the value that DISPLAYED_DECIMAL is pointing at into register B HWI HWID_HOLO ; ... 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 ``` \ No newline at end of file