15
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:

MANUAL

Embed Size (px)

Citation preview

Page 1: MANUAL

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:

Page 2: MANUAL

PROGRAM:

ASSUME CS: CODE, DS: DATADATA SEGMENTROCOL EQU 03HMAT1 DB 05H, 09H, 0AH,03H, 02H, 07H, 03H, 00H, 09HMAT2 DB 09H, 07H, 02H, 01H, 00H, 0DH, 07H, 06H, 02HPMAT3 DW 09H DUP (?)DATA ENDSCODE SEGMENTSTART : MOV AX, DATA

MOV DS, AXMOV CH, ROCOLMOV BX, OFFSET PMAT3MOV SI, OFFSET MAT1

NEXTROW: MOV DI, OFFSET MAT2MOV CL, ROCOL

NEXTCOL: MOV DL, ROCOLMOV BP, 0000HMOV AX, 0000HSAHF

NEXT_ELE: MOV AL, [SI]MUL BYTE PTR [DI]ADD BP, AXINC SIADD DI, 03DEC DLJNZ NEXT_ELESUB DI, 08SUB SI, 03MOV [BX], BPADD BX, 02DEC CLJNZ NEXTCOLADD SI, 03DEC CHJNZ NEXTROWMOV AH, 4CHINT 21H

CODE ENDSEND START

Page 3: MANUAL

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.

Page 4: MANUAL

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:

Page 5: MANUAL

PROGRAM:

ADDRESS OPCODE LABEL MNEMONICS COMMENTS4500 21 LXI H, 4600 Load immediate HL register

pair with 46004501 004502 464503 3E MVI A, 10 Move immediate 90 to

accumulator4504 904505 D3 OUT 01 Out it through CR4506 014507 7E L1 MOV A,M Move memory content to

accumulator4508 D3 OUT 00 Out it through 8279 port4509 00450A 23 INX H Increment HL register pair450B 7D MOV A,L Move the content of L

register to accumulator450C FE CPI 06 Compare immediate with 06450D 06450E C2 JNZ L1 Jump on no zero to label

location L1450F 074510 814511 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.

Page 6: MANUAL

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 COMMENTS4100 C3 CLR C4101 74 MOV A, #DATA14102 344103 24 ADDC A, #DATA24104 784105 90 MOV DPTR, #41504106 414107 504108 F0 MOVX @DPTR, A4109 80 L1: SJUMP L1410A FE

ALGORITHM:

8-BIT SUBTRACTION:1. Clear carry Flag.2. Get the first data in accumulator.

Page 7: MANUAL

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 COMMENTS4100 C3 CLR C4101 74 MOV A, #DATA14102 344103 94 SUBB A, #DATA24104 244105 90 MOV DPTR, #45004106 454107 004108 F0 MOVX @DPTR, A4109 80 L1: SJUMP L1410A 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 COMMENTS4100 74 MOV A, #DATA14101 0A4102 75 MOV B, #DATA24103 F04104 884105 A4 MUL AB4106 90 MOV DPTR, #41504107 41

Page 8: MANUAL

4107 504108 F0 MOVX @DPTR, A4109 A3 INC DPTR410A E5 MOV A,B410B F0410C F0 MOVX @DPTR,A410D 80 L1: SJUMP L1410E 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 COMMENTS4100 74 MOV A, #DATA14101 654102 75 MOV B, #DATA24103 F04104 084105 84 DIV AB4106 90 MOV DPTR, #41504107 414107 504108 F0 MOVX @DPTR, A4109 A3 INC DPTR410A E5 MOV A,B410B F0410C F0 MOVX @DPTR,A410D 80 L1: SJUMP L1410E FE

Page 9: MANUAL

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.

Page 10: MANUAL

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 COMMENTS4100 90 MOV DPTR, #42004101 424102 004103 75 MOV 40H, #004104 404105 004106 7D MOV R5, #0A4107 0A4107 E0 L2: MOVX A, @DPTR4108 B5 CJNE A, 40H, L14109 40410A 08410B A3 L3: INC DPTR410C DD DJNZ R5,L2410D F9410E E5 MOV A, 40H410F 404110 F0 MOVX @DPTR,A4111 80 HLT:SJMP HLT4112 FE4113 40 L1: JC L34114 F64115 F5 MOV 40H, A4116 404117 80 SJMP L34118 F2

Page 11: MANUAL

ALGORITHM:

ASCII TO DECIMAL CONVERSION:

FLOWCHART:

PROGRAM:

ADDRESS OPCODES MNEMONICS COMMENTS4100 90 MOV DPTR, #42004101 454102 004103 E0 MOVX A, @DPTR4104 75 MOV B, #644105 F04106 644107 84 DIV AB4107 90 MOV DPTR, #45014108 454109 01410A F0 MOVX @DPTR, A410B E5 MOV A,B410C F0410D 75 MOV B, #0A410E F0410F 0A4110 84 DIV AB4111 A3 INC DPTR4112 F0 MOVX @DPTR, A4113 A3 INC DPTR4114 E5 MOV A,B4115 F04116 F0 MOVX @DPTR, A4117 80 HLT: SJMP HLT4118 FE

PROCEDURE:

1. Enter the opcodes from the specified address.2. Enter the input data.3. Execute the program and verify the result.

Page 12: MANUAL

OBSERVATION:

RESULT:

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