summaryrefslogtreecommitdiff
path: root/examprep/bin/main.dbg
diff options
context:
space:
mode:
authorJacob McDonnell <jacob@jacobmcdonnell.com>2025-02-10 17:35:01 -0500
committerJacob McDonnell <jacob@jacobmcdonnell.com>2025-02-10 17:35:01 -0500
commitdb27faf84654f0084542536e538044a0458bb554 (patch)
tree9df700cc7bc02dd2c80006306e5fd8d24ba908c1 /examprep/bin/main.dbg
parentbdb2965d02e8e8fa8f1fdf00e27718f6b048fb06 (diff)
HW4 Initial
Diffstat (limited to 'examprep/bin/main.dbg')
-rw-r--r--examprep/bin/main.dbg65
1 files changed, 65 insertions, 0 deletions
diff --git a/examprep/bin/main.dbg b/examprep/bin/main.dbg
new file mode 100644
index 0000000..cd3eb3d
--- /dev/null
+++ b/examprep/bin/main.dbg
@@ -0,0 +1,65 @@
+**************************************************************************
+* Parameter Declearation Section
+*
+* Export Symbols
+ xdef pgstart ; export 'pgstart' symbol
+ absentry pgstart ; for assembly entry point
+
+* Symbols and Macros
+PORTA equ $0000 ; i/o port A addresses
+DDRA equ $0002 ; data direction register for PORTA
+PORTB equ $0001 ; i/o port B addresses
+DDRB equ $0003 ; data direction register for PORTB
+
+**************************************************************************
+* Data Section: address used [ $3000 to $30FF ] RAM Memory
+*
+ org $3000 ; Reserved RAM memory starting address
+ ; for Data for CMPEN 472 class
+SOURCE ds.b $000C ; 12 Byte source array
+
+LENSRC dc.w $000C ; Length of the Source Array
+
+DEST ds.b $000C ; 12 Byte destination array
+
+LENDST dc.w $000C ; Length of the destination array
+
+StackSP dc.w $3100 ; Address of the stack
+
+*
+**************************************************************************
+* Program Section: address used [ $3100 to $3FFF ] RAM Memory
+*
+ org $3100 ; Program start address, in RAM
+pgstart lds StackSP ; initialize the stack pointer
+ ldaa #1 ; Load 1 into A
+ ldx #SOURCE ; Load the address of SOURCE into X
+ ldy LENSRC ; Load the length of SOURCE into Y
+fillLoop tbeq Y,doneLoop ; If Y==0, jump to done loop
+ staa 1,X+ ; Copy A into address of X, add 1 to X
+ inca ; Increment A by 1
+ dey ; Decrement Y by 1
+ bra fillLoop ; Jump to fillLoop
+doneLoop jsr memcpy ; Call memcpy
+ bra done
+
+
+memcpy pshy ; Save Y to the stack
+ pshx ; Save X to the stack
+ pshd ; Save D to the stack
+ ldy #SOURCE ; Load the address of the source array into Y
+ ldx #DEST ; Load the address of the destination array into X
+ ldd LENSRC ; Load the length of the source array into D
+loop tbeq D,EXIT ; If d==0, jump to EXIT
+ movb Y,X ; Copy data from address in Y to address in X
+ inx ; Increment X by 1
+ iny ; Increment Y by 1
+ subd #1 ; Decrement D by 1
+ bra loop ; Branch always to loop
+EXIT puld ; Restore D from the stack
+ pulx ; Restore X from the stack
+ puly ; Restore Y from the stack
+ rts ; Return to caller
+
+
+done