Aim
To write a 8085 ALP to find largest and smallest of n 8 bit numbers
Program
Address | Mnemonics | Opcode | LSB | MSB | Comments |
2000 | LDA 2500 | 3A | 0 | 25 | Load accumulator with count |
2003 | MOV C,A | 4F | Copy count to register c | ||
2004 | LXI H,2501 | 21 | 01 | 25 | Load first number's address in HL pair |
2007 | MOV A,M | 7E | Copy first accumulator | ||
2008 | MOV B,A | 47 | Copy first number to register B | ||
2009 | MOV D,A | 57 | Copy first number to register D | ||
200A | DCR C | 0D | Decrement limit | ||
200B | INX H | 23 | Take next number in HL pair | ||
200C | MOV A,M | 7E | Copy next number to accumulator | ||
200D | CMP B | B8 | Compare the number with accumulator | ||
200E | JNC 2012 | D2 | 12 | 20 | If new number is larger jump to 2012 |
2011 | MOV B,A | 47 | If number is smaller set it as smaller | ||
2012 | CMP D | BA | Compare number with register D | ||
2013 | JC 2017 | DA | 17 | 20 | Jump to 2017 if new number is not larger |
2017 | DCR C | 0D | Decrement count by 1 | ||
2018 | JNZ 200B | C2 | 0B | 20 | Check limit reached or not |
201B | MOV A,B | 78 | Copy smallest number to accumulator | ||
201C | STA 27F4 | 32 | F4 | 27 | Store smallest value |
201F | MOV A,D | 7A | Copy largest value to accumulator | ||
2020 | STA 27F5 | 32 | F5 | 27 | Store largest value |
2023 | CALL 06E3 | CD | E3 | 6 | Call subroutine |
2026 | HLT | 76 | End |
No comments:
Post a Comment
Post Your valuable comments here ..........