Anda di halaman 1dari 8

EC-315

LIST OF THE PROGRAMS AND STEPS REQUIRD TO IMPLEMENT THEM


IN
EMBEDDED SYSTEMS LABORATORY
GENERAL
For the solution of each subsequent problem (but in more particular for the more complex ones) you
should always go through the following steps:-
1. Understand the problem.
2. Find the algorithm (i.e. find a procedure to solve the problem in some cases this is trivial).
3. Draw a neat flowchart. For a complex program it is necessary to draw several flowcharts, starting at the
higher level ( i.e. with basic blocks) and refining it further till the level is reached where it can easily be
converted into a program.
4. Devise a test procedure. How will you test whether your program is doing what you want it to do and to
stop its execution in order to test the CPU registers (i.e. set-break points) etc?
5. Write a program (with pencil) on a coding sheet (Editing). Whenever necessary, a comment should be
given to make the program more comprehensive. But the comment should never be trivial given a
reason or writing that particular program step (e.g. ‘Save counter value’ for MOV B,A).
6. Covert the instructions code into the machine code and mnemonics.
7. Load the program. After having loaded the program it is advisable to check whether all codes and data
have been entered properly.
8. Execute and debug the program. The time involved in debugging is inversely proportional to the time
you have spent in going through points 1 to 8. Do not forget that your program should always start with
defining the Stack-pointer, even if your program does not use the stack. You need it in any case for
testing the program in single step.
9. Your program should always be terminated by a HALT-instruction or RST1 or unless you have
program of infinite loop. This will prevent the microprocessor to execute some random data beyond
your program which might alter your instructions.
The problems are generally arranged in order of increasing complexity, start in with simple examples
which are intended to familiarize you with the instructions-set.
To setup Dyna 85L kit, for use in serial mode:

1. Connect the serial port of kit with serial port of computer.


2. Switch on the power supply of the kit.
3. Invoke TANGO from your PC desktop.
4. Press F9 key of PC
5. Option is highlighted and baud rate of 1200 is set by default. Change the baud rate to 2400 using
cursor keys and press F9 once again and press ENTER key.
6. “DYNA 85>” prompt will appear on your PC monitor.
7. Assemble program using serial mode commands.
8. Following commands can be used in serial mode.
A-Assembly A(start)
D- Display memory D(start), (end)
E-Edit memory E C000
C-Copy memory C(start),(end),(destination)
F-Fill memory F(start),(end),(byte)
I-Insert byte I (start),(end),(byte)
R-Examine/ Modify register R
GO- Program execution GO (start), 00(CR) space bar
T-trace (single step) T (start), 00
9. Example
DYNA 85>A C000
>C000: MVI A,20
>C002: MVI B,20
>C004: ADD B
>C005: RST 1
>
DYNA 85>D C000, C0FF
> ------------------------
PRESS SPACEBAR
Get additional data.
10. Steps to change the memory location:

DYNA 85>E C000


> --------- NEW DATA ----
11. To see contents of register
DYNA 85>R
DYNA 85>A= B= ………………………………….
Programming Problems FOR 8085
1. Write a program to perform the following functions and verify the operation
(a) Load the number 8B H in register D.
(b) Load the number 6F H in register C
(c) Increment the contents of register C by 1
(d) Add the contents of C & D.
2. To load the contents of memory location 2050H to A which has 50 H in it.
3. To load register pair BC with 2050H
4. Load register A with 11H and add 11H to it.
5. Load register A with 67. Subtract 67H from A.
6. Load above program, edit data 67H to 50H and subtract from A.
7. Load A with 34H and B with 00H and AND.
8. Edit contents of B in above program to 34H and then AND the contents of A &B.
9. Load A with 87H and AND its contents with the data 45H.
10. Load A with 66H and OR its contents with data 00H.
11. Load A with F6 H and B with F6 H and XOR the data.
12. Load A with AAH and XOR with data 55H
13. Load A with 02H and B with 09H and compare the contents of the two registers.
14. Load 9B and A7 in register D&E respectively and add these numbers. Display 01 if sum is greater
than FF and display sum otherwise.
15. Rotate the contents of A through carry to left.
16. Rotate A left (RLC)
17. Write a program to
(a) Load the number 30H to register B and 39H in register C.
(b) Subtract 39H from 30H.
18 Write a program to load register B and C with hexadecimal numbers and
compare them. Store smaller number in A and if numbers are equal load with 00.
19 Write a program to compare two numbers at consecutive memory locations.
Store the smaller number in A and if numbers are equal load with 00.
20 Write a program to arrange numbers at consecutive memory locations.
Starting from 9050 in ascending order.
21 Write program to change binary number to BCD number.
22 A set of eight bytes stored in memory location 9070H. WAP to subtract two
bytes at a time and store the results in a sequential order in memory location starting from 9070H.
23 Write a program to load reg. A.B.C. and D with the same constant (e.g. 1A).
Try to optimize your program in such a way that you use the smallest number of program bytes.
Test you program in single step mode. After each step you can test in the run-mode it will store
result at the HALT instruction. However, in order to test your CPU-register, command has to go
back to the monitor, which can only be done by resetting the microprocessor. But a reset may
randomly change the content of the CPU-registers. Therefore, the test can only be made in single
step.
24 Assume that 4 bytes of data are stored at consecutive locations of the data
memory starting at location X. Write a program which loads register E with (X) i.e. with data
contained at memory location X,D with (X+1), C with (X+2) and B with (X+3)
(c) Use direct addressing mode (LDA)
(d) Use register indirect addressing (M)
(e) Compare (a)and (b) in terms of memory requirement.
Test your program in single-step mode.
25 Assume that 2 bytes of data is stored at consecutive locations of data memory starting at location
X. Write the program that moves the data from locations X, X+1 to locations Y, Y+1.You can
test your program in run-mode and check data-memory locations Y and Y+1 execution.
(a) Use direct addressing
(b) Use indirect addressing (addressing X and Y specified by double register)
26 Assume that I byte of data is stored at data mammary location X. Write a program which tests
bit 5 of (X) and write FF into X+1 if bit 5 = 0 and writes 00 at the same location if bit 5 = 1.
27. (a) Write a program which tests the zero condition of data byte
specified at data memory l ocation X. If it is zero, a 00 should be stored at
location X+1, otherwise FF.
(b) Write a program which tests the all-one-condition of data byte specified at data memory
location X. If all the bytes are one, store 01 at location X+1, otherwise 00.
28. Four bytes of data are specified at consecutive data memory locations starting at X. Write a
program which increments the value of 4 bytes by one.
29. Two data bytes are stored at location X and Y. Interchange the data at two locations using
indirect addressing.
30. (a) Two binary number are stored at data memory locations X and X+1. Compute the sum of
two numbers and store the result at location X.
(b) Four unsigned Binary numbers are stored at consecutive data memory location starting at
X. Compute the sum of four numbers and store it at location Y. Use indirect addressing.
31. Two unsigned Binary number are stored at consecutive data memory locations X, X+1. Write
a program for computing (X+1)-(X). The magnitude of the result should be stored at Y and the
sign (00 if positive and 01 if negative) at Y+1.
32. (a) A double precision number, i.e., a 16 bit unsigned number, is stored at X and X+1, with
low order byte at X. Another double precision number is stored at Y and Y+1. Add the two
numbers and store the result at W and W+1.
(b) Same as 10(a). Subtract the two numbers and store the result at W and W+1.
33. Write a program which decrements a counter (i.e. e.g. a binary number stored at X) one by one
halts when the counter value is zero. Test your program in single-step.
34. A binary number is stored at memory location X. Compute the number of its logical 1’s and
store the result at Y.
35. A code word is stored at memory location X. Write a program for testing whether the code
word belongs to 2/5 code, and set the location Y to FF if yes and 00 if no. The code word is
valid if three MSBs are zero and if the number of 1’s in the remaining 5 bits is 2 (2/5 code).
36. A counter is defined as register (e.g. B) which gets decremented till zero. Define such a
counter as subroutine. Write a program, which consists of two counters. You must implement
the following steps:
1. Set initial value of counter 1.
2. Call counter subroutine.
3. Set initial value of counter 2
4. Call counter subroutine.
5. Go back to step one.
37. (a) Implement the time delay loop (counter) for the generation of milliseconds. Determine the
exact time delay by adding up the states of instructions.
(b) Implement the time delay of several seconds.
38. (a) Write a program for a decimal counter (00-99) with programmable clock frequency (e.g.
frequency specified at data memory location X) and display the count in the data field
using corresponding monitor subroutine.
(b) Same as problem no. 16(a) but counter counts from 00 to a given decimal number (defined
in data memory) where it gets reset and starts again at 00.
39. (a) N binary numbers are stored at consecutive data memory location, starting at X, where N is
defined at data memory location “NUMBER”. Find the largest number and display it in the
data field.
(b) N binary numbers are stored at consecutive data memory locations starting at X.
Rearrange the numbers in ascending order.
40. Four programs are defined as follows :
Program 0: Display 0000 (address field)
“ 1: “ 1111 “
“ 2: “ 2222 “
“ 3: “ 3333 “
The starting addresses of the programs are defined in a table (which is a part of the program
memory) in the stored number 0-3.
There is a simple way to fetch the address of the corresponding program using offset-
addressing :e.g. the address A+2 is obtained by adding twice the number (2x1), called offset,
to the base address. Write a routine to achieve this.
41. Write a program for moving a data block starting at address X to address Y. the address X,Y as
well as the block-length (i.e. no. of bytes) are specified at some suitable data-memory
locations.
42. In computer communication data is often transmitted in ASCII format. This code consists of
128 symbols for numbers, letters and signs out of which Hex-Decimal characters have the
following representation :
Character HEX-ASCII Representation
18 30
19 31
20 33
21 34
22 35
23 36
24 37
25 38
26 39
27 40
A 41
B 42
C 43
D 44
E 45
F 46
Assume that character is stored in its ASCII representation at location X. Write a program
to display the corresponding character in the data-field.
43. Write a program which displays (in address field) the hexadecimal character which is
depressed. The program should be such that data can be entered through the keyboard an
indefinite number of time at every key depression the displayed character get shifted 1 digit to
left as the new digit is entered on the least significant digit. A small part of the monitor
program is thus implemented. For this program you have to use keyboard subroutine.
44. A binary number is stored at data memory location X. Multiply the number by 10 and display
the result in the address field. (Hint: bx10 = bx2 + bx23, a multiplication by 2 corresponds to a
shift left on a bit).
45. (a) Two unsigned binary numbers are stored at data-memory location X and X+1. Find the
product and display it in the address field.
(i) Find the product by successive addition i.e. the multiplier is added as often to itself
as corresponds to the value of the multiplication.
(ii) Find the product by common method of multiplication (shift left and add).
(iii) Compare the static and dynamic performances of (a) and (b).
(b) With a given conditions of problem no. 23(a) divide a number by 10 and display it in the
address field.
(c) Similar as in problem no. 23(b) divide 16 bit number by a 8 bit number display the result in
the data field.
(i) Using successive subtraction.
(ii) Using common method for division (shift right and subtract).
46. A two digit BCD number is stored at memory location X. Convert the number into binary and
display the result in data-field.
47. An eight bit binary number is stored at data memory location Y. Convert the decimal (BCD)
and display the result in the address field (use same algorithm as for the hardware binary BCD
conversion).
48. Given two digit decimal number at data-memory location X and X+1.
Find the product using binary multiplication and display the result in the address field.
49. Write a program to implement a digital clock on a microprocessor kit.
50. Write an assembly language program to generate FIBONACCI series.
51. Write an assembly language program to find the square root of a given number by subtracting
successive odd numbers. The number is stored at location X. The result be stored at location
X+1.
52. Write an assembly language program to find the square of a single digit hexadecimal number,
use, table lookup technique.
Microcontroller Based Programming Problems
Steps for using Keil Software

Creating source file

1. Invoke Keil software from desktop.


2. Click on the file menu and select New.
3. A new window will open in the Keil IDE.
4. Write the program and save file with extension “.a”

Creating a new project

1. Select New Project from the project Menu.


2. Name the project ‘****.uv2’
3. The device window will be displayed. Select ‘89C51RD+’ from the ‘Philips’
4. Expand Target 1 in the tree menu.
5. Click on Project and select Targets, Groups, Files……
6. Click on Groups/ Add files tab under available Groups select source group 1.
7. Click add files to Group… button
8. Browse the file and add to the project.

Testing program in Debugger


1. Click on Debug menu and select start/ stop button.
2. Step through the code by pressing F11 on the keyboard

Problems
1. Load R5 with 25H and, R7 with 34H, add the contents of R5 & R7. add 12H to result.
2. Load R6, R1, R4 with 15H, 12H and F3H respectively, push these to stack.
3. Write a program to determine if R5 contains the value D. if so, put 55H in it, otherwise put 00H in
it.
4. Find the sum of values 79H, F5H and E2H. put sum to register R0 (low byte) and R5(high byte)
5. Write a program to (a) load accumulator with value 55H and (b) with complement the
accumulator 10 times.
6. Load 9B and A7 registers R0 and R1 respectively and add these numbers. If sum is greater than
FF, load with 01 otherwise store sum in A.
7. Write a program to get 8 bit data from P1 and sent it to ports P0, P2, P3 continuously.
8. Write a program to monitor the P1.3 bit. When it is high make low to high to low pulse on p1.3.
9. Write a program to copy the block of 10 bytes of data from RAM locations starting at 35H to
RAM location starting at 60H.
10. Write a program to see if RAM location 37H contains an even value if so send it to P2. if not make
it even, then send it to P2.
11. Write a program to add two 16 bit numbers. The numbers are 3CE7 H and 3B8DH. Place the sum
in R7 and R6; R6 should have lower byte.
12. Write a program to
(f) make P2 an input port
(g) to get a byte of hex data in the range of 00-FF H from P1 and convert it to decimal. Save
the digits in R7, R6 and R5, where the least significant digit is R7.
13. Read the test P1 to test whether it has the value 45H. if it does, send 99H to P2; otherwise clear
port P2.
14. Assume the lower 4 bit of P1 are connected to 4 switches. Write a program to send following
ASCII characters to P2 on the status of switches.
0000 ‘0’
0001 ‘1’
: :
: :
1111 ‘F’

Anda mungkin juga menyukai