Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (2 votes)
260 views

Programming Practices With Simulators

Here is the assembly language program to find the sum of elements in an array: ADDRESS MNEMONIC OPERAND COMMENT 4100 LXI H, 5000 21 00 50 Initialize memory pointer to start of array 4103 MVI B, 10 06 10 Initialize total elements counter 4105 MVI C, 00 06 00 Initialize carry register 4107 MVI D, 00 06 00 Initialize register for memory pointer 4109 MOV A, M 7E Load accumulator from memory 410A DAD D 19 Add memory pointer register 410B JNC ADD1 D2 11 41 Jump

Uploaded by

arun
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (2 votes)
260 views

Programming Practices With Simulators

Here is the assembly language program to find the sum of elements in an array: ADDRESS MNEMONIC OPERAND COMMENT 4100 LXI H, 5000 21 00 50 Initialize memory pointer to start of array 4103 MVI B, 10 06 10 Initialize total elements counter 4105 MVI C, 00 06 00 Initialize carry register 4107 MVI D, 00 06 00 Initialize register for memory pointer 4109 MOV A, M 7E Load accumulator from memory 410A DAD D 19 Add memory pointer register 410B JNC ADD1 D2 11 41 Jump

Uploaded by

arun
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

EX.

NO:14

PROGRAMMING PRACTICES WITH SIMULATORS/EMULATORS/OPEN SOURCE

8 bit operation
Aim:
To write and execute the Assembly language program for performing 8 bit addition, subtraction,
in 8051 using KEIL software.

Program logic:

8 bit addition
Data got from internal memory are loaded into ACC register and B registers. B register content is added
with ACC register content. Occurrence of carry flag (overflow) is checked. If it is occurred, then
increment carry counter by 1. ACC register contain the result of addition of two numbers. ACC content
and carry register content are stored in consecutive memory location.

Program
ORG 00H
SJMP START
START: MOV R0,#50H ; initialize data memory at 50h
MOV R1,#00H ; clear R0 reg for carry
MOV A,@R0; get first data in acc.
INC R0 ; move to next location
ADD A,@R0 ;add second data to acc content
JNC STORE ; check whether overflow occur
INC R1 ; if carry occur in c carry reg R1
STORE: INC R0 ; if no carry come to this loop STORE
MOV @R0,A ; store result in acc into mem location
NC R0 ; inc mem location
MOV A,R1 ;[ store carry reg]
MOV @R0,A ;content in next location]
END; halt the program

OUTPUT:

INPUT: OUTPUT:

R0-02H R0 05H
R1-03H R1 - 00H
Program logic:
8 bit subtraction:
Data got from internal memory are loaded into ACC register and B register. B register content is
subtracted wit Acc register content. Occurrence of carry flag (for barrow) is checked. If it is occurred,
then increment carry counter by 1. ACC register contain the result of subtraction of two numbers. ACC
content and carry register content are stored in consecutive memory location.
Program:
ORG 00H
SJMP START
START: MOV R0,#50H ; initialize data memory at 50h
CLR C; clear flag
MOV R1,#00H ; clear R0 reg for carry
MOV A, @R0; get first data in acc
INC R0; move to next location
subb A,@R0 ; subtract second data with acc content
JNC STORE; check whether carry occur
INC R1; if carry occur Inc carry reg R1
CPL A; [do 2's complement
INC A; of result]
STORE: INC R0 ; if no carry come to this loop STORE
MOV @R0, A; store result in acc into mem location
INC R0; Inc mem location
MOV A,R1 ;[ store carry reg
MOV @R0,A ; content in next location]
END; halt the program

OUTPUT:

INPUT: OUTPUT:

R0-05H R0 02H
R1-03H R1 - 00H

RESULT:

Thus the Assembly language program for 8 bit addition, subtraction in 8051is performed using
KEIL software.
Flowchart for rolling display

Start

Initialize look up A character

Initialize keyboard mode of 8279

Clear the Accumulator and display

Initialize 8279 in delay RAM WRITE display

Display A character

Stop

LOOK UP TABLE
EX.NO:15 MINI PROJECT DEVELOPMENT WITH PROCESSORS.

TO DISPLAY CHARACTERS IN A ROLLING DISPLAY

AIM

To interface the 8279 with 8085 microprocessor and perform the following operation.
To display the rolling message VRSCET in the display.

NOTE
a) Rolling message:
1) Store the look up table value in 4300 memory address onwards.

DISPLAY THE ROLLING MESSAGE VRSCET IN THE DISPLAY

ADDRESS LABEL MNEMONIC OPCODE COMMENTS


S
4100 START LXI H, 4300 21,00,43 Initialize the data pointer
4103 MVI D,0F 16,06 move the count value in D relay
4105 MVI A, 10H 3E, 10
4107 OUT CNT D3, C2
4109 MVI A, CC 3E, CC
410B OUT CNT D3, C2
410D MVI A, 90H 3E, 90
410F OUT CNT D3,C2
4111 LOP MOV A,M 7E
4112 OUT DAT D3, C0
4114 CALL DELAY CD,1F,41 Delay call
4117 IN X H 23 Increment the H register
4118 DCR D 15
4119 JNZ LOP C2,11,41 Jump NO zero to lop
411C JMP START C3,00,41 Jump to start
411F DELAY MVI B, A0H 06,A0 Move immediate A0 to B register
4121 LOOP 1 MVI C, FFH 0E,FF Move immediate data to C register
4123 LOOP2 DCR C OD Decrement C register
4124 LOP JNZ LOOP2 C2,23,41 Jump NO zero LOOP 2
4127 DCR B 05 Decrement B register
4128 JNZ LOOP1 C2, 21, 41 Jump Non zero to LOOP 1
410B RET C9 Return to main program

DATA BUS D7 D6 D5 D4 D3 D2 D1 D0

SEGMETS d c b a dp g f e
OBSERVATION:

LETTER 7 DATA BUS


SEGMENT HEXADECIMAL

D7 D6 D5 D4 D3 D2 D1 D0

LOOK UP TABLE:

ADDRESS HEX CODE


4300 1C
4301 FA
4302 29
4303 6C
4304 68
4205 78

RESULT:

Thus 8279 controller was interfaced with 8085 and program for rolling display was executed
successfully.
Flowchart for 16 bit multiplication
Start

Initialize the HL pair 0000H

Get the 16 bit multiplicand & multiplier


value is BC pair & stack pointer

Initialize the DE pair 0000H

Add the multiplicand with multiplier

Decrement the multiplicand

Is multiplicand=0

No

Yes
Stop the data in HL pair get the
given memory location

Stop

Input data

BC pair-1CD2 H

Stack pointer-01AD H

Output

4A00 - EA H

4A01- 4B H

4A02 - 30 H

4A03 - 00 H
EX.NO:16 16 BIT MULTIPLICATIONS

AIM

To write a program for 16 bit multiplication for the given set of datas

APPARATUS REQUIRED

1)8085 Microprocessor kit


2) Power supply
3) RAM address 4100 5FFF
NOTE

1. HL is used as the 16 bit Accumulator


2. Multiplier stored in BC pair
3. Multiplicand stored in SP
4. DE pair used to store then bit value temporary
5. Result stored in address represented by SHLD in Acc.

ADDRESS LABLE MNEMONICS OPCODE COMMENTS


4100 LXIH, 0000 21,00,00 Initials the HL pair in 0000
4103 LXIB, 16 bit data 01,D2,1C Get the 16 bit data
4106 LXI SP,16 bit 31,AD,01 Two value in multiplier and
data multiplicand
4109 LXI D, 0000 11,00,00
410C MUL DAD SP 39 Initialize the DE pair
410D JNC DOWN D2,11,41 Jump if it is non zero go down
4110 INX D 13 Increment D register
4111 DOWN DCX B 0B Decrement B register
4112 MOV A,B 78 Move the value B reg. to A reg.
4113 ORA C B1
4114 JNZ MUL C2,0C,41 Jump non zero to MUL
4117 SHLD 4A00 22,00,4A Store the output is given address
411A XCH G EB Exchange the value in acc to
memory
411B SHLD 4A02 22,02,4A Store the output in given address
411E HLT 76 stop the program

RESULT

Thus the assembly language program to perform 16 bit multiplication using 8085 microprocessor is
verified for the given 16 bit data.
FLOWCHART:
Ex. N0. 17 SUM OF ELEMENTS IN AN ARRAY

AIM:

To find the sum of elements in an array.

ALGORITHM:

1. Load the array in the consecutive memory location and initialize the memory pointer with the
starting address.
2. Load the total number of elements in a separate register as a counter.

3. Clear the accumulator.

4. Load the other register with the value of the memory pointer.

5. Add the register with the accumulator.

6. Check for carry, if exist, increment the carry register by 1. otherwise, continue
Decrement the counter and if it reaches 0, stop. Otherwise increment the memory pointer by 1
and go to step 4.
PROGRAM:

Label Program Comments

MOV DPTR, #4200 Load 4200 to DPTR, get array size


MOVX A, @DPTR Copy array size value to A
MOV R0, A Move contents of A to R0
MOV B, #00
MOV R1, B
CLR C Clear B, R1 & Carry Flag
AGAIN INC DPTR Get value from data pointer
MOVX A, @DPTR
ADD A, B Sum of two numbers
MOV B, A
JNC NC If no carry jump to NC
INC R1 Else increment R1
Decrement size of array, if not zero
NC DJNZ R0,AGAIN fetch data from
DPTR and add to the resultant value
Store the result in 4500 memory
MOV DPTR, #4500 locations
MOV A, B
MOVX @DPTR, A
INC DPTR
MOV A, R1
MOVX @DPTR, A
HERE SJMP HERE
OBSERVATION:

INPUT OUTPUT

4200 4500

4201

4202

4203 4501

RESULT:

Thus the sum of elements in an array is calculated using 8051.

You might also like