MP & MC Programs (3)
MP & MC Programs (3)
STUDY OF 8085
MICROPROCESSOR
d 16 BIT MULTIPLICATION
LARGEST,SMALLEST AND
3. SORTING OF AN ARRAY
a LARGEST OF AN ARRAY
b SMALLEST OF AN ARRAY
Control Unit
Generates signals within uP to carry out the instruction, which has been decoded. In reality
causes certain connections between blocks of the uP to be opened or closed, so that data goes
where it is required, and so that ALU operations occur.
Registers
The 8085/8080A-programming model includes six registers, one accumulator, and one flag
register, as shown in Figure. In addition, it has two 16-bit registers: the stack pointer and the
program counter. They are described briefly as follows. The 8085/8080A has six general-
purpose registers to store 8-bit data; these are identified as B,C,D,E,H, and L as shown in the
figure. They can be combined as register pairs - BC, DE, and HL - to perform some 16-bit
operations. The programmer can use these registers to store or copy data into the registers by
using data copy instructions.
Accumulator
The accumulator is an 8-bit register that is a part of arithmetic/logic unit (ALU). This register is
used to store 8-bit data and to perform arithmetic and logical operations. The result of an
operation is stored in the accumulator. The accumulator is also identified as register A.
Flags
The ALU includes five flip-flops, which are set or reset after an operation according to data
conditions of the result in the accumulator and other registers. They are called Zero(Z), Carry
(CY), Sign (S), Parity (P), and Auxiliary Carry (AC) flags; they are listed in the Table and their
bit positions in the flag register are shown in the Figure below. The most commonly used flags
are Zero, Carry, and Sign. The microprocessor uses these flags to test data conditions. For
example, after an addition of two numbers, if the sum in the accumulator id larger than eight
bits, the flip-flop uses to indicate a carry -- called the Carry flag (CY) – is set to one. When an
arithmetic operation results in zero, the flip-flop called the Zero(Z) flag is set to one. The first
Figure shows an 8-bit register, called the flag register, adjacent to the accumulator. However, it
is not used as a register; five bit positions out of eight are used to store the outputs of the five
flip-flops. The flags are stored in the 8-bit register so that the programmer can examine these
flags (data conditions) by accessing the register through an instruction. These flags have critical
importance in the decision-making process of the micro- processor. The conditions (set or
reset) of the flags are tested through the software instructions. For example, the instruction JC
(Jump on Carry) is implemented to change the sequence of a program when CY flag is set. The
thorough understanding
of flag is essential in writing assembly language programs.
This 16-bit register deals with sequencing the execution of instructions. This register is a
memory pointer. Memory locations have 16-bit addresses, and that is why this is a 16-bit
register. The microprocessor uses this register to sequence the execution of the instructions.
The function of the program counter is to point to the memory address from which the next byte
is to be fetched. When a byte (machine code) is being fetched, the program counter is
incremented by one to point to the next memory location
The stack pointer is also a 16-bit register used as a memory pointer. It points to a memory
location in R/W memory, called the stack. The beginning of the stack is defined by loading 16-
bit address in the stack pointer.
Instruction Register/Decoder
Temporary store for the current instruction of a program. Latest instruction sent here from
memory prior to execution. Decoder then takes instruction and ‘decodes’ or interprets the
instruction. Decoded instruction then passed to next stage.
Register Selector
This block controls the use of the register stack in the example. Just a logic circuit which
switches between different registers in the set will receive instructions from Control Unit.
uP requires extra registers for versatility. Can be used to store additional data during a program.
More complex processors may have a variety of differently named registers.
ALE (Output)
Address Latch Enable: It occurs during the first clock cycle of a machine state and enables the
address to get latched into the on chip latch of peripherals. The falling edge of ALE is set to
guarantee setup and hold times for the address information. ALE can also be used to strobe the
status information. ALE is never 3stated.
SO, S1 (Output)
Data Bus Status. Encoded status of the bus cycle:
S1 S0
O O HALT
0 1 WRITE
1 0 READ
1 1 FETCH
S1 can be used as an advanced R/W status.
RD (Output 3state)
READ; indicates the selected memory or 1/0 device is to be read and that the Data Bus is
available for the data transfer.
WR (Output 3state)
WRITE; indicates the data on the Data Bus is to be written into the selected memory or 1/0
location. Data is set up at the trailing edge of WR. 3stated during Hold and Halt modes.
READY (Input)
If Ready is high during a read or write cycle, it indicates that the memory or peripheral is ready
to send or receive data. If Ready is low, the CPU will wait for Ready to go high before
completing the read or write cycle.
HOLD (Input)
HOLD; indicates that another Master is requesting the use of the Address and Data Buses. The
CPU, upon receiving the Hold request. will relinquish the use of buses as soon as the
completion of the current machine cycle. Internal processing can continue. The processor can
regain the buses only after the Hold is removed. When the Hold is acknowledged, the Address,
Data, RD, WR, and IO/M lines are 3stated.
HLDA (Output)
HOLD ACKNOWLEDGE; indicates that the CPU has received the Hold request and that it will
relinquish the buses in the next clock cycle. HLDA goes low after the Hold request is removed.
The CPU takes the buses one half clock cycle after HLDA goes
low.
INTR (Input)
INTERRUPT REQUEST; is used as a general purpose interrupt. It is sampled only during the
next to the last clock cycle of the instruction. If it is active, the Program Counter (PC) will be
inhibited from Incrementing and an INTA will be issued. During this cycle a RESTART or CALL
instruction can be inserted to jump to the interrupt service routine. The INTR is enabled and
disabled by software. It is disabled by Reset and immediately after an interrupt is accepted.
INTA (Output)
INTERRUPT ACKNOWLEDGE; is used instead of (and has the same timing as) RD during the
Instruction cycle after an INTR is accepted. It can be used to activate the 8259 Interrupt chip or
some other interrupt port.
RST 5.5
RST 6.5 - (Inputs)
RST 7.5
RESTART INTERRUPTS; These three inputs have the same timing as I NTR except they
cause an internal RESTART to be automatically inserted.
RST 7.5 ~~ Highest Priority
RST 6.5
RST 5.5 o Lowest Priority
The priority of these interrupts is ordered as shown above. These interrupts have a higher
priority than the INTR.
TRAP (Input)
Trap interrupt is a nonmaskable restart interrupt. It is recognized at the same time as INTR. It is
unaffected by any mask or Interrupt Enable. It has the highest priority of any interrupt.
RESET IN (Input)
Reset sets the Program Counter to zero and resets the Interrupt Enable and HLDA flipflops.
None of the other flags or registers (except the instruction register) are affected The CPU is
held in the reset condition as long as Reset is applied.
X1, X2 (Input)
Crystal or R/C network connections to set the internal clock generator X1 can also be an
external clock input instead of a crystal. The input frequency is divided by 2 to give the internal
operating frequency.
CLK (Output)
Clock Output for use as a system clock when a crystal or R/ C network is used as an input to
the CPU. The period of CLK is twice the X1, X2 input period.
IO/M (Output)
IO/M indicates whether the Read/Write is to memory or l/O Tristated during Hold and Halt
modes.
SID (Input)
Serial input data line The data on this line is loaded into accumulator bit 7 whenever a RIM
instruction is executed.
SOD (output)
Serial output data line. The output SOD is set or reset as specified by the SIM instruction.
Vcc
+5 volt supply.
Vss
Ground Reference.
Aim:
Algorithm:
Input Output
9100 – 04 9200 – 0C
9101 – 08 9201 – 00
9100 – FF 9200 – FE
9101 – FF 9201 – 01
Program:
MVI C, 00
LDA 9100
MOV B, A
LDA 9101
ADD B
JNC L1:
INR C
L1 : STA 9200
MOV A, C
STA 9201
RST 1
Result:
The ALP to perform 8-bit addition was executed and its output verified.
Program Format ( 8 bit subtraction)
Aim:
Algorithm:
Input Output
9200 – FF 9200 – 55
9201 – AA 9201 – 01
9200 – BB 9200 – 44
9201 – FF 9201 – 00
Program:
MVI C, 00
LDA 9200
MOV B, A
LDA 9201
SUB B
JNC L1
CMA
INR A
INR C
L1 : STA 9200
MOV A, C
STA 9201
RST 1
Result:
The ALP to perform 8-bit subtraction was executed and its output verified.
Program Format: (8 bit multiplication)
Aim:
Algorithm:
Input Output
9100 – 05 9102 – 14
9101 – 04 9103 – 00
9100 – FF 9102 – FE
9101 – FF 9103 – 01
Program:
MVI C, 00
LDA 9100
MOV B, A
LDA 9101
MOV D, A
MVI A, 00
L2 : ADD D
JNC L1:
INR C
L1 : DCR B
JNZ L2:
STA 9102
MOV A, C
STA 9103
RST 1
Result:
The ALP to perform 8-bit multiplication was executed and its output verified.
Program Format: ( 8 bit division)
; Compare A
9009 B8 L1 : CMP B
and B
; If carry, go
900A DA 12 90 JC 9012(L2) to L2
Aim:
Algorithm:
Input Output
MVI C, 00
LDA 9100
MOV B, A
LDA 9101
L1 : CMP B
JC L2:
SUB B
INR C
JMP L1:
L2 : STA 9103
MOV A, C
STA 9102
RST 1
Result:
The ALP to perform 8-bit division was executed and its output verified.
Program Format: ( 16 bit addition)
; L ← [9100]
9002 2A 00 91 LHLD 9100
H ← [9101]
;E ← L
9005 EB XCHG
D←H
; L ← [9102]
9006 2A 02 91 LHLD 9102
H ← [9103]
;L ← L+E
9009 19 DAD D
H ←H+D
; If no carry,
900A D2 0E 90 JNC 900E(L1)
go to L1
900D 0C INR C ;C ← C+1
; [9104] ← L
900E 22 04 91 L1: SHLD 9104
[9105] ← H
9011 79 MOV A, C ;A ← C
9012 32 06 91 STA 9106 ; [9106] ← A
9015 CF RST 1 ; Reset
Expt. No: 1.c Page No:
Aim:
Algorithm:
Input Output
9100 – 06 9104 – 09
9101 – 05 9105 – 0B
9102 – 03 9106 – 00
9103 – 06
9100 – 06 9104 – 09
9101 – F0 9105 – E0
9102 – 03 9106 – 01
9103 – F0
Program:
MVI C, 00
LHLD 9100
XCHG
LHLD 9102
DAD D
JNC L1
INR C
L1 : SHLD 9104
MOV A, C
STA 9106
RST 1
Result:
The ALP for adding two 16-bit numbers was executed and its output verified.
Program Format: ( 16 bit subtraction)
;E ← L
9003 EB XCHG
D←H
; L ← [9102]
9004 2A 02 91 LHLD 9102
H ← [9103]
9007 7D MOV A, L ;A ← L
9008 93 SUB E ;A ← A–E
9009 6F MOV L, A ;L ← A
900A 7C MOV A, H ;A ← H
;A ← A–D
900B 9A SBB D
– CARRY
900C 67 MOV H, A ;H ← A
; [9200] ← L
900D 22 00 92 SHLD 9200
[9201] ← H
9010 CF RST 1 ; Reset
Expt. No: 1.c Page No:
Aim:
Algorithm:
Input Output
9100 – 06 9200 – 03
9101 – 05 9201 – 01
9102 – 09
9103 – 06
9100 – 06 9200 – 02
9101 – 08 9201 – FE
9102 – 08
9103 – 06
Program:
LHLD 9100
XCHG
LHLD 9102
MOV A, L
SUB E
MOV L, A
MOV A, H
SBB D
MOV H, A
SHLD 9200
RST 1
Result:
The ALP for subtracting two 16-bit numbers was executed and its output verified.
Program Format: (16 bit multiplication)
9009 ; D ← FF
11 FF FF LXI D, FFFF
E ← FF
; HL ← HL +
900C 39 L2 : DAD SP
SP
; If no carry,
900D D2 11 90 JNC L1
jump to L1
; BC ← BC +
9010 03 INX B
1
; DE ← DE -
9011 1B L1 : DCX D
1
9012 7A MOV A, D ;A ←D
9013 B2 ORA E ; A ← A OR E
; If no zero,
9014 C2 0C 90 JNZ 900c(L2)
jump to L2
; [9200] ← L
9017 22 00 92 SHLD 9200
[9201] ← H
901A 69 MOV L, C ;L ←C
901B 60 MOV H, B ;H ←B
; [9202] ← L
901C 22 02 92 SHLD 9202
[9203] ← H
901F CF RST 1 ; Reset
Expt. No: 1.d Page No:
Aim:
Algorithm:
Input Output
FFFF 9200 – 01
FFFF 9201 – 00
9202 – FE
9203 – FF
Program:
LXI H, 0000
LXI B, 0000
LXI SP, FFFF
LXI D, FFFF
L2 : DAD SP
JNC L1
INX B
L1 : DCX D
MOV A, D
ORA E
JNZ L2
SHLD 9200
MOV L, C
MOV H, B
SHLD 9202
RST 1
Result:
The ALP to perform 16-bit multiplication was executed and its output verified.
Program Format: ( BCD to hexa)
Aim:
Algorithm:
1. Load the accumulator with the MSB of the given BCD number from a memory
address
2. Initialize one register (Reg B) with immediate data 0A
3. Move the accumulator content to a register (Reg D)
4. Clear the accumulator
5. Add Reg D content to accumulator
6. Decrement Reg D
7. Check for zero, if not zero, go to step 5
8. Move the accumulator content to Reg C
9. Load the accumulator with the LSB of the given BCD number from a memory address
10. Add Reg C content to accumulator
11. Store the accumulator content in a memory location
12. Stop
Sample Data:
Input Output
9101 – 08 (LSB)
Program:
LDA 9100
MVI B, 0A
MOV D, A
MVI A, 00
L1 : ADD D
DCR B
JNZ L1
MOV C, A
LDA 9101
ADD C
STA 9102
RST 1
Result:
The ALP for converting a given BCD number to HEX number was executed and its
output verified.
Program Format: (hexa to bcd)
Aim:
Algorithm:
1. Clear one register pair (BC) for storing hundreds and tens
2. Load the accumulator with the HEX number from a memory address
3. Subtract 64H (100D) from accumulator
4. Check for carry, if there is carry go to step 7
5. Increment Reg B
6. Go to step 3
7. Add 64H (100D) to accumulator
8. Subtract 0AH (10D) from accumulator
9. Check for carry, if there is carry go to step 12
10. Increment Reg C
11. Go to step 8
12. Add 0AH (10D) to accumulator
13. Store the ones in accumulator in a memory location
14. Move the tens in Reg C to accumulator
15. Store the tens in accumulator in a memory location
16. Move the hundreds in Reg B to accumulator
17. Store the hundreds in accumulator in a memory location
18. Stop
Sample Data:
Input Output
9201 – 05 (10’s)
9202- 02 (100’s)
Program:
LXI B, 0000
LDA 9100
L2 : SUI 64
JC L1
INR B
JMP L2
L1 : ADI 64
L4 : SUI 0A
JC L3
INR C
JMP L4
L3 : ADI 0A
STA 9200
MOV A, C
STA 9201
MOV A, B
STA 9202
RST 1
Result:
The ALP for converting a given HEX number to BCD number was executed and its
output verified.
Program Format (HEXA TO ASCII)
;If carry go to
900A D2 0F 90 JC LOOP:
loop
;If carry go to
900A D2 0F 90 JC LOOP
loop
ALGORITHM:
HEXA TO ASCII
1. Load accumulator with the hexa data
2. if the data is less than or equal to 09 add 30.
3. if the data is greater than 09 add 37.
4. store the result in memory
5. stop
ASCII TO HEXA
HEXA TO ASCII
LDA 9100
ADI A,30
CPI 39
JZ LOOP
JC LOOP
ADI A,07,
LOOP:STA 9101
RST 1
SAMPLE DATA
I/P 9100-00 9100-09 9100-0E
O/P 9101-30 9101-39 9101-45
SAMPLE DATA
Result: The program for converting hexa to ASCII and ASCII to hexa was executed.
Program Format: ( largest of an array)
; If no carry,
9008 D2 0C 90 JNC L1
jump to L1
Aim:
Algorithm:
1. Initialize one register pair (HL) with the starting address of the array
2. Initialize one register (Reg B) with one count less than the length of the
array
3. Move the memory content to accumulator
4. Increment HL pair
5. Compare the contents of accumulator and memory
6. Check for carry, if no carry, go to step 8
7. Move the memory content to accumulator
8. Decrement Reg B
9. Check for zero, if not zero, go to step 4
10. Store the accumulator content in a memory location
11. Stop
Sample Data:
Input Output
9100 – 08
9101 – 0A
9102 – 02
9103 – 0C 9200 – 19
9104 – 08
9105 – 06
9106 – 00
9107 – 19
Program:
LXI H, 9100
MVI B, 07
MOV A, M
L2 : INX H
CMP M
JNC L1
MOV A, M
L1 : DCR B
JNZ L2
STA 9200
RST 1
Result:
The ALP to search the largest value in an array was executed and its output
verified.
Program Format: (smallest of an array)
; If carry,
9008 DA 0C 90 JC 900C(L1)
jump to L1
Aim:
Algorithm:
1. Initialize one register pair (HL) with the starting address of the array
2. Initialize one register (Reg B) with one count less than the length of the
array
3. Move the memory content to accumulator
4. Increment HL pair
5. Compare the contents of accumulator and memory
6. Check for carry, if there is carry, go to step 8
7. Move the memory content to accumulator
8. Decrement Reg B
9. Check for zero, if not zero, go to step 4
10. Store the accumulator content in a memory location
11. Stop
Sample Data:
Input Output
9100 – 08
9101 – 0A
9102 – 02
9103 – 0C 9200 – 00
9104 – 08
9105 – 06
9106 – 00
9107 – 19
Program:
LXI H, 9100
MVI B, 07
MOV A, M
L2 : INX H
CMP M
JC L1
MOV A, M
L1 : DCR B
JNZ L2
STA 9200
RST 1
Result:
The ALP to search the smallest value in an array was executed and its output
verified.
Program Format: ( ascending order)
900E 56 MOV D, M ;D ←M
900F 77 MOV M, A ;M ←A
; HL ← HL –
9010 2B DCX H
1
9011 72 MOV M, D ;M ←D
; HL ← HL +
9012 23 INX H
1
9013 0D L1 : DCR C ;C←C–1
; If no zero,
9014 C2 08 90 JNZ 9008(L2)
jump to L2
9017 05 DCR B ;B←B–1
; If no zero,
9018 C2 02 90 JNZ L3
jump to L3
901B CF RST 1 ; Reset
Expt. No: 3c Page No:
Aim:
Algorithm:
1. Initialize one register (Reg B) with one count less than the length of the
array
2. Initialize one register pair (HL) with the starting address of the array
3. Initialize one register (Reg C) with the length of the array
4. Decrement the inner counter - Reg C
5. Move the memory content to accumulator
6. Increment HL pair
7. Compare the contents of accumulator and memory
8. Check for carry, if there is carry, go to step 13
9. Move the memory content to Reg D
10. Move the accumulator content to memory
11. Decrement HL pair
12. Move the content of Reg D to memory
13. Increment HL pair
14. Decrement the inner counter – Reg C
15. Check for zero, if not zero, go to step 5
16. Decrement the outer counter - Reg B
17. Check for zero, if not zero, go to step 2
18. Stop
Sample Data:
Input Output
9100 – 08 9100 – 00
9101 – 0A 9101 – 02
9102 – 02 9102 – 06
9103 – 0C 9103 – 08
9104 – 08 9104 – 08
9105 – 06 9105 – 0A
9106 – 00 9106 – 0C
9107 – 19 9107 – 19
Program:
MVI B, 07
L3 : LXI H, 9100
MVI C, 08
DCR C
L2 : MOV A, M
INX H
CMP M
JC L1
MOV D, M
MOV M, A
DCX H
MOV M, D
L1 : INX H
DCR C
JNZ L2
DCR B
JNZ L3
RST 1
Result:
The ALP to sort an array in ascending order was executed and its output
verified.
Program Format: (descending order)
Aim:
Algorithm:
1. Initialize one register (Reg B) with one count less than the length of the
array
2. Initialize one register pair (HL) with the starting address of the array
3. Initialize one register (Reg C) with the length of the array
4. Decrement the inner counter - Reg C
5. Move the memory content to accumulator
6. Increment HL pair
7. Compare the contents of accumulator and memory
8. Check for carry, if there is no carry, go to step 13
9. Move the memory content to Reg D
10. Move the accumulator content to memory
11. Decrement HL pair
12. Move the content of Reg D to memory
13. Increment HL pair
14. Decrement the inner counter – Reg C
15. Check for zero, if not zero, go to step 5
16. Decrement the outer counter - Reg B
17. Check for zero, if not zero, go to step 2
18. Stop
Sample Data:
Input Output
9100 – 08 9100 – 19
9101 – 0A 9101 – 0C
9102 – 02 9102 – 0A
9103 – 0C 9103 – 08
9104 – 08 9104 – 08
9105 – 06 9105 – 06
9106 – 00 9106 – 02
9107 – 19 9107 – 00
Program:
MVI B, 07
L3 : LXI H, 9100
MVI C, 08
DCR C
L2 : MOV A, M
INX H
CMP M
JNC L1
MOV D, M
MOV M, A
DCX H
MOV M, D
L1 : INX H
DCR C
JNZ L2
DCR B
JNZ L3
RST 1
Result:
The ALP to sort an array in descending order was executed and its output
verified.
STUDY OF 8051 MICROCONTROLLER
AIM:
The 8051 operations that do not use the internal 128-byte RAM addresses
from 00h to 7fh are done by a group of specific internal registers, each called as
special function registers. SFR may be addressed much like internal RAM using
address from 80h to ffh.
IE REGISTER: (Interrupt enable)
TCON has control bits and flags for the timers in the upper nibble and control
bits and flag for the external interrupt in the lower nibble.
TMOD is dedicated to two timers and can be consider to the two duplicate 4 bit
registers each of which control actions of one of timers.
TRANSMISSION:
When a byte of data is to be transmitted via the TX0 pin. The SBUF is
loaded with datatype.
RECEPTION:
When 8051 receives data serially via RXO pin of it, the 8051 de
frames it. The start and stop bit are separated out from a byte of data.
PORT 0:
PORT 1:
Port 1 is an 8 bit bidirectional I/O port with internal pull ups. The
ports pins are externally being pulled low. Its source current(TTL) is high
because of the internal pull ups.
PORT 2:
It is an 8 bit bidirectional I/O ports with internal for TTL
inputs. It accesses to external data memory that use 16 bit
address.
PORT 3:
Input to the inverting oscillator amplifier and input to the internal clock
operating circuit.
XTAL2:
Output from the inverting oscillator amplifier.
ALGORITHM
mov r0,#50
mov r1,#0a
mov a,#99
loop: mov @ro,a
inc ro
djnz r1,loop
lcall oobb
sample data
I/P
A-99
O/P
50-59 filled with 99
mov dptr,#9100
mov r1,#0a
mov a,#77
loop: movx @dptr,a
inc dptr
djnz r1,loop:
lcall oobb
sample data
I/P
A-77
O/P
9100-9109 filled with 77
Result: The program to fill internal and external memory was executed.
Expt. No: 4 c.d.e Page No:
EXTERNAL TO INTERNAL
1. Initialize dptr with the source address
2. Initialize ro with the destination address.
3. Initialize r1 with the count.
4. move the content of dptr to a.
5. move the data from a to the content of ro.
6. inc ro.
7. inc dptr
8. decrement r1 and repeat from step 4 till r1 reaches 0.
9. stop.
WITHIN EXTERNAL
PROGRAM
Internal to external
mov r0,#50
mov dptr,#9100
mov r1,#0a
loop: mov a,@ro
movx @dptr,a
inc ro
inc dptr
djnz r1,loop
lcall oobb
sample data
I/P
50-59 (give the data i/p)
O/P
9100-9109 (see the output)
External to internal
mov r0,#50
mov dptr,#9100
mov r1,#0a
loop: movx a,@dptr
mov @ro,a
inc ro
inc dptr
djnz r1,loop
lcall oobb
sample data
I/P
9100-9109 (give the data i/p)
O/P
50-59(see the output)
External to external
mov dptr,#9100
mov r1,#0a
loop: movx a,@dptr
mov 83,#92
movx @dptr,a
inc dptr
mov 83,#91
djnz r1,loop
lcall oobb
sample data
I/P
9100-9109 (give the data i/p)
O/P
9200-9209(see the output)
Result: The program to transfer internal to external, external to internal and external to external
are executed
Expt. No: 5 Page No:
AIM:
ALGORITHM:
LOGICAL INSTRUCTION
PROGRAMS
a)BIT MANIPULATION
MOV R0,#50
MOV A,@RO
RRC A
JC L1:
MOV 51,#OE
L1: LCALL 00BB
MOV 51,#0D
LCALL 00BB
SAMPLE DATA
I/P 50-32 50-39
O/P 51-EVEN 51-ODD
b) BIT MANIPULATION
mov ro,#20
jb 27,l1
mov 51,#oe
lcall 00bb
l1: mov 51,#0d
lcall 00bb
SAMPLE DATA
I/P 20-32 20-39
O/P 51-EVEN 51-ODD
LOGICAL INSTRUCTION
MOV R0,#50
MOV R1,#60
MOV R2,#05
LOOP: MOV A,@RO
ANL A,#of0
RRA
RRA
RRA
RRA
MOV @R1,A
INC RO
INC R1
DJNZ R2,LOOP:
LCALL 00BB
SAMPLE DATA
I/P 50-10 51-25 52-38 53-49 54-56
O/P 60-01 61-02 62-03 63-04 64-05
Result: The program using logical and bit manipulation instruction was executed.
Expt. No: 6a Page No:
AIM:
ALGORITHM:
1.set the bit 0 of port 1
2.call delay routine
3.clr bit 0 of port 1
4.call delay routine
5.repeat from step 1
Delay
1.initialize one reg
2.decrement that reg till it becomes zero. 3.return to main program.
PROGRAM
L1: SETB 90
LCALL DELAY(9100)
CLR 90
LCALL DELAY(9100)
SJMP L1:
9100DELAY:
MOV RO,#44
L1: DJNZ RO,L1
RET
Output
Square wave
Result
The program to operate the port bits was executed.
Expt. No: 6b Page No:
AIM:
To control the traffic as per the sequence
ALGORITHM:
Find Hex data using the given sequence by seeing the diagram
III 1 0 0 0 1 0 1 1 8B
IV 0 0 1 1 1 0 0 1 39
V 1 1 0 0 0 0 0 0 C0
SEQ PB7 PB6 PB5 PB4 PB3 PB2 PB1 PB0 HEX
UENCE DATA
I 0 0 0 0 1 1 1 1 0F
II 0 0 0 0 1 1 1 1 0F
III 0 0 0 0 1 1 1 1 0F
IV 0 0 0 0 1 1 1 1 0F
V 1 1 1 1 0 0 0 0 F0
TRAFFIC INTERFACE CARD
G G G
CO A1 AO
A5 Y
A6 R
G A3 Y R R Y G A3
G A2 A4 A7 A7 A4 G A2
G C1 G C1
A6 R
A5 Y
CO A1 AO
G G G
N
W E
PROGRAM:
MOV DPTR,#4003
MOV A,#80
MOVX @DPTR,A
L2: MOV 82,#00
MOV A,#4D
MOVX @DPTR,A
MOV 82,#01
MOV A,#0F
MOVX @DPTR,A
LCALL 9100(DELAY)
LCALL 9200(AMBER)
MOV 82.#00
MOV A,#8B
MOVX @DPTR,A
LCALL 9100(DELAY)
LCALL 9200(AMBER)
MOV 82,#00
MOV A,#C0
MOVX @DPTR,A
MOV 82,#01
MOV A,#FO
MOVX @DPTR,A
LCALL 9100(DELAY)
LCALL 9100(DELAY)
LJMP 9006(L1:)
AMBER(9200)
MOV 82,#00
MOV A,#39
MOVX @DPTR,A
MOV 82,#01
MOV A,#0F
MOVX @DPTR,A
LCALL 9100(DELAY)
RET
DELAY(9100)
MOV R0,#3C
L4: MOV R1,#FF
L3: MOV R2,#FF
L2: DJNZ R2,9106(L2:)
DJNZ R1,9104(L3:)
DJNZ R0,9102(L4:)
RET
AIM:
Program
MOV DPTR,#4003
MOV A,#80
L1: MOVX @DPTR,A
MOV DPTR,#4000
MOV A,#C6
MOVX @DPTR,A
LCALL DELAY
MOV A,#84
MOVX @DPTR,A
LCALL DELAY
MOV A,#A5
MOVX @DPTR,A
LCALL DELAY
MOV A,#E7
MOVX @DPTR,A
LCALL DELAY
LJMP L1:
STEP SEQUENCE ANITCLOCKWISE
PA7 PA6 PA5 PA4 PA3 PA2 PA1 PA1 HEXA
VALUE
SUPPLY A B X X SUPPLY A B -
1 1 0 0 0 1 1 1 C6
1 0 0 0 0 1 0 0 84
1 0 1 0 0 1 1 0 A5
1 1 1 0 0 1 1 0 E7
AIM:
To blink 1 using 7-segment LED.
ALGORITHM:
MOV DPTR,#4003
MOV A,#80
MOVX @DPTR,A
L1:MOV DPTR,#4000
MOV A,#06
MOVX @DPTR,A
LCALL DELAY
MOV A,#00
MOVX @DPTR,A
LCALL DELAY
LJMP L1:
DELAY
MOV R0,#FF
L3:MOV R1,#FF
L2:DJNZ R1,L2:
DJNZ R0,L3:
RET
AIM:
To test the given IC is working or not.
ALGORITHM:
MOV DPTR,#4003
MOV A,#80
MOVX @DPTR,A
L1:MOV DPTR,#4000
MOV A,#01
MOVX @DPTR,A
LCALL DELAY(9100)
MOV A,#00
MOVX @DPTR,A
LCALL DELAY(9100)
LJMP L1:
9100: DELAY
MOV R0,#FF
L3:MOV R1,#FF
L2:DJNZ R1,L2:
DJNZ R0,L3:
RET
NEXT INSTRUCTION .
RST 1
2. TO ENTER DATA
-M9100(FOR EXAMPLE)
DATA 1
SPACE BAR
DATA 2
SPACE BAR
- G9000(FOR EXAMPLE)
RESULT 1
SPACE BAR
RESULT 2