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

Explain sample instruction format of mips instruction, Q. Explain Sample In...

Q. Explain Sample Instruction Format of MIPS instruction? All MIPS instructions are of same size and are 32 bits long. MIPS designers chose to keep all instructions of same len

Programming with loops and comparisons, Q. Programming with loops and compa...

Q. Programming with loops and comparisons? This segment deals with more practical illustrations employing comparison, loops and shift instructions. Simple Program Loops

Illustrate the text area, specifies a form field where user can enter large...

specifies a form field where user can enter large amounts of text. In most respects, works like an field. It can have a name as well as a def

Data can be moved using a ''write:'' statement, Data can be moved from one ...

Data can be moved from one field to another using a 'Write:' Statement and stored in the desired format.  Write: Date_1 to Date_2 format DD/MM/YY.

State the various security tools, State the various Security Tools Sec...

State the various Security Tools Securing an Intranet is not a simple task. Just as articles in a house are protected by use of various types of security systems such as lock

Use of hypertext links in internet access, Use of Hypertext links in Intern...

Use of Hypertext links in Internet access From the user's point of view, the Web having of a vast, worldwide collection of documents i.e. pages. Every page may have links (poin

Explain semaphore, What is a semaphore? Semaphore: It is a synchroniz...

What is a semaphore? Semaphore: It is a synchronization tool which gives a general-purpose solution to controlling access to critical sections.

What is object orientation, What is object orientation? Object orientat...

What is object orientation? Object orientation means that we classify software as a collection of discrete objects that incorporate with together DS and behaviour. Four aspe

Software estimation, Software Estimation The statement of scope helps t...

Software Estimation The statement of scope helps the planner to established estimates using one or more method which fail into two wide categories: empirical modeling and decom

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