Advertisement
Guest User

Untitled

a guest
Dec 6th, 2019
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.78 KB | None | 0 0
  1. Lab 1 - Assemble and Trace
  2. Introduction
  3. The purpose of this lab was to become familiar with writing Assembly code using the CodeWarrior IDE.
  4.  
  5. Software and Hardware Used
  6. CodeWarrior IDE 5.2
  7. HCS12 Emulator
  8.  
  9. Methods
  10. The HCS12 manual was used as a reference for the different Assembly instructions supported by the CPU
  11. The main instructions used were LDAA, ADDA, and STAA
  12.  
  13. Data
  14. All values are encoded as part of the Assembly instructions
  15. (immediate addressing)
  16.  
  17. Result
  18. Result 0x98 stored in memory location $210
  19.  
  20. Discussion
  21. This was a good introduction to basic Assembly programming, and I became familiar with some basic Assembly instructions.
  22. This lab also got me used to the development environment and simulation tool.
  23.  
  24.  
  25.  
  26.  
  27.  
  28. Lab 2 - Directives, Addressing Modes and Basic Arithmetic Programming
  29. Introduction
  30. The purpose of this lab was to use arithmetic operations in Assembly code.
  31.  
  32. Software and Hardware Used
  33. CodeWarrior IDE 5.2
  34. HCS12 Emulator
  35.  
  36. Methods
  37. Similar instructions used as previous lab, but involved more registers and more arithmetic commands such as IDIV
  38. IDIV is inherently addressed, and operates on a fixed set of registers that needed to be loaded with the correct values before executing the instruction, and the results stored after executing the instruction
  39.  
  40. Data
  41. Array stored at $2000:
  42. 50, 188, 63, 211, 3
  43.  
  44. Result
  45. Sum stored at $2010-$2011 = 515
  46. Average stored at $2012-$2013 = 103
  47. Difference stored at $2014-$2015 = 412
  48.  
  49. Discussion
  50. This lab used more commands and registers than the previous lab, and further familiarized me with the IDE and the HCS12 instruction set.
  51. This lab was a good introduction to 16-bit values and how certain registers on the HCS12 are different sizes than others.
  52.  
  53.  
  54.  
  55.  
  56.  
  57. Lab 3 - Directives, Addressing Modes and Basic Arithmetic Programming
  58. Introduction
  59. The purpose of this lab was to use arithmetic operations in Assembly code.
  60.  
  61. Software and Hardware Used
  62. CodeWarrior IDE 5.2
  63. HCS12 Emulator
  64.  
  65. Methods
  66. This lab used more instructions, especially control flow instructions
  67. (conditional and unconditional branch, jump)
  68. Comparison instructions were used to determine if a conditional branch was taken or not
  69.  
  70. Data
  71. Array stored at $2000:
  72. 13, 127, 255, 88, 200, 58, 211, 101, 168, 44
  73.  
  74. Result
  75. Unsigned minimum stored at $2200 = 0x0D
  76. Unsigned maximum stored at $2201 = 0xFF
  77. Difference stored at $2202 = 0xF2
  78. Signed minimum stored at $2203 = 0xC8
  79. Signed maximum stored at $2204 = 0x7F
  80.  
  81. Discussion
  82. This lab was a good introduction to control flow instructions and comparison instructions, which were heavily used in the rest of the labs
  83.  
  84.  
  85.  
  86.  
  87.  
  88. Lab 4 - Loop and Branch
  89. Introduction
  90. The purpose of this lab was to use loop instructions and branch instructions in Assembly language.
  91.  
  92. Software and Hardware Used
  93. CodeWarrior IDE 5.2
  94. HCS12 Emulator
  95.  
  96. Methods
  97. This lab used similar instructions as the previous lab
  98. The Y register was used for the loop counter instead of the X register to simplify programming, since the D and X registers were used by the IDIV instruction, and there is no way to change IDIV to use a different set of registers
  99.  
  100. Data
  101. Array stored at $1100:
  102. 133, 1200, 1390, 1900, 1881, 3939, 2010, 4080, 9801, 4592, 11, 22, 33, 3333, 3242, 5435, 8760, 9800, 2876, 9601
  103.  
  104. Result
  105. Even count stored at $1000 = 0x09
  106. Odd count stored at $1001 = 0x0B
  107. Sum stored at $1002 = 0x14
  108.  
  109. Discussion
  110. This lab built on the previous lab, and was more practice on using control flow instructions and looping.
  111.  
  112.  
  113.  
  114.  
  115.  
  116. Lab 5 - Nested Loops
  117. Introduction
  118. The purpose of this lab was to use loop instructions and branch instructions in Assembly language, and to nest the loop instructions.
  119.  
  120. Software and Hardware Used
  121. CodeWarrior IDE 5.2
  122. HCS12 Emulator
  123.  
  124. Methods
  125. This lab used similar instructions as the previous lab, but looped using both the X and Y registers, for a nested loop.
  126. Both loops work by initializing the register to 0, and incrementing it by one until it reaches a predefined value, and at that point the program will branch to the next part or finish.
  127.  
  128. Data
  129. Array stored at $1000:
  130. 15, 20, 14, 13, 17, 9, 10, 5, 18, 7, 19, 8, 1, 3, 4, 11, 2, 6, 12, 16
  131.  
  132. Result
  133. Results stored at $1000, replacing the original data:
  134. 0x14, 0x13, 0x12, 0x11, 0x10, 0x0F, 0x0E, 0x0D, 0x0C, 0x0B, 0x0A, 0x09, 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01
  135.  
  136. Discussion
  137. This lab was simple once I properly used registers to store loop indexes and the program’s state. Adding a nested loop within the first loop was not a challenge.
  138.  
  139.  
  140.  
  141.  
  142.  
  143. Lab 6 - Subroutines
  144. Introduction
  145. The purpose of this lab was to use subroutines in Assembly language.
  146.  
  147. Software and Hardware Used
  148. CodeWarrior IDE 5.2
  149. HCS12 Emulator
  150.  
  151. Methods
  152. This lab was supposed to be based on subroutines, but I ended up using clever workarounds to avoid using a subroutine.
  153. I also did not want to make more than one comparison for each grade range. Instead of checking if a grade was more than one amount and less than another (inside of a range), I made 5 checks, checking if it was equal to or above each letter grade threshold. For each check that passed, a counter was incremented one time. After the CPU makes the 5 checks, it branches to a different part of the code depending on the value of the counter, and that code increments the correct location in memory for tallying the number of students that got each letter grade.
  154.  
  155. Data
  156. Array stored at $1000:
  157. 76, 95, 87, 92, 87, 91, 91, 100, 79, 50, 81, 86, 100, 90, 77, 54, 87, 100, 87, 79, 77, 76, 100, 100, 82, 85, 100, 100, 51, 100, 83, 82, 100, 92, 92, 91, 66, 62, 80, 82, 79
  158.  
  159. Result
  160. Results stored in memory as an array starting from $1050:
  161. 0x11, 0x0C, 0x06, 0x02, 0x03
  162.  
  163. Discussion
  164. I did not feel like I understood how subroutines work on the HCS12 when I wrote the code, and wanted to see if I could efficiently write the program without using any subroutines.
  165. The program uses control flow instructions, but none of them use the stack to store a return address.
  166. I ended up practicing using subroutines before the next lab, and used them heavily in the next lab once I felt I sufficiently understood how they worked.
  167.  
  168.  
  169.  
  170.  
  171. Lab 7 - Parallel I/O
  172. Introduction
  173. The purpose of this lab was to use the HCS12 parallel ports to connect to LEDs and pushbuttons on the emulated Dragon12 development board.
  174.  
  175. Software and Hardware Used
  176. CodeWarrior IDE 5.1 Special Edition
  177. HCS12 Emulator
  178.  
  179. Methods
  180. This lab did not use many complex instructions, since reading or writing IO ports is as simple as storing a value into memory.
  181. This code runs on real hardware with very few modifications (move the entry point to the starting location of the Dragon12’s FLASH memory)
  182.  
  183. Data
  184. None
  185.  
  186. Result
  187. None
  188.  
  189. Discussion
  190. This lab was a good introduction to the HCS12’s I/O ports, and the code worked almost right away on real hardware.
  191. I did not expect it to be this easy to use the I/O ports on the HCS12.
  192.  
  193.  
  194.  
  195.  
  196.  
  197. Lab 8 - Parallel I/O (Hardware)
  198. Introduction
  199. The purpose of this lab was to upload the code from Lab 7 onto a real development board, and verify it works correctly on real hardware.
  200.  
  201. Software and Hardware Used
  202. CodeWarrior IDE 5.1 Special Edition
  203. HCS12 Dragon12-Plus2 Development Board
  204.  
  205. Methods
  206. The code from Lab 7 worked with very few changes required. The hardest part of this lab was getting the devkit to communicate with the computer at all.
  207.  
  208. Data
  209. None
  210.  
  211. Result
  212. None
  213.  
  214. Discussion
  215. This lab was great practice for uploading a simple program to the Dragon12 devkit, and reminded me of many years ago when I uploaded my first Arduino program. Both boards were hard to initially set up and configure to connect with the PC, but once connected, were easy to program for.
  216. After getting the basic program to work correctly, I used the online HCS12 and Dragon12 reference manuals to add more features to the code. My second version of this lab controls the 7-segment displays, LCD screen, and buzzer in addition to the LEDs.
  217. Controlling the 7-segment displays proved to be a hard and time consuming task to perfect, since the digits are multiplexed and share pins. They also share the B port with the LEDs, thus it is necessary to disable the LEDs when displaying numbers on the digits. Each digit has to be lit one at a time and cycled very fast to give the impression that they are all lit at once. The code has to run fast enough or else it will look strange (the LEDs will appear to flicker). An issue that caused the program to run slowly was the necessity to add a delay to debounce the switches, and a shorter delay when sending commands to the LCD screen driver, since it does not run as fast as the main HCS12 CPU. Whenever the program entered a delay, I turned off the 7-segment display so it would not flicker or look erratic. The code worked correctly from the beginning, but it took many hours of debugging to prevent the 7-segment display from flickering.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement