Pasumarthisreekar S2

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

Q1.

Problem Statement: Design a state machine and corresponding gate level circuit for a vending machine. The
specifications are as follows:

1. The machine can disperse snacks of Rs. 15 only.


2. Only one type of snack is there in the machine.
3. The machine can accept two types of coin only: Rs. 5 and Rs. 10.
4. The combination can be Rs. 5-5-5, Rs. 5-10, Rs. 10-5, or Rs. 10-10.
5. Case of returning extra money or change (over Rs. 15) must be considered.
6. After depositing Rs. 15 or more the snack door opens and if any change is to be returned, the coin return
door opens.
7. After dispersing the snack and change the machine goes into ready state for using again.
8. Coins can be deposited one at a time only.

Solution:
Q2.

Problem Statement: A microprocessor is designed to control various appliances and lights in your house. The system
has an output port with the address 01H, and various appliance units are connected to the bits D7 to D0. On a cool
morning you want to turn on the radio, the coffeepot, and space heater. Write appropriate instructions for the
microprocessor. Assume R/W memory in your system begins at 2000H.

Solution:

To turn on the radio, the coffeepot, and the space heater, set D6, D5, and D4 at logic 1, and turn the other bits at
logic 0.

D7 D6 D5 D4 D3 D2 D1 D0
0 1 1 1 0 0 0 0

The output port requires 70H, and it can be sent to the port by loading the accumulator with 70H.

PROGRAM:

S.No MEMORY ADDRESS MACHINE CODE MNEMONIC COMMENTS


INSTRUCTION
1. 2000 3E MVI A, 70H Load the
2001 70 accumulator with
the bit pattern
necessary to turn on
the devices
2. 2002 D3 OUT 01H Send the bit pattern
2003 01 to the port 01H,
turn on the devices
3. 2004 76 HLT End of the program
Q3.

Problem Statement: Subtract the 16-bit number in memory locations 4002H and 4003H from the 16-bit number in
memory locations 4000H and 4001H. The most significant eight bits of the two numbers are in memory locations
4001H and 4003H. Store the result in memory locations 4004H and 4005H with the most significant byte in memory
location 4005H.

Solution:

PROGRAM:

S.No COMMAND DESCRIPTION

1. LHLD 4000H Get first 16-bit number in HL

2. XCHG Save first 16-bit number in DE

3. LHLD 4002H Get second 16-bit number in HL

4. MOV A, E Get lower byte of the first number

5. SUB L Subtract lower byte of the second number

6. MOV L, A Store the result in L register

7. MOV A, D Get higher byte of the first number

8. SBB H Subtract higher byte of second number with borrow

9. MOV H, A Store 16-bit result in memory locations 4004H and 4005H

10. SHLD 4004H Store 16-bit result in memory locations 4004H and 4005H

11. HLT Terminate program execution

You might also like