[Solved] ECE 362 Lab Verification / Evaluation Form Experiment 2

$25

File Name: ECE_362_Lab_Verification_/_Evaluation_Form_Experiment_2.zip
File Size: 518.1 KB

SKU: [Solved] ECE 362 Lab Verification / Evaluation Form Experiment 2 Category: Tag:
5/5 - (1 vote)

ECE 362 Lab Verification / Evaluation FormExperiment 2Evaluation:IMPORTANT! You must complete this experiment during your scheduled lab period. All work for this experiment must be demonstrated to and verified by your lab instructor before the end of your scheduled lab period.STEP DESCRIPTION MAX SCORE1 Data Transfer Group Instructions 32 Arithmetic Group Instructions 63 Logical Group Instructions 54-A Code Segment A 24-B Code Segment B 24-C Code Segment C 24-D Code Segment D 24-E Code Segment E 25 Thought Questions 1TOTAL 25Signature of Evaluator: ________________________________________________________Academic Honesty Statement:IMPORTANT! Please carefully read and sign the Academic Honesty Statement, below.You will not receive credit for this lab experiment unless this statement is signed in the presence of your lab instructor.In signing this statement, I hereby certify that the work on this homework and experiment is my own and that I have not copied the work of any other student (past or present) while completing them. I understand that if I fail to honor this agreement, I will receive a score of ZERO and be subject to possible disciplinary action.Printed Name: _____________________ Class No. __ __ __ __ __Signature: ____________________________________ Date: _______ECE 362 Experiment 2 Rev 8/12Bigger Bytes Lab Manual -1- 2012 by D. G. MeyerExperiment 2: Assembly Language Programming Techniques Part 1Instructional Objectives: To learn more about the HC(S)12 Instruction Set To learn about basic assembly language programming techniques by examining severalprogram modules, testing their operation using appropriate data, and modifying thesemodules.References: S12CPUV2 Reference Manual, Sections 2, 3, 5, and Appendix A (on course web site) CPU12 Reference Guide (on course web site)Pre-lab Preparation: Read this document in its entirety Review the description of the HC(S)12 instruction set provided in Chapter 3 of the Meyertext Fill in all the Before Execution boxes for Steps 1-3 and complete the skeleton fileprovided for Step 4Introduction:A clear understanding of a machines instruction set (the tools in the toolbox) is essential tosuccessful assembly language programming. The primary objective of this laboratory exercise istherefore to provide practical experience with the HC(S)12 instruction set and its plethora ofaddressing modes material that is covered in Chapter 3 of the text. To accomplish this goal,you will complete a number of exercises dealing with commonly-used HC(S)12 instructions andaddressing modes. Using the Microcontroller Kit, you will execute the code segments you havewritten with appropriate test data you have chosen. This will help reinforce your understandingof how instructions and data are stored in memory, plus help prepare you for future debugging ofmore complex programs.In the first part of this experiment you will examine representative instructions from thefollowing general groups: data transfer, arithmetic, and logical. There will be a number of shortexercises for which you will be asked to write a code segment and assemble the statements intomachine code. For each exercise, you will also pick appropriate test data and perform anymemory and/or register initializations necessary to carry out the exercise. You will then executethe code segments on the Microcontroller Kit, and record the results of the execution in theprovided tables. The primary objectives of these exercises is to enhance your understanding ofhow instructions and data are stored in memory, provide practice in determining meaningful testdata, provide practice in examining the results of instruction execution, and help prepare you forfuture debugging of more complex program.In the second part of the experiment, you will combine instructions together to create codesegments that perform some meaningful and perhaps socially-redeeming tasks (e.g., extendedprecision arithmetic). The same tools used to analyze the execution of isolated instructions willbe used to examine the behavior of the code segments you write.ECE 362 Experiment 2 Rev 8/12Bigger Bytes Lab Manual -2- 2012 by D. G. MeyerStep 1: Data Transfer Group InstructionsThis group consists of instructions that move data between registers or between memorylocations and registers. A list of some of the HC(S)12 instructions that comprise this category isshown below.Mnemonic DescriptionEXG Exchange register valuesLD Load registerMOV Move memoryST Store registerTFR Transfer register to registerLEA Load Effective AddressPSH Push data onto stackPUL Pull data from stackSTEP 1-A: MOVW instruction using immediate/extended addressing modes.STEP 1-B: LEA instruction using accumulator offset indexed addressing mode.Assembly Instruction(s) Machine Code Relevant Memory Relevant RegistersBefore execution: Before execution:After execution: After execution:Assembly Instruction(s) Machine Code Relevant Memory Relevant RegistersBefore execution: Before execution:After execution: After execution:ECE 362 Experiment 2 Rev 8/12Bigger Bytes Lab Manual -3- 2012 by D. G. MeyerSTEP 1-C: PSHA instruction, followed by PSHB and PULD.Assembly Instruction(s) Machine Code Relevant Memory Relevant RegistersBefore execution: Before execution:After execution: After execution:Step 2: Arithmetic Group InstructionsThis group consists of instructions which add, subtract, increment, or decrement data in registersor memory. A list of some of the HC(S)12 instructions that comprise this group appears below.Mnemonic DescriptionADC Add with carryADD AddDEC Decrement by 1INC Increment by 1DAA Decimal adjust accumulator AMUL MultiplySUB SubtractSBC Subtract with carry (borrow)STEP 2-A: ADCB instruction using immediate addressing mode.Assembly Instruction(s) Machine Code Relevant Memory Relevant RegistersBefore execution: Before execution:After execution: After execution:ECE 362 Experiment 2 Rev 8/12Bigger Bytes Lab Manual -4- 2012 by D. G. MeyerSTEP 2-B: ADDD instruction using extended addressing mode.Assembly Instruction(s) Machine Code Relevant Memory Relevant RegistersBefore execution: Before execution:After execution: After execution:STEP 2-C: ADDA instruction using immediate addressing, followed by DAA instruction.Assembly Instruction(s) Machine Code Relevant Memory Relevant RegistersBefore execution: Before execution:After execution: After execution:STEP 2-D: SUBA instruction using immediate addressing, followed by DAA instruction(what goes wrong?).Assembly Instruction(s) Machine Code Relevant Memory Relevant RegistersBefore execution: Before execution:After execution: After execution:ECE 362 Experiment 2 Rev 8/12Bigger Bytes Lab Manual -5- 2012 by D. G. MeyerSTEP 2-E: EMUL instruction using inherent addressing mode.Assembly Instruction(s) Machine Code Relevant Memory Relevant RegistersBefore execution: Before execution:After execution: After execution:STEP 2-F: FDIV instruction using inherent addressing mode.Assembly Instruction(s) Machine Code Relevant Memory Relevant RegistersBefore execution: Before execution:After execution: After execution:Step 3: Logical Group InstructionsThis group includes instructions which perform ANDs, ORs, XORs, compares, rotates, orcomplements of data in registers or memory. Some of the HC(S)12 instructions that comprisethis group are listed below.Mnemonic DescriptionAND Bit-wise ANDOR Bit-wisel OREOR Bit-wise XORASL or LSL Arithmetic (logical) shift leftASR Arithmetic shift rightCMP CompareTST Test for zero or minusROL Rotate left through carryROR Rotate right through carryECE 362 Experiment 2 Rev 8/12Bigger Bytes Lab Manual -6- 2012 by D. G. MeyerSTEP 3-A: LSLA instruction using inherent addressing mode.Assembly Instruction(s) Machine Code Relevant Memory Relevant RegistersBefore execution: Before execution:After execution: After execution:STEP 3-B: RORB instruction using inherent addressing mode.Assembly Instruction(s) Machine Code Relevant Memory Relevant RegistersBefore execution: Before execution:After execution: After execution:STEP 3-C: CPX instruction using extended addressing mode.Assembly Instruction(s) Machine Code Relevant Memory Relevant RegistersBefore execution: Before execution:After execution: After execution:ECE 362 Experiment 2 Rev 8/12Bigger Bytes Lab Manual -7- 2012 by D. G. MeyerSTEP 3-D: ANDCC instruction using immediate addressing mode.Assembly Instruction(s) Machine Code Relevant Memory Relevant RegistersBefore execution: Before execution:After execution: After execution:STEP 3-E: ORCC instruction using immediate addressing mode.Assembly Instruction(s) Machine Code Relevant Memory Relevant RegistersBefore execution: Before execution:After execution: After execution:Step 4: Writing Code SegmentsIn the previous experiment you were introduced to various embedded system softwaredevelopment tools. You learned about the translation of assembly language instructions to andfrom machine code in the assembly and disassembly exercises. Finally, you executed a specificinstruction using a variety of different addressing modes. Given those tools, the next objective isto learn how instructions work together. To achieve this, you will be asked to write severalsmall segments of code. Each segment of code will have a defined function it is to perform andconstraints will be given on how it is done or what it can modify in the process. It is importantto learn to write code within those constraints since you will often be writing a portion of aprogram that will interface with other code in a specific way.A skeleton file to facilitate completion of this step is available on the course web site(reproduced below for your reference). The description of each program is contained in theheader section. You should download a copy of the file and fill in the code segments whereindicated. To test the code, you will assemble and download the file, initialize any requiredregister or memory locations, then run the program. You should demonstrate each code segmentto your lab instructor as you complete it.ECE 362 Experiment 2 Rev 8/12Bigger Bytes Lab Manual -8- 2012 by D. G. MeyerSkeleton file listing:;****************************************************************************; Step 4-A:;; Write a program that loads two 16-bit numbers from the memory location; ops, divides the first number by the second, then stores the quotient; in the memory location quot and the remainder in memory location; remain. Note that the space for the operands and results has; already been allocated for you below. Each has a label associated with; the memory location. You can use the labels ops, quot, and remain; when writing your code, and the assembler will convert it to the; appropriate memory address.;; Note that the instructions for the next step begin at memory location; $0820. Check your assembled source listing (.lst) file to make sure; that your code does not pass that location.step4a org $0800; Put your code herestopops rmb 4quot rmb 2remain rmb 2;****************************************************************************; Step 4-B:;; Write a program that tests whether the unsigned value contained; in the A register is higher than value stored at the memory location; tval. If it is, the program sets the variable higher to $FF,; and if not, the program sets the variable higher to $00.;;****************************************************************************step4b org $0820; Put your code herestoptval fcb 100higher rmb 1ECE 362 Experiment 2 Rev 8/12Bigger Bytes Lab Manual -9- 2012 by D. G. Meyer;****************************************************************************; Step 4-C:;; Write a program that performs the addition of the two; 3-byte numbers located at the memory location adds and stores; the result in the memory location sum.;; Note: You may not change the values of any of the registers.;; Therefore, you should push any registers used in the program at the; beginning of the program, and then pull (pop) them off at the end; of the program.;; NOTE: The operands are stored MSB to LSB.;;****************************************************************************step4c org $0840; Put your code herestoporg $0870adds rmb 6 ; Addendssum rmb 3 ; Sum;****************************************************************************; Step 4-D:;; Write a program that will transfer a specified number of bytes of data; from one memory location (source) to another memory location (destination).; Assume that the source address is contained in the Y register, the; destination address is contained in the X register, and the A register; contains the number of bytes of data to be transferred. The X, Y and A; registers should return with their original values, and the other registers; should be unchanged.;; Note: For this program, you should use a FOR loop. The basic; structure of a FOR loop is:;; loop check counter; branch out of loop if done (here, to label done); perform action; branch back to loop; done next instruction;; NOTE: When testing this program, make sure that you are not transferring; data to memory locations where your program is located!!! Check your; assembled listing file to see where your programs are located.;****************************************************************************step4d org $0890; Put your code herestopECE 362 Experiment 2 Rev 8/12Bigger Bytes Lab Manual -10- 2012 by D. G. Meyer;***********************************************************************; Step 4-E:;; Write a program that determines how many bits of the number passed; in the A register are 1s. The A register should return its original; value, and the number of 1 bits should be returned in the B register.;; Note: For this program, you should use a DO loop. The basic; structure of a DO loop is:;; initialize counter; loop perform action; update and check counter; branch back to loop if not done;; You will need to maintain three pieces of data for this program:; (a) initial value (in A register); (b) number of 1 bits (returned in B register); (c) counter for the loop;; Since we only have two accumulators available in the HC(S)12, you will; need to use an index register, a local variable (stored in memory), or; the stack to implement this. A memory location with the label count; has been reserved below if you would like to use it.;;***********************************************************************step4e org $0920; Put your code herestopcount rmb 1endStep 5: Thought QuestionsPlace your answers to the following thought questions in the space provided, below.(a) Why are the (legacy) ABX and ABY instructions not included in the native HC(S)12instruction set?__________________________________________________________________________________________________________________________________________________(b) Why are ORCC and ANDCC instructions provided in addition to ones like SEC, CLC, SEI,CLI, SEV, and CLV?__________________________________________________________________________________________________________________________________________________

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] ECE 362 Lab Verification / Evaluation Form Experiment 2
$25