summaryrefslogtreecommitdiff
path: root/programs/hex-to-bcd.s
diff options
context:
space:
mode:
Diffstat (limited to 'programs/hex-to-bcd.s')
-rw-r--r--programs/hex-to-bcd.s7
1 files changed, 7 insertions, 0 deletions
diff --git a/programs/hex-to-bcd.s b/programs/hex-to-bcd.s
new file mode 100644
index 0000000..53a3ff2
--- /dev/null
+++ b/programs/hex-to-bcd.s
@@ -0,0 +1,7 @@
+hex_to_bcd:
+ pla #1 ; Get argument.
+ div #10 ; Divide A by 10.
+ lsl #4 ; Shift the result left by 4 bits.
+ oab ; Or the result, with the remainder.
+ pha #1 ; Push the packed BCD result to the stack.
+ rts ; Return the result.