summaryrefslogtreecommitdiff
path: root/demo/demo1.asm
diff options
context:
space:
mode:
Diffstat (limited to 'demo/demo1.asm')
-rw-r--r--demo/demo1.asm63
1 files changed, 63 insertions, 0 deletions
diff --git a/demo/demo1.asm b/demo/demo1.asm
new file mode 100644
index 0000000..3ba82dd
--- /dev/null
+++ b/demo/demo1.asm
@@ -0,0 +1,63 @@
+; MCU 8051 IDE - Demostration code
+; Macro instructions, conditional compilation and constants
+; Try tab "Graph" on bottom panel
+
+; Press F2 and F6 to run the program (start simulator and animate)
+
+$TITLE('DEMO 2') ; Set title for code listing
+$DATE(36/-4/1907) ; Set date for code listing
+
+; Constant definitions
+; --------------------
+counter idata 00Fh ; Counter of Px shifts
+x set 100 ; Some variable
+inc_dec equ 100 / X ; Flag: Increment/Decrement counter
+
+ cseg at 1FFh ; Code segment starts at 0x1FF
+something: db 4d ; Reserve 4 bytes in this segment
+
+; Macro instructions
+; --------------------
+
+;; Shift the given registeres
+shift macro reg0, reg1
+
+ ; Increment / Decrement counter
+ mov A, counter
+ if inc_dec <> 0
+ inc A
+ else
+ dec A
+ endif
+ $nolist ; <- Disable code listing
+ mov counter, A
+ $list ; <- Enable code listing
+
+ ; Shift
+ mov reg1, reg0
+ mov reg0, reg1
+ setb C
+ mov A, reg0
+ rl A
+ mov reg0, A
+endm
+
+; Program initilization
+; --------------------
+ org 0h
+ sjmp start
+
+; Program start
+; --------------------
+start: mov P1, #00Fh
+ mov P3, #01Eh
+ sjmp main
+
+; Main loop
+; --------------------
+main: shift P1, P3
+ sjmp main
+
+; Program end
+; --------------------
+ end