Question

Write a Marie or MASM program which sums the numbers from 1 to N, where you...

Write a Marie or MASM program which sums the numbers from 1 to N, where you choose N. For extra credit nmake it a subroutine and call it several times.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Assume DS: Data ,CS:Code

Data Segment

TABADR DW 6000H

COUNT DB 05H

Data Ends

Code Segment

Start:

MOV AX,Data

MOV DS,AX

MOV SI,TABADR

MOV CL,COUNT

Loop1:MOV AL,[SI]

ADD BL,AL

INC SI

DEC CL

JNZ Loop1

INT 03H

Code Ends

End Start

STEP BY STEP EXPLANATION OF PROGRAM IS GIVEN BELOW:

--Here,Assume is an assembler directive which tells the start of the programby assuming cs as code segment and ds as data degment.

--'Data Segment' tells the start of data segment.

--TABADR stands for tab address and DW stands for define word i.e we are setting TABADR equal to 6000H.

--DB stands for define byte and the value of COUNT is set to 05H.

--DATA ENDS signifies the end of data segment.

--'Code Segment' tells the start of code segment.

--Since,we cannot put anything directly into segment registers such as DS.So we first initialize AX with the value 'Data' segment address and then move value of AX into DS.

--SI is initialised with the value of TABADR i.e 6000

--CL is a counter reg and hence initialized with count value i.e 05.

--The data  at 6000H (i.e the value of SI) is then moved to AL reg.

--ADD AL with contents of BL and store the result in BL.

--Then we increment SI so that it now points to next address location

--And simultaneously we decrement CL bcoz we have read one value.

--We then apply a jump condition to the loop Loop1 unitl the value of CL becomes zero.

--If CL becomes zero it comes out of the loop and runs the instruction INT 21H,which is actually a break point interrupt which stops the execution.

--Then the code segment ends.

Here, a subroutine is made in the form of a loop to call the statements again and again.

Add a comment
Know the answer?
Add Answer to:
Write a Marie or MASM program which sums the numbers from 1 to N, where you...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a MARIE program that sums the numbers from 1 to N (N(N + 1) /...

    Write a MARIE program that sums the numbers from 1 to N (N(N + 1) / 2) using a loop and user input.

  • Using the MARIE computer assembly language, write a program that computes the following expression: z ß...

    Using the MARIE computer assembly language, write a program that computes the following expression: z ß (a * b) * (c * d). The computer will read in the input values a, b, c, and d from the keyboard, and the final result (z) has to be displayed. In addition, every time an input value is read in, it must be displayed on the screen. Each time a multiplication of two numbers is needed, it has to be done using...

  • 2. Write a program that reads N integer numbers of array from the user and then...

    2. Write a program that reads N integer numbers of array from the user and then displays the sum, max number and the numbers of the array use four subroutines ( Read_Array(), Calculate_Sum(), Find_Max() and Display_Array()). Here is sample output Please enter number of elements: 4 Please enter the required numbers: 50 100 150 20 The entered numbers are: 50 100 150 20 Sum is : 320 Max is 150 by Mpsi ,sum and max to call subroutine and retrieve...

  • Write a MARIE assembly program to read two different positive numbers from the keyboard and output...

    Write a MARIE assembly program to read two different positive numbers from the keyboard and output the smaller number to the screen.

  • 1. Write a MARIE program that can implement a sum of two products, i.e. using MARIE...

    1. Write a MARIE program that can implement a sum of two products, i.e. using MARIE program to calculate 13*35 + 27*18 (* means multiply) and store the result to a variable Sum. Hint: e.g. following code can be used to initialize the variables A, B, C and D, in which A is 13, B is 35, C is 27 and D is 18 A,       DEC   13    /one of the four input numbers: 13 B,       DEC   35...

  • 2. Write a Marie program that accepts two positive (inputs) two integers and outputs the sum...

    2. Write a Marie program that accepts two positive (inputs) two integers and outputs the sum of both of the integers and all the numbers in between Write a Marie program that determines the largest of a series of positive integers provided by a user. The user will enter a -1 when she is finished. Up to 10 numbers will be provided by the user. Write a Marie program that accepts two positive integers, multiples them by repeated addition, and...

  • Task 2.5: A simple calculator (25 marks) In this task you will develop a MARIE program...

    Task 2.5: A simple calculator (25 marks) In this task you will develop a MARIE program that implements four basic functions of a calculator: addition, subtraction, multiplication, division, and exponent. The program should be performing the user selected tasks (one of the mentioned mathematical operations) after the user enters one of the selection inputs, ‘a’, ‘s’, ‘m’, ‘d’ or ‘p’. Here, input ‘a’ selects addition process, ‘s’ selects subtraction process, ‘m’ selects multiplication process, ‘d’ selects division process, and ‘p’...

  • ssembly Language Programming with x86, IRVINe MASM 1. Write a program to add 7 12 times...

    ssembly Language Programming with x86, IRVINe MASM 1. Write a program to add 7 12 times and print out the result ------------------------------------------------------------------------------- Write a program to print and add 10 20 30 40 50   ; you can use a loop The output should be “The sum of 10 20 30 40 50 ”

  • Write a MARIE program to calculate some basic statistics on a list of positive numbers. The...

    Write a MARIE program to calculate some basic statistics on a list of positive numbers. The program will ask users to input the numbers one by one. Assume that all numbers will be in the range 1 to 1000. To terminate the data entry, user will input any negative number. Once the data entry is complete, the program will show four statistics about the list of numbers: (1) Count (2) Minimum value (3) Sum of numbers (4) "Mean/Average" calculation. As...

  • Write a C++ program divisorsum.cpp which which reads numbers, one at a time, from the terminal...

    Write a C++ program divisorsum.cpp which which reads numbers, one at a time, from the terminal input, and outputs the proper divisors and the proper divisor sum for that integer in an equation format. Here is an example: > divisorsum 6 6: 1+2+3 = 6 888 888: 1+2+3+4+6+8+12+24+37+74+111+148+222+296+444 = 1392 0 > Note: spaces will be ignored, but punctuation symbols (:+=) must be in the correct places. Your program should handle the calculation of proper divisor sums for all numbers...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT