Assi 1
Assi 1
University of Technology
Department of Electrical Engineering
Microcontroller Lab
Assignment 1
Written by
5.
6.
Embedded system: is a combination of computer hardware and software designed for a specific
function or functions within a larger system. The systems can be programmable or with fixed
functionality. Industrial machines, consumer electronics, agricultural and process industry
devices, automobiles, medical equipment, cameras, household appliances, airplanes, vending
machines and toys, as well as mobile devices, are possible locations for an embedded system.
7.
8.
9.
A total of 32 bytes of RAM are set aside for the register banks and the stack. These 32 bytes are
divided into four register banks in which each bank has 8 registers, R0–R7. RAM locations from
0 to 7 are set aside for bank 0 of R0–R7 where R0 is RAM location 0, R1 is RAM location 1, R2
is location 2, and so on, until the memory location 7, which belongs to R7 of bank 0. The second
bank of registers R0–R7 starts at RAM location 08 and goes to locations OFH. The third bank of
R0–R7 starts at memory location 10H and goes to location to 17H. Finally, RAM locations 18H
to 1FH are set aside for the fourth bank of R0–R7.
Register bank 0 is the default when the 8051 is powered up. We can switch to the other banks
using PSW register. D4 and D3 bits of the PSW are used to select the desired register bank, since
they can be accessed by the bit addressable instructions SETB and CLR. For example, "SETB
PSW.3" will set PSW.3 = 1 and select the bank register 1.
0 0 Bank0
0 1 Bank1
1 0 Bank2
1 1 Bank3
10.
a. Accumulator
The accumulator, register A, is used for all arithmetic and logic operations. If the accumulator is
not present, then every result of each calculation (addition, multiplication, shift, etc.) is to be
stored into the main memory. Access to main memory is slower than access to a register like the
accumulator because the technology used for the large main memory is slower (but cheaper) than
that used for a register.
b. The "R" Registers
The "R" registers are a set of eight registers, namely, R0, R1 to R7. These registers function as
auxiliary or temporary storage registers in many operations. Consider an example of the sum of
10 and 20. Store a variable 10 in an accumulator and another variable 20 in, say, register R4. To
process the addition operation, execute the following command −
ADD A,R4
After executing this instruction, the accumulator will contain the value 30. Thus "R" registers are
very important auxiliary or helper registers. The Accumulator alone would not be very useful if
it were not for these "R" registers. The "R" registers are meant for temporarily storage of values.
Let us take another example. We will add the values in R1 and R2 together and then subtract the
values of R3 and R4 from the result.
MOV A,R3 ;Move the value of R3 into the accumulator
ADD A,R4 ;Add the value of R4
MOV R5,A ;Store the resulting value temporarily in R5
MOV A,R1 ;Move the value of R1 into the accumulator
ADD A,R2 ;Add the value of R2
SUBB A,R5 ;Subtract the value of R5 (which now contains R3 + R4)
As you can see, we used R5 to temporarily hold the sum of R3 and R4. Of course, this is not the
most efficient way to calculate (R1 + R2) – (R3 + R4), but it does illustrate the use of the "R"
registers as a way to store values temporarily.