Programs Micro Processor

  • October 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Programs Micro Processor as PDF for free.

More details

  • Words: 650
  • Pages: 9
Microprocessor Programs Multiplication of Two 4 bit Numbers

L1:

XRA A LXI H, 2100 MOV B,M INX H ADD M DCR B JNZ L1 STA 2102 HLT

Multiplication of Two 8-bit Numbers

L2: L1:

XRA A MOV B,A LXI H, 1100 MOV C,M INX H ADD M JNC L1 INR B DCR C JNZ L2 INX H MOV M,A INX H MOV A,B MOV M,A HLT

Addition Of Two Numbers: LDA 4150 MOV B,A LDA 4151 ADD M STA 4152 HLT

Addition Of Two no(method 2) LXI H,2050 MOV A,M INX H ADD M INX H MOV A,B HLT Subtraction of Two no LDA 4150 MOV B,A LDA 4151 SUB B STA 4152 HLT Method 2 : Subtraction of Two No LXI H,2050 MOV A,M INX H SUB M INX H MOV M,A HLT Biggest of Numbers LXI H,4150 MOV C,M INX H MOV A,M LOP: INX H CMP M JNC LOP1 MOV A,M LOP1 DCR C JNZ LOP MOV M,A HLT Smallest of the No: LXI H,4150 MOV C,M LOOP: INX H MOV A,M INX H

CMP M JC LOOP1 MOV A,M LOOP1:DCR C JNZ LOOP MOV M,A HLT Division

P1:

L1:

XRA A MOV C,A LXI H,4150 MOV B,M INX H MOV A,M SUB B JC L1 INC C JMP P1 ADD B STA 4153 MOV AMC STA 4152 HLT

Block Transfer

L1:

LXI H,2100 LXI D,2200 MVI C,0A MVI A,M STAX D INX H INX D DCR C JNZ L1 HLT RST 7

Ascending Order

L1:

LXI H,4150 MOV C,M MOV B,C INX H MOV A,M PUSH H DCR B JZ LA1

L2:

L3:

LA1:

INX H CMP M JC L3 MOV D,A MOV A,M MOV M,D DCR B JNZ L2 POP H MOV M,A DCR C JMP L1 HLT

Decending Order:

L1:

L2:

L3:

LXI H,4150 MOV C,M MOV B,C INX H MOV A,M PUSH H DCR B JZ LA1 INX H CMP M JNC L3 MOV D,A MOV A,M MOV M,D DCR B JNZ L2 POP H MOV M,A DCR C JMP L1 HLT

Binary To BCD

AGAIN:

FINISH:

LXI H,2101 MVI C,04 ORA M DCR C JZ FINISH RLC INX H JMP AGAIN INX H CPI OA

RESULT:

JC RESULT MVI A,EE MOV M,A MOV M,C HLT

BCD To Binary MVI D,08 LXI H,2100 MVI C,04 MOV B,M AGAIN: MOV A,B INX H ANA D JZ LOOP MVI A,01 LOOP: MOV M,A MOV A,D RRC MOV D,A DCR C JNZ AGAIN HLT Decimal to Hexa

L1:

L2:

L3:

XRA A MOV C,A LXI H,2100 MOV B,M ADI 64 JNC L2 INR C DCR B JNZ L1 MOV D,A INX H MOV B,M XRA A ADI 0A DCR B JNZ L3 INX H ADD M ADD D

L4:

JNC L4 INR C INX H MOV M,C INX H MOV M,A HLT

Hexa Decimal to Decimal LXI H,4150 LXI B,0000 MOV A,M SUI 64 JC L2 INR B JMP L1 ADI 64 SUI OA JC L4 INR C MOV M,B MOV B,A MOV A,C RLC RLC RLC RLC ADD B INX H MOV M,A HLT

Sample Programs 1) TO ADD TWO 8-BIT DATA LDA 000 MOV B,A LDA 001 MVI C,00 ADD B JNC AHEAD INR C [lab1] STA 002 MOV A,C STA 003 HLT Here, 000 -> 1st Operand 001 -> 2nd Operand 003 -> Sum 004 -> Carry ---------------------------------------------------------------2) TO ADD TWO 8-BIT DATA PRESENT IN THE MEMORY LXI H,000 MVI C,OO MOV A,M INX H ADD M JNC LAB1 INR C [LAB1] INX H MOV M,A INX H MOV M,C HLT Here, 000 -> 1st Operand 001 -> 2nd Operand 003 -> Sum 004 -> Carry ---------------------------------------------------------------3) TO ADD TWO 16-BIT DATA LHLD 000 XCHG LHLD 002 XRA A DAD D JNC LAB1 INR A [LAB1] SHLD 004 STA 006 HLT Here, 000 & 001 -> 1st Operand 002 & 003 -> 2nd Operand 004 & 005 -> Sum 006 -> Carry -----------------------------------------------------------------

Related Documents

Micro Processor Programs
November 2019 12
Programs Micro Processor
October 2019 14
All Micro Processor Programs
November 2019 11
Micro Processor
November 2019 22
Micro Processor 2
November 2019 10