Due September, 16th 2008
Write a program that swaps the upper and lower 4 bits in a byte. For example if the input byte has a value of $D8 the result should be $8D. The input byte should be loaded into Accu A and the result should also be contained in Accu A. Write the program like a subroutine ending in RTS like the block fill examples. Look at the command set of the HC12 processor in particular bit-shift operations to accomplish the task. Each entry must be an individual contribution.
*********************************************************************************** * Program to swap first four and last four bits of an eight bit byte * * Example Given in Class September 11, 2008, EE 3362, Michael Giesselman * *********************************************************************************** ORG $1000 ; Assembler Directive LDAA #$C9 ; Load ACCU A with $C9 LDAB #$C9 ; Load ACCU B with #c9 LSRA ; Shift ACCU A to the right 1 bit LSRA ; Shift ACCU A to the right 1 bit LSRA ; Shift ACCU A to the right 1 bit LSRA ; Shift ACCU A to the right 1 bit LSLB ; Shift ACCU B to the left 1 bit LSLB ; Shift ACCU B to the left 1 bit LSLB ; Shift ACCU B to the left 1 bit LSLB ; Shift ACCU B to the left 1 bit STAA $1050 ; ORAB $1050 ; OR register A with register B RTS
*********************************************************************************** * Program to swap first four and last four bits of an eight bit byte * * Example Given in Class September 16, 2008, EE 3362, Michael Giesselman * *********************************************************************************** ORG $1000 ; Assembler Directive LDAA #$C9 ; Load ACCU A with $C9 LDAB #$C9 ; Load ACCU B with $C9 LDX #4 ; Load X with 4 LOOP: LSRA ; Logical Shift Right ACCU A LSLB ; Logical Shift Left ACCU B DBNE X, Loop STAA $0850 ORAB $0850 RTS
If you are having trouble with the MiniIDE giving an error like A2003, "can't find asm12.exe," or every line of your program has an error here are a few things to try before pulling your hair or asking the professor.
Comments
Matt, This solved the
Matt,
This solved the saving the program file problem!!!! THANKS!!! Now I have to figure out how to run the simulator. I keep getting errors when I try to load the program. I tried changing the above values/range to $0850, but this didn't work either. What do you think I'm doing wrong?
--Gabe
Remember you also need to
Remember you also need to change ORG $800 so that the originating memory address starts at $800 instead of $1000. This older processor has RAM from $0800 - $0BFF.
Hope this helps,
-mpare
Post new comment