Beruflich Dokumente
Kultur Dokumente
University of Jordan
Faculty of Engineering and Technology
Department of Computer Engineering
Embedded Systems Laboratory 0907334
1
COMPUTER NAME:
UNIVERSITY OF JORDAN
FACULTY OF ENGINEERING AND TECHNOLOGY
DEPARTMENT OF COMPUTER ENGINEERING
EMBEDDED SYSTEMS LABORATORY CPE0907334
Labsheet 2: Instruction Set Analysis 2 & Modular Programming
Techniques
Name: Abed el-Rahman Khaled Hamed Student ID: 0164872
Section: 4
Pre-lab) Part 1: Starting up with instructions
Answer the following short questions:
A) Write the instructions needed to check if the value found in REGA equal to 10.
Movlw D’10’
Subwf REGA,0
Btfss STATUS,Z
B) Write the instructions needed to check if the value found in REGA equal to zero.
Mov REGA,F
Btfss STATUS,Z
1. What will the results of the program 3 be when we substitute the instruction @ line 23
“decfsz counter, F ” with decfsz counter, W ?
Infinite Loop
2. Assuming that the PIC runs at an external oscillator speed of 4 MHz? What is the time spent
in executing the program 3.asm code?
29 microsecond
2
(Pre-lab) Part 3: Code Writing Skills
Modify Program1.asm code of the experiment to add this case:
If testNum has the decimal value 10, Result will have the ASCII value ‘E’
include "p16F84A.inc"
cblock 0x25
testNum
Result
endc
org 0x00
Main
movf testNum, W
sublw D'10' ;10d - testNum
btfsc STATUS,Z
goto Equal
btfss STATUS, C
goto Greater ;C = 0, that's B = 1, then testNum > 10
goto Smaller ;C = 1, that's B = 0, then testNum < 10
Greater
movlw A'G'
movwf Result
goto Finish
Smaller
movlw A'S'
movwf Result
Goto Finish
Equal
movlw A'E'
Movwf Result
Finish
nop
end
3
Part4: Code Analysis Skills
Read and simulate the given code Labsheet2.asm and answer the questions which follow:
1. What will be stored in the following Registers when Num has the following values:
3. Where does Mul7 subroutine expect to find its input, where does it store its output?
Input: Working
Output: Num_7
4. What is the value at the top of stack when the Mul49 subroutine call instruction executed is?
0004
4
Part 5: Code Writing Skills
In MPLAB, Write a program which converts a number from unpacked BCD format saved in three
registers to one decimal number, assuming that registers names are BCDH, BCDM and BCDL.
BCDH (High Digit of the decimal number) is at location 0x21, BCDM (Mid Digit of the decimal
number) is at location 0x22, BCDL (Low Digit of the decimal number) is at location 0x23, and Result
is at location 0x40, also assume that all BCD numbers are in the valid range of 0 – 9.