Home.............Unix a view.......... Unix porgram........DBMS.............basic computer tutor............microprocessor 8085..........Student part time jobs..........Colleges in Tamilnadu.............website park
Home
Hello Friends,
I am launching these blog for the students as a guiding aspect. In this blog you can clarify your doubts about c/c++,unix,os, DBMS, microprocessor. I am going to publish many complicated programs such as sjf preemptive algorithm and micro processor programs which will help you in lab programs. Here I have mentioned some part time jobs for student also. I referred some contents from other resources, So I should say thanks to them.

This blog will be updated by many programs like anna university question papers, c and c++ programs, Many projects on c,c+= and micro processor,etc. I hope that this will be a helpful blog for you. Especially this will help for the anna university students.
I need your cooperation and valuable feed backs, Which will help me to improve my self. You can send your suggestions to
studentsevice@gmail.com
.

"All the best"
Thank you.

microprocessor 8085

Add two 16-bit numbers - Source Program 1

Sample problem:

(4000H) = 15H
(4001H) = 1CH
(4002H) = B7H
(4003H) = 5AH
Result = 1C15 + 5AB7H = 76CCH
(4004H) = CCH
(4005H) = 76H

Source Program 1:
LHLD 4000H : Get first I6-bit number in HL
XCHG : Save first I6-bit number in DE
LHLD 4002H : Get second I6-bit number in HL
MOV A, E : Get lower byte of the first number
ADD L : Add lower byte of the second number
MOV L, A : Store result in L register
MOV A, D : Get higher byte of the first number
ADC H : Add higher byte of the second number with CARRY
MOV H, A : Store result in H register
SHLD 4004H : Store I6-bit result in memory locations 4004H and 4005H.
HLT : Terminate program execution

SUBTRACTING TWO 16 BIT NUMBERS:


Sample problem

(4000H) = 19H
(400IH) = 6AH
(4004H) = I5H (4003H) = 5CH
Result = 6A19H - 5C15H = OE04H
(4004H) = 04H
(4005H) = OEH

Source program:

LHLD 4000H : Get first 16-bit number in HL
XCHG : Save first 16-bit number in DE
LHLD 4002H : Get second 16-bit number in HL
MOV A, E : Get lower byte of the first number
SUB L : Subtract lower byte of the second number
MOV L, A : Store the result in L register
MOV A, D : Get higher byte of the first number
SBB H : Subtract higher byte of second number with borrow
MOV H, A : Store l6-bit result in memory locations 4004H and 4005H.
SHLD 4004H : Store l6-bit result in memory locations 4004H and 4005H.
HLT : Terminate program execution.



2's complement of the number

(4200H) = 55H
Result = (4300H) = AAH + 1 = ABH

Source program:

LDA 4200H : Get the number
CMA : Complement the number
ADI, 01 H : Add one in the number
STA 4300H : Store the result
HLT : Terminate program execution

SUM OF THE SERIES:


4200H = 04H

420lH = 9AH

4202H = 52H

4203H = 89H

4204H = 3EH

Result = 9AH + 52H + 89H + 3EH = H

4300H = B3H Lower byte

4301H = 0lH Higher byte

Source program 2

LDA 4200H

MOV C, A : Initialize counter

LXI H, 4201H : Initialize pointer

SUB A :Sum low = 0

MOV B, A : Sum high = 0

BACK: ADD M : Sum = sum + data

JNC SKIP

INR B : Add carry to MSB of SUM

SKIP: INX H : Increment pointer

DCR C : Decrement counter

JNZ BACK : Check if counter 0 repeat

STA 4300H : Store lower byte

MOV A, B

STA 4301H : Store higher byte

HLT :Terminate program execution

MULTIPLY TWO 8 BIT NUMBERS:

(2200H) = 03H

(2201H) = B2H

Result = B2H + B2H + B2H = 216H

= 216H

(2300H) = 16H

(2301H) = 02H

Source program :

* LDA 2200H
* MOV E, A
* MVI D, 00 : Get the first number in DE register pair
* LDA 2201H
* MOV C, A : Initialize counter
* LX I H, 0000 H : Result = 0
* BACK: DAD D : Result = result + first number
* DCR C : Decrement count
* JNZ BACK : If count 0 repeat
* SHLD 2300H : Store result
* HLT : Terminate program execution


Divide a 16 bit number by a 8-bit number
(2200H) = 60H

(2201H) = A0H

(2202H) = l2H

Result = A060H/12H = 8E8H Quotient and 10H remainder

(2300H) = E8H

(2301H) = 08H

(2302H= 10H

(2303H) 00H

Source program :

* LHLD 2200H : Get the dividend
* LDA 2202H : Get the divisor
* MOV C, A
* LXI D, 0000H : Quotient = 0
* BACK: MOV A, L
* SUB C : Subtract divisor
* MOV L, A : Save partial result
* JNC SKIP : if CY 1 jump
* DCR H : Subtract borrow of previous subtraction
* SKIP: INX D : Increment quotient
* MOV A, H
* CPI, 00 : Check if dividend < divisor
* JNZ BACK : if no repeat
* MOV A, L
* CMP C
* JNC BACK
* SHLD 2302H : Store the remainder
* XCHG
* SHLD 2300H : Store the quotient
* HLT : Terminate program execution

Arrange in ascending order
* MVI B, 09 : Initialize counter
* START : LXI H, 2200H: Initialize memory pointer
* MVI C, 09H : Initialize counter 2
* BACK: MOV A, M : Get the number
* INX H : Increment memory pointer
* CMP M : Compare number with next number
* JC SKIP : If less, don't interchange
* JZ SKIP : If equal, don't interchange
* MOV D, M
* MOV M, A
* DCX H
* MOV M, D
* INX H : Interchange two numbers
* SKIP:DCR C : Decrement counter 2
* JNZ BACK : If not zero, repeat
* DCR B : Decrement counter 1
* JNZ START
* HLT : Terminate program execution


Add two decimal numbers of 6 digit each

* LXI H, 6000H : Initialize pointer l to first number
* LXI D, 6l00H : Initialize pointer2 to second number
* LXI B, 6200H : Initialize pointer3 to result
* STC
* CMC : Carry = 0
* BACK: LDAX D : Get the digit
* ADD M : Add two digits
* DAA : Adjust for decimal
* STAX.B : Store the result
* INX H : Increment pointer 1
* INX D : Increment pointer2
* INX B : Increment result pointer
* MOV A, L
* CPI 06H : Check for last digit
* JNZ BACK : If not last digit repeat
* HLT : Terminate program execution