answersLogoWhite

0

Source program

LXI SP, 27FFH ; Initialize stack pointer

LDA 2200H ; Get the number

CPI 02H ; Check if number is greater than 1

JC LAST

MVI D, 00H ; Load number as a result

MOV E, A

DCR A

MOV C,A ; Load counter one less than number

CALL FACTO ; Call subroutine FACTO

XCHG ; Get the result in HL

SHLD 2201H ; Store result in the memory

JMP END

LAST: LXI H, 000lH ; Store result = 01

END: SHLD 2201H

HLT

Subroutine Program:

FACTO:LXI H, 0000H

MOV B, C ; Load counter

BACK: DAD D

DCR B

JNZ BACK ; Multiply by successive addition

XCHG ; Store result in DE

DCR C ; Decrement counter

CNZ FACTO ; Call subroutine FACTO

RET ; Return to main program

User Avatar

Wiki User

14y ago

Still curious? Ask our experts.

Chat with our AI personalities

RafaRafa
There's no fun in playing it safe. Why not try something a little unhinged?
Chat with Rafa
BlakeBlake
As your older brother, I've been where you are—maybe not exactly, but close enough.
Chat with Blake
JudyJudy
Simplicity is my specialty.
Chat with Judy

Add your answer:

Earn +20 pts
Q: Compute the factorial of n using 8085 microprocessors?
Write your answer...
Submit
Still have questions?
magnify glass
imp