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

Displaying the towers of hanoi solution, Once you have a solution to the To...

Once you have a solution to the Towers of Hanoi problem, we want to improve the display of the solution. The details of the implementation are up to you. At a minimum, your impleme

Differentiate among validation and exception testing, Differentiate between...

Differentiate between validation and exception testing. - Validation testing is done to test software in conformance to requirements specified. It aims to demonstrate that soft

Why we use addressing schemes, Q Why we use addressing schemes? An ope...

Q Why we use addressing schemes? An operation code of an instruction tells the operation to be performed. This operation is executed on some data stored in memory or register.

Explain design parameters, Explain the following design parameters S, ...

Explain the following design parameters S, SC, TC, C, CCI, EUF, K, T S The various terms are given below: S: Total number of switching components A good design sh

What is edi (electronic data interchange), What is EDI (Electronic Data Int...

What is EDI (Electronic Data Interchange)? EDI: Electronic Data Interchange (EDI) is used by organizations for transactions that happen on regular basis to a pre-determined for

Explain naming convention globals, Explanation The values of global vari...

Explanation The values of global variables can be used and changed all over the project within all scripts and libraries. However it is highly recommended to remain the number o

Arterial puncture - specimen collection, Arterial puncture - Specimen colle...

Arterial puncture - Specimen collection: Arterial puncture:    this requires special skill and usually performed only by physician. The preferred site is radial arter

Some of the advantages of b2b, Some of the advantages of B2B are: i) En...

Some of the advantages of B2B are: i) Enhanced customer satisfaction Code ii) Enhanced inventory system iii) Simple and cost effective marketing iv) Coordination among

What is assembler, What is Assembler A macro-assembler or assembler nor...

What is Assembler A macro-assembler or assembler normally forms a part of operating system. That translates an assembly language program into machine language program.

Minmax search - artificial intelligence, MinMax Search Parents frequent...

MinMax Search Parents frequently get two children to share a cake by asking one to cut the cake and the other to select which half they want to eat. In this two player cake-sco

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