Attachment # 00005743 - ECET330_W3_iLab_Instructions.docx

ECET330_W3_iLab_Instructions.docx (157.83 KB)
Raw Preview of Attachment:
(refer to the detailed question and attachment below)
ECET330 Lab3 ProceduresTitle: Introduction toLoops and Subroutines in Assembly LanguageI. OBJECTIVESTobecome familiar with conditional branch instructionsUnderstanding how to write loopsUnderstanding how to write subroutinesII. PARTS LISTEquipment:IBM PC or compatible with Windows 2000 or higher CodeWarrior IDEINTRODUCTIONIn programming logic, branches refer to the different possible pathways that could be followed through a given set of instructions as they execute. In HCS12 assembly language, when the bra <label> instruction is encountered, sequential execution of program instructions automatically ceases and program control is diverted directly to the effective address symbolized by the operand <label>. This is an unconditional branch. There are other forms of bra that test for a certain condition to exist before allowing the branch to take place. For example,bcs<label> causes a branch to execute only if the carry flag is set (C=1); otherwise it will be ignored. Another branch, conditional bne<label>, tests the Z flag (not equal means Z must be 0) before branching. Program loops repeat a sequence of instructions. A loop is constructed by placing the instruction bra <label> at the end of the sequence and the label referred to in its operand at the beginning. Instructions within such a loop will be repeated indefinitely. Placing a branch conditional, such as bne, at the end will allow program control to exit the loop and pass onto the next instruction as soon as the condition (e.g. Z=0) is found to be NOT true. Example of a Simple LoopThe following example shows how to define an array of byte-size values of 10. It also reserves 10byte-size spaces in the data section of the program.It also shows how to move the address of the arrays into Registers X and Y.Finally, it shows how to write a loop.These lines will repeat 10 times.After executing the above program, the values are copied to list2. Note that the values in the program are decimal. However, the simulation shows the values in hex.You may cut and paste the individual windows, such as memory window or register windows of the IDE, by holding ALT+PrtScr. Then, you may paste the result to a Word document.PROCEDUREWrite a program to find the sum of the elements of an array called list1. The size of list1 is fourbytes. The values of list1 are $FF, $1, $FE, and $02. To check your work, the sum should become $0200.The requirements for writing this program are as follows.-You must use a loop and count variable (i.e. count must be defined in the data section) as a loop counter.- Clear both Registers A and B using CLRA and CLRB instructions.-Use indexed addressing mode to access the elements of the array using Register X as the index register. The instruction LDX #list1 places the array list1 address into Register X.-Add each element to Register B.-Use the branch instruction BCC to check if there is a carry after the addition of each element. BCC means the Branch if Carry flag is clear.-If there is a carry, add 1 to Register A.-The final result should be in Register A and B.Copy and paste the register window at the second iteration where the carry becomes set. Highlight the carry flag to show that it is set.Copy and paste the register window to show the final result.Write a program to use a subroutine to find the sum of the array elements. For simplicity, assume that the sum of the data valuesis less than $FF. You do not need to use the BCC to check for carry flag. Follow the following steps to write this program.Define two arrays called List1 and List2 using DC.B directive. Initialize List1 with byte-size values of $6, $12, $4, $0F, and $11. Initialize List2 with byte-size values of $4, $5, and $7. Reserve two byte-size locations called Sum1 and Sum2 using DS.B directive. The subroutine must find the sum of the elements of the array list1. Before calling the subroutine, the main program must initialize Register X to have the address of the array and Register B to have the size of the array. The subroutine must use a loop and indexed addressing mode using Register X as the index register and Register B as the loop counter. The subroutine must return the sum in Register A.The main program must call the subroutine two times. The first time, the subroutine will find the sum of the array List1. After returning from the subroutine, the main code must save Register A in Sum1. Then, the subroutine is called for a second time to find the sum of the elements in List2. After the return from the subroutine, the value of Register A is saved in Sum2.Since this code is using a subroutine, make sure to initialize the SP register using:LDS #$4000.This line must be added to the main code before calling any subroutines.Copy and paste the source code.Copy and paste the assembly, register, and memory after the first JSR instruction to verify that stack holds the return address. Copy and paste the memory window to show the values of Sum1 and Sum2.


Offered Price $70.00

ECET 330 Homework / Lab

Question # 00071902
Subject: Computer Science
Due on: 05/24/2015
Posted On: 05/20/2015 06:06 PM

Expert tutors with experiences and qualities
Posted By
Best Tutors for school students, college students
Feedback Score:

Purchase it
Report this Question as Inappropriate
Complete the attached documents. For the lab, use the instructions as guidelines, then use coversheet for answers.

Tutorials for this Question

Available for

ECET 330 Homework / Lab

Tutorial # 00066611
Posted On: 05/20/2015 06:10 PM
Posted By:
Best Tutors for school students, college students neil2103
Expert tutors with experiences and qualities
Feedback Score:
Report this Tutorial as Inappropriate
Tutorial Preview …Homework…
ECET330_W3_iLab_(1).docx (83.24 KB)
Preview: at xxx second xxxxxxxxx where the xxxxx becomes set xxxxxxxxx the xxxxx xxxx to xxxx that it xx set IV x C xxxx xxx paste xxx register window xx show the xxxxx result xx x A xxxx and paste xxx source code xxxx Entry, xxxxxxxx x export xxxxxxx symbol ABSENTRY xxxxx ; for xxxxxxxx assembly: xxxx xxxx as xxxxxxxxxxx entry pointRAMStart xxx $2000RAMEnd EQU xxxxxxxxxxxxx EQU xxxxx xxx RAMStartList1 xx B $6, xxxx $4, $0F, xxxxxxxx DC x xxx $5, xx Sum1 DS x 1Sum2 DS x 1 xxx xxxxxxxxxxxxxxxxxxxxxxx LDS xxxxxx LDX #List1 xxxx #$5 JSR xxxxxx STAA xxxx xxxx LDX xxxxxx.....
Micro_Homework_3.docx (13.17 KB)
Preview: $2000result            xx 1counter         DS xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ORG          $8000                    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx STAB         counterBACK:          xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx counter                    xxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx STAA         result 3 xxxx is the xxxx of each xxxxxxxxxxxxx LDAA     xxxxx xxxxxxxxxxxxx thereIII xxxxxxxxxx $2000IV DECBV xxxxxxxxxxxx 0, XI xxxx = x xxxxxxx size x 2.....
Purchase this Tutorial @ $85.00 *
* - Additional Paypal / Transaction Handling Fee (3.9% of Tutorial price + $0.30) applicable