
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Determine Modulus of First Array Elements Corresponding to Another in 8086
In this program we will see how to perform modulus of the first array corresponding to the next array.
Problem Statement
Write 8086 Assembly language program perform modulus of the first array corresponding to the next array.
Discussion
In this example there are two different arrays. The arrays are stored at location 501 onwards and 601 onwards. The size of these two arrays are stored at offset location 500. We are taking the array size to initialize the counter, then by using loops we are getting the modulus of the elements one by one
Input
Address | Data |
---|---|
… | … |
500 | 04 |
501 | 0F |
502 | 0B |
503 | 05 |
504 | 08 |
… | … |
601 | 04 |
602 | 0A |
603 | 02 |
604 | 03 |
… | … |
Flow Diagram
Program
MOV SI, 500 ;Point Source index to 500 MOV CL, [SI] ;Load the array size into CL MOV CH, 00 ;Clear Upper half of CX INC SI ;Increase SI register to point next location MOV DI, 601 ;Destination register points to 601 L1: MOV AL, [SI] ;Load A with the data stored at SI MOV AH, 00 ;Clear upper half of AX DIV [DI] ;Subtract AX by DI MOV [SI], AH ;Store AH to SI address INC SI ;SI Point to next location INC DI ;DI Point to next location LOOP L1 ;Jump to L1 until the counter becomes 0 HLT ;Terminate the program
Output
Address | Data |
---|---|
… | … |
500 | 04 |
501 | 00 |
502 | 01 |
503 | 01 |
504 | 02 |
… | … |
Advertisements