ADDITION

 

Program:

 

//Addition of two 8bit numbers

//Manually strore 1st no in the memory location C050

//Manually store 2nd no in the memory location C051

//Result is stored in C053

 

LXI H,C050

MOV A,M

INX H

ADD M

STA C052

HLT

 

Input:

 

Content of Memory Location C050: 05h

Content of Memory Location C051: 04h

 

Output:

Content of Memory Location C052: 09h

 

SUBSTRACT

 

Program:

 

//Substraction of two 8bit numbers

//Manually strore 1st no in the memory location C050

//Manually store 2nd no in the memory location C051

//Result is stored in C053

 

LXI H,C050

MOV A,M

INX H

SUB M

INX H

MOV M,A

HLT

 

Input:

 

Content of Memory Location C050: 45h

Content of Memory Location C051: 12h

 

Output:

Content of Memory Location C052: 33h

 

MULTIPLY

 

Program:

 

//Multiply 5 by 4

//Result is stored in A Register.

 

MVI C,05H

MVI A,00H

MVI B,04H

NEXT: ADD B

DCR C

JNZ NEXT

HLT

 

Output:

5x4= 20 in decimal

Accumulator: 14h

 

OR

 

//Multiple 4 by 2

//Result is stored in A Register.

 

MVI A,04H

RAL

HLT

 

Output:

4x2= 08 in decimal

Accumulator: 08h

 

DIVISION

 

Program:

 

//Divide 15 decimal by 5 decimal

//Store result in c registers

 

MVI A,0FH

MVI B,05H

MVI C,00H

NEXT: INR C

SUB B

JNZ NEXT

HLT

 

Output:

15/5= 15 in decimal

C register: 03h

 

OR

 

//Divide 8 by 2

//Result is stored in A Register.

 

MVI A,08H

RAR

HLT

 

Output:

8/2= 04 in decimal

Accumulator: 04h