You are on page 1of 3

An Assembly Language Program to find the square of an 8-bit number using 8085?

Algorithm 1) Load the HL pair with the number whose square is to be found. 2) Copy the number to C and B registers. 3) Initialize D and A registers with 0. 4) Add content of accumulator with register B. 5) Check for carry. 6) If no carry go to step 8 else go to next step. 7) Increment content of D. 8) Decrement content of C. 9) If ZF = 0 then go to next step else go to step 4. 10) Store the product and carry in memory. 11) Terminate the program. Program MEMORY 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 420A 420B 420C 420D 420E 420F 4210 4211 4212 4213 4214 4215 4216 4217 GO LABEL MNEMONIC LXI H,4500 OPCODE 21 00 45 7E 47 16 00 4F 7A 80 D2 0E 42 14 0D C2 09 42 32 00 42 74 32 01 COMMENT Load the number to the HL pair Copy the number to the accumulator Copy the accumulator content to register B Initialize D with 0 Copy accumulator content to C Copy content of D to accumulator [A] [A] + [B] Jump on no carry to the label AHEAD Increment D Decrement C Jump on non-zero to the label GO Store the product to 4100 Copy carry to accumulator Store carry to 4101

MVI A,M MVI B,A MVI D,00 MOV C,A MOV A,D ADD B JNC AHEAD

AHEAD

INR D DCR C JNZ GO

STA 4100

MOV A,D STA 4101

4218 4219 Observation Input at Output at 4100 : 05H

HLT

41 76

Program ends

4100 : 19H ----------- Square 4101 : 00H ----------- Carry - See more at: http://programmings4u.blogspot.in/2013/06/factsqu.html#square

An Assembly Language Program to find the square root of a number using 8085?
Algorithm 1) Load the HL pair with the address of the number whose square root is to be found. 2) Copy the number to accumulator. 3) Initialize E with 0. 4) Subtract content of E from accumulator. 5) Increment register E by 2. 6) Increment content C register by 1. 7) Compare accumulator content with 0. 8) If accumulator content is not zero then go to step 4 else go to step 9. 9) Store the square root in to the memory. 10) Terminate the program. Program MEMORY 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 420A 420B 420C 420D LABEL MNEMONIC MVI C,00 LXI H,4100 OPCODE 0E 00 21 00 41 7E 1E 01 93 1C 1C 0C FE 00 COMMENT Initialize C as 0 Load HL pair with the address of the data whose occurrence is to be found Copy the data to the Accumulator Initialize E with 0 [A] [A] + [E] Increment register E Increment register E Increment register C Compare accumulator content with 0

MOV A,M MVI E,01 LOOP SUB E INR E INR E INR C CPI ,00

420E 420F 4210 4211 4212 4213 4214 4215 Observation Input at Output at 4100 : 4500 :

JNZ LOOP

MOV A,C STA 4500

C2 07 42 79 32 00 45 76

Jump on non-zero to the label LOOP Copy content of register C to accumulator Store the square root in 4500 Program ends

HLT

31H 07H

------------ Square root

Program to find the square of a number. (BCD 16 bit) 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 4100 4103 4104 4105 4106 4107 410A 410B 410C 410F 4110 4111 4112 4113 21 00 50 LXI H,05000H 4E MOV C,M AF XRA A 57 MOV D,A 86 LOOP: ADD M D2 0B 41 JNC J1 14 INR D 0D J1: DCR C C2 06 41 JNZ LOOP 23 INX H 77 MOV M,A 23 INX H 72 MOV M,D 76 HLT

You might also like