0% found this document useful (0 votes)
124 views

8085 Assignment Answers

The document contains several examples of source code programs in assembly language along with sample problems the programs are solving. The programs demonstrate arithmetic operations like addition, multiplication and bitwise operations on numbers stored in memory locations. The last program identifies the memory location that contains a number with the most significant bit set to 1.

Uploaded by

Swaminathanbchn
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
124 views

8085 Assignment Answers

The document contains several examples of source code programs in assembly language along with sample problems the programs are solving. The programs demonstrate arithmetic operations like addition, multiplication and bitwise operations on numbers stored in memory locations. The last program identifies the memory location that contains a number with the most significant bit set to 1.

Uploaded by

Swaminathanbchn
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

Source Program 1: LHLD 4000H XCHG LHLD 4002H MOV A, E ADD L MOV L, A MOV A, D ADC H MOV H, A SHLD 4004H

05H. HLT

: : : :

: Get first I6-bit number in HL : Save first I6-bit number in DE : Get second I6-bit number in HL Get lower byte of the first number : Add lower byte of the second number Store result in L register Get higher byte of the first number : Add higher byte of the second number with CARRY Store result in H register : Store I6-bit result in memory locations 4004H and 40 : Terminate program execution

Source program 2: LHLD 4000H : Get first I6-bit number XCHG : Save first I6-bit number in DE LHLD 4002H : Get second I6-bit number in HL DAD D : Add DE and HL SHLD 4004H : Store I6-bit result in memory locations 4004H and 4005H. HLT : Terminate program execution Sample problem 4: (2200) = 1100 (0CH) (2201) = 0101 (05H) Multiplicand = 1100 (1210) Multiplier = 0101 (510) Result = 12 x 5 = (6010)

Source program : LXI H, 2200 : Initialize the memory pointer MOV E, M : Get multiplicand MVI D, 00H : Extend to 16-bits INX H : Increment memory pointer MOV A, M : Get multiplier LXI H, 0000 : Product = 0 MVI B, 08H : Initialize counter with count 8 MULT: DAD H : Product = product x 2 RAL JNC SKIP : Is carry from multiplier 1 ? DAD D : Yes, Product =Product + Multiplicand SKIP: DCR B : Is counter = zero JNZ MULT : no, repeat SHLD 2300H : Store the result HLT : End of program

Sample problem 9: (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

Sample problem 6: (2200H) = 04H (2201H) = 56H (2202H) = A9H (2203H) = 73H (2204H) = 82H Result = 02 since 2202H and 2204H contain numbers with a MSB of 1.

Source program : LDA 2200H MOV C, A : Initialize count MVI B, 00 : Negative number = 0 LXI H, 2201H : Initialize pointer BACK: MOV A, M : Get the number ANI 80H : Check for MSB JZ SKIP : If MSB = 1 INR B : Increment negative number count SKIP: INX H : Increment pointer

DCR JNZ MOV STA HLT

C : Decrement count BACK : If count 0 repeat A, B 2300H : Store the result : Terminate program execution

Source program 10 : LXI H, 4200H : Set pointer data for MOV B,M : Get the data in B-reg MOV A,B : Copy the data to A-reg ANI OFH : Mask the upper nibble INX H : Increment address as 4201 MOV M,A : Store the lower nibble in MOV A,B : Get the data in A-reg ANI FOH : Bring the upper nibble to RRC RRC RRC RRC INX H MOV M,A : Store the upper nibble in HLT : Terminate program execution

array

memory lower nibble position

memory

Sample problem 7: (2200H) = 04 (2201H) = 34H (2202H) = A9H (2203H) = 78H (2204H) =56H Result = (2202H) = A9H

Source program : MVI B, 00H MVI C, 08H MOV A, D BACK: RAR JNC SKIP INR B

SKIP: DCR C JNZ BACK HLT

You might also like