Вы находитесь на странице: 1из 12

MATRIX MULTIPLICATION

AIM:

To write an assembly language program to reform matrix multiplication using


8086.

ALGORITHM:

1. Initialize the segments and the data for two matrices ant their size using the
respective assembler directives.
2. Get the offset addresses of Matrix 1 & 2 in corresponding index registers.
3. Clear Accumulator and Lower byte of flag register.
4. Initialize count for row and columns.
5. Multiply the elements of corresponding row and column in sequence, for matrix
multiplication using loop.
6. Store the result as another matrix and stop execution.

FLOWCHART:
PROGRAM:

ASSUME CS: CODE, DS: DATA


DATA SEGMENT
ROCOL EQU 03H
MAT1 DB 05H, 09H, 0AH,03H, 02H, 07H, 03H, 00H, 09H
MAT2 DB 09H, 07H, 02H, 01H, 00H, 0DH, 07H, 06H, 02H
PMAT3 DW 09H DUP (?)
DATA ENDS
CODE SEGMENT
START : MOV AX, DATA
MOV DS, AX
MOV CH, ROCOL
MOV BX, OFFSET PMAT3
MOV SI, OFFSET MAT1
NEXTROW: MOV DI, OFFSET MAT2
MOV CL, ROCOL
NEXTCOL: MOV DL, ROCOL
MOV BP, 0000H
MOV AX, 0000H
SAHF
NEXT_ELE: MOV AL, [SI]
MUL BYTE PTR [DI]
ADD BP, AX
INC SI
ADD DI, 03
DEC DL
JNZ NEXT_ELE
SUB DI, 08
SUB SI, 03
MOV [BX], BP
ADD BX, 02
DEC CL
JNZ NEXTCOL
ADD SI, 03
DEC CH
JNZ NEXTROW
MOV AH, 4CH
INT 21H
CODE ENDS
END START
PROCEDURE:

1. Type the program in editor pad.


2. Copy it to MASM assembler software.
3. Assemble the program, check for errors.
4. Run the program and check the result.
5. Or transfer the program to kit and execute. Verify the result.

RESULT:

The program for performing 3x3 matrix multiplication is written, executed and
the result is verified.
INTERFACING KEYBOARD/DISPLAY CONTROLLER TO 8085

AIM:
To interface Keyboard/Display controller(8279) with 8085 processor and to
display a string of characters.

ALGORITHM: (To display the string “HELLO”)

1. Form the look up table.


2. Move the control word to accumulator and out it through control register.
3. Get the letters one by one from memory and out it.
4. Check whether all letters are displayed. If not, display next character.
5. Stop of program.

FLOWCHART:
PROGRAM:

ADDRESS OPCODE LABEL MNEMONICS COMMENTS


4500 21 LXI H, 4600 Load immediate HL register
pair with 4600
4501 00
4502 46
4503 3E MVI A, 10 Move immediate 90 to
accumulator
4504 90
4505 D3 OUT 01 Out it through CR
4506 01
4507 7E L1 MOV A,M Move memory content to
accumulator
4508 D3 OUT 00 Out it through 8279 port
4509 00
450A 23 INX H Increment HL register pair
450B 7D MOV A,L Move the content of L
register to accumulator
450C FE CPI 06 Compare immediate with 06
450D 06
450E C2 JNZ L1 Jump on no zero to label
location L1
450F 07
4510 81
4511 76 HLT Halt the process

PROCEDURE:

1. Key in the opcodes.


2. Give the input data from look up table at the specified memory locations.
3. Execute the program and verify the character display.

Result:

The Keyboard/Display controller is interfaced with 8085 and the character display
is verified.
SIMPLE ARITHMETIC OPERATIONS USING 8051

AIM:

To write an assembly language program to (i) add two 8-bit numbers


(ii) subtract two 8-bit numbers (iii) multiply two 8-bit numbers (iv) divide two 8-bit
numbers.

APPARATUS REQUIRED:

8051 Microcontroller Kit and Power Supply

ALGORITHM:

8-BIT ADDITION:
1. Clear carry flag.
2. Get the first data in accumulator.
3. Add the second data with that of accumulator.
4. Store the result in a memory location.
5. Stop execution.

Flowchart:

PROGRAM:

ADDRESS OPCODES MNEMONICS COMMENTS


4100 C3 CLR C
4101 74 MOV A, #DATA1
4102 34
4103 24 ADDC A, #DATA2
4104 78
4105 90 MOV DPTR, #4150
4106 41
4107 50
4108 F0 MOVX @DPTR, A
4109 80 L1: SJUMP L1
410A FE

ALGORITHM:

8-BIT SUBTRACTION:
1. Clear carry Flag.
2. Get the first data in accumulator.
3. Subtract the second data from that of accumulator.
4. Store the result in a memory location.
5. Stop execution.
6.

FLOCHART:

PROGRAM:

ADDRESS OPCODES MNEMONICS COMMENTS


4100 C3 CLR C
4101 74 MOV A, #DATA1
4102 34
4103 94 SUBB A, #DATA2
4104 24
4105 90 MOV DPTR, #4500
4106 45
4107 00
4108 F0 MOVX @DPTR, A
4109 80 L1: SJUMP L1
410A FE

ALGORITHM:

8-BIT MULTIPLICATION:
1. Get the first data in accumulator.
2. Get the second data in B register.
3. Multiply the two data.
4. Store the result in a memory location.
5. Stop execution.

FLOWCHART:

PROGRAM:

ADDRESS OPCODES MNEMONICS COMMENTS


4100 74 MOV A, #DATA1
4101 0A
4102 75 MOV B, #DATA2
4103 F0
4104 88
4105 A4 MUL AB
4106 90 MOV DPTR, #4150
4107 41
4107 50
4108 F0 MOVX @DPTR, A
4109 A3 INC DPTR
410A E5 MOV A,B
410B F0
410C F0 MOVX @DPTR,A
410D 80 L1: SJUMP L1
410E FE

ALGORITHM:

8-BIT DIVISION:

1. Get the first data (dividend) in accumulator.


2. Get the second data (Divisor) in B register.
3. Divide the two data.
4. Store the result in a memory location.
5. Stop execution.

FLOWCHART:

PROGRAM:

ADDRESS OPCODES MNEMONICS COMMENTS


4100 74 MOV A, #DATA1
4101 65
4102 75 MOV B, #DATA2
4103 F0
4104 08
4105 84 DIV AB
4106 90 MOV DPTR, #4150
4107 41
4107 50
4108 F0 MOVX @DPTR, A
4109 A3 INC DPTR
410A E5 MOV A,B
410B F0
410C F0 MOVX @DPTR,A
410D 80 L1: SJUMP L1
410E FE
PROCEDURE:

1. Enter the opcodes and data.


2. Execute the program and verify the results at specified memory locations.

OBSERVATION:

RESULT:

The assemble language programs for addition, subtraction, multiplication and


division operation are written, executed and the results are verified.
ARRAY OPERATION AND CODE CONVERSION

AIM:
To write an assembly language program to (i) find the biggest numder in an array
of data, (ii) convert the code from ASCII to Decimal value.

APPARATUS REQUIRED:

8051 Microcontroller kit and Power supply.

ALGORITHM:

FINDING THE BIGGEST NUMBER IN THE ARRAY:

FLOCHART:

PROGRAM:

ADDRESS OPCODES MNEMONICS COMMENTS


4100 90 MOV DPTR, #4200
4101 42
4102 00
4103 75 MOV 40H, #00
4104 40
4105 00
4106 7D MOV R5, #0A
4107 0A
4107 E0 L2: MOVX A, @DPTR
4108 B5 CJNE A, 40H, L1
4109 40
410A 08
410B A3 L3: INC DPTR
410C DD DJNZ R5,L2
410D F9
410E E5 MOV A, 40H
410F 40
4110 F0 MOVX @DPTR,A
4111 80 HLT:SJMP HLT
4112 FE
4113 40 L1: JC L3
4114 F6
4115 F5 MOV 40H, A
4116 40
4117 80 SJMP L3
4118 F2
ALGORITHM:

ASCII TO DECIMAL CONVERSION:

FLOWCHART:

PROGRAM:

ADDRESS OPCODES MNEMONICS COMMENTS


4100 90 MOV DPTR, #4200
4101 45
4102 00
4103 E0 MOVX A, @DPTR
4104 75 MOV B, #64
4105 F0
4106 64
4107 84 DIV AB
4107 90 MOV DPTR, #4501
4108 45
4109 01
410A F0 MOVX @DPTR, A
410B E5 MOV A,B
410C F0
410D 75 MOV B, #0A
410E F0
410F 0A
4110 84 DIV AB
4111 A3 INC DPTR
4112 F0 MOVX @DPTR, A
4113 A3 INC DPTR
4114 E5 MOV A,B
4115 F0
4116 F0 MOVX @DPTR, A
4117 80 HLT: SJMP HLT
4118 FE

PROCEDURE:

1. Enter the opcodes from the specified address.


2. Enter the input data.
3. Execute the program and verify the result.
OBSERVATION:

RESULT:

The programs for array operation and code conversion are wriiten, executed and
the results are verified.

Вам также может понравиться