Vous êtes sur la page 1sur 12

LABORATORY REPORT

ECE 521 : MOCRO P PROCESSOR SYSTEM


LAB 3 : PROGRAMMING AND SUBROUTINES
EE2423E

NAME MATRIX

ALIF DANIAL BIN ZAHARI 2019818806

AIMAN AHMAS BIN MAAMOR 2019455824

FAIRUZ EZZATY BINTI ELIAS 2019853512


Question 1

Figure 1: code if question 1

Figure 2: Simulation before execution

Figure 3: Result of the simulation after execution


The coding from figure 1 was to compile and execute a program that copies twelve bytes of
data that begins from memory 1000H to memory locations starting 100BH. The memory location
selected is DPTR . Furthermore , loop operation is used because twelve bytes must be copied for
1000H and then similar coding is used for 100BH. Also, a timer of #12 for each loop to run and expire
when the timer reach ‘0’ . Finally , when the last data is copied the program ends. This is the intended
action . From , result in figure 3 shows that the program ran as intended and was successful .

Question 2

Figure 4: code for question 2


Figure 5: Simulation before execution

Figure 6: Result of the simulation after execution

The coding from figure 4 was to compile and execute a program that place the larger of the
contents of memory locations 1200H and 1250H into memory location 1300H. This task requires
that both given memory location to be tested and determine which of the two is the larger . Based
of the result from figure 6 it shows that memory location that is saved in ‘A’ is larger thus it is put
into memory location 1300H that is put in @DPTR. In conclusion , the program was executed and ran
as it should successfully.
Question 3

Figure 7 : Code for Question 3


Figure 8 : Simulation before execution

Figure 9 : Result of the simulation after execution

The coding from figure 7 was to compile and execute a program that sort out three given
hexadecimal numbers into ascending order with the smallest number put into memory location
1013H. The given hexadecimal numbers are 1010H, 1011H and 1012H . The final result show that
40H is saved in accumulator ‘A’ , #1015H in saved in DPTR0 . This show that the program ran as
intended and was successful.
Question 4

Figure 10 : code for question 4


Figure 11 : Simulation before start execution

Figure 12 : Result of simulation after start execution

The coding from figure 10 was to compile and execute a program that inspect the contents
of memory address 1008H and, if the contents are greater than ‘0AH’. The contents are then
subtracted by ‘05H’ and stored in memory location ‘200AH’. Otherwise, the contents are to be added
with ‘10H’ and the result is stored in location ‘200BH’.

The program uses CJNE to compare A and B contents . Where if it is determine that the content
is JNC is A ,but JC is B . The label for ABESAR is to execute when the content is larger . As for label
BBEASR is to execute when the content is smaller .

From the figure 12 that the content is executed at BBESAR . Thus , the program ran successfully
and as intended.
Question 5
Figure 13 : Code for exercise 5

Figure 14: Simulation before start execution

Figure 15: Result of the simulation after execution

The coding from figure 3 was to compile and execute a program that uses indirect addressing
and looping technique to store twelve 8-bit numbers in memory location starting with 1250H. Using
R1 , R2 and DPTR and assigning #00H to both R1 and R2 to ensure the content is available to use later
.

Increment, INC is use and CJNE to compare R1 and see whether if it is necessary to loop again
or to continue the program .Then the code follow with similar as the above but this time R2 where R2
is #00H .Thus , it is unused but the accumulator stores the date from @DPTR .

The final result is that ‘A’ has 42H and DPTR0 has 125CH . The program was successful .
Question 6

Figure 16: code for question 6

Figure 17: Simulation before execution


Figure 18: Result of the simulation after execution

The coding from figure 16 was to compile and execute a program that compute the area of
two rectangular that width and length are stored in memory locations 2100H and 2101H, and saved
the area of the rectangular in memory locations 2200H and 2300H . Also , the calculation process of
the area is done in a subroutine .
From the figure 18 , the result shows that #12H is in ‘A’ and #2300H in DPTR . Thus , the
program was successful .

Vous aimerez peut-être aussi