Add a byte number from one memory location, Computer Engineering

Assignment Help:

Add a byte number from one memory location to a byte from subsequent memory location and put sum in the third memory location. Also save carry flag in the least significant bit of fourth memory location. 

; ABSTRACT                         : This program adds 2-8-bit words in the memory locations

;                                               : NUM1 and NUM2. The result is stored in the memory 

;                                               : location RESULT. The carry bit, if any will be stored as 

;                                               : 0000 0001 in the location CARRY

 

; ALGORITHM:

;                       get NUM1

;                       add NUM2 in it

;                       put sum into memory location RESULT

;                       rotate carry in LSB of byte

;                       Mask off upper seven bits of byte

;                       store the result in the CARRY location.

;

; PORTS:                     None used

; PROCEDURES:      None used

; REGISTERS:           Uses CS, DS, AX

;

DATA   SEGMENT

NUM1                         DB                  25h                  ; First number

 NUM2                        DB                  80h                  ; Second number

 RESULT                    DB                  ? ; Put sum here

 CARRY                     DB

DATA   ENDS

CODE   SEGMENT

                        ASSUME CS: CODE, DS: DATA

START: MOV AX, DATA                ; Initialise data segment

MOV DS, AX                        ; register using AX

            MOV AL, NUM1                   ; Load the first number in AL

            ADD AL, NUM2                   ; Add 2ndnumber in AL

MOV RESULT, AL  ; Store the result

               RCL AL, 01                         ; rotate carry into LSB

               AND AL, 00000001B         ; Mask out all but LSB

               MOV CARRY, AL             ; Store the carry result

            MOV AH, 4CH

               INT 21H

CODE ENDS

END START

Discussion:

RCL instruction brings carry in the least significant bit position of AL register. AND instruction is employed for masking higher order bits of the carry now in AL.

In the same way we can also write applications employing other shift instructions.


Related Discussions:- Add a byte number from one memory location

Exponential search, Exponential Search Another alternative to variable ...

Exponential Search Another alternative to variable size decrease-and-conquer search is known as exponential search. This algorithm begins searching at the beginning of the list

Is it possible to decrease clock skew to zero, Is it possible to decrease c...

Is it possible to decrease clock skew to zero? Describe your answer? Even if there are clock layout strategies (H-tree) which can into theory reduce clock skew to zero by havi

What are parallel algorithms, What are Parallel Algorithms? The central...

What are Parallel Algorithms? The central assumption of the RAM model does not hold for some newer computers that can implement operations concurrently, i.e., in parallel algor

Forward checking - artificial intelligence, Forward checking: Whether ...

Forward checking: Whether to add some sophistication to the search method there constraint solvers use a technique called as forward checking. So here the general idea is to w

Explian two limitations of dead-box analysis, (a) Explian two limitations o...

(a) Explian two limitations of dead-box analysis. (b) Describe why memory analysis is difficult. (c) With reference to the "Shadow Walker" rootkit, explain what is meant by

Implemented in a program developed for sorting , A student counted up the n...

A student counted up the number of statements implemented in a program developed for sorting n integers and came up with a recurrence of the form: T(n) = a * n + b + 2T(n/2), an

Comparator, 6 bit magnitude comparator

6 bit magnitude comparator

Explain concurrent sharing, Explain Concurrent sharing. Concurrent s...

Explain Concurrent sharing. Concurrent sharing: Some number of programs may share a file concurrently. While this is the case, this is essential to ignore mutual interferen

Higher order predicate logic, Higher Order Predicate Logic : In the v...

Higher Order Predicate Logic : In the very first order predicate logic, we are only allowed to quantify over objects. If we are considered to allow ourselves to quantify over

Display the map centered on the users location, Question: a) The follo...

Question: a) The following is a description of the navigation options in a mobile web site which provides public bus time slots for a city. It is an interesting service for m

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd