In: Computer Science
Write an assembly program (Data and Code) that uses loop to read 10 numbers and output the largest of those numbers, you can assume any length for those numbers.
80x86 assembly language
Codes
find out the largest among 8-bit n numbers, where size “10" is stored at memory address 2000 : 600 and the numbers are stored from memory address 2000 : 601 and store the result (largest number) into memory address 2000 : 800.
Example
Input data and memory address
10 | 20 | 21 | 22 | 23 | 24 | 25 | 36 | 26 | 27 | 28 |
600 | 601 | 602 | 603 | 604 | 605 | 606 | 607 | 608 | 607 | 608 |
Out put data
36 |
800 |
Algorithm –
Program
MEMORY ADDRESS | MNEMONICS | COMMENT |
---|---|---|
500 | MOV SI, 600 | SI<-600 |
503 | MOV CL, [SI] | CL<-[SI] |
505 | MOV CH, 00 | CH<-00 |
507 | INC SI | SI<-SI+1 |
508 | MOV AL, [SI] | AL<-[SI] |
50A | DEC CL | CL<-CL-1 |
50C | INC SI | SI<-SI+1 |
50D | CMP AL, [SI] | AL-[SI] |
50F | JNC 513 | JUMP TO 513 IF CY=0 |
511 | MOV AL, [SI] | AL<-[SI] |
513 | INC SI | SI<-SI+1 |
514 | LOOP 50D | CX<-CX-1 & JUMP TO 50D IF CX NOT 0 |
516 | MOV [800], AL | AL->[800] |
51A | HLT | END |
Explanation –