1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Ulleksa [173]
2 years ago
10

Write a MASM program to calculate Fibonacci numbers:

Computers and Technology
1 answer:
IceJOKER [234]2 years ago
3 0

Answer:

.data

programmerName          BYTE   "PROGRAMMER NAME", 0

programTitle       BYTE   "PRINT FIBONACCI NUMBERS WITHIN RANGE", 0

prompt_1           BYTE   "WHAT IS YOUR NAME? ", 0

prompt_2           BYTE   "Enter the number of Fibonacci terms you want to display between [1 - 46]", 0

num_fibo               DWORD   ?

previous1               DWORD   ?

previous2               DWORD   ?

spaces               BYTE   " ",0

goodbye               BYTE   "Goodbye, ", 0

first2           BYTE   "1 1 ", 0

first1           BYTE   "1", 0

temp               DWORD   ?

moduloFive           DWORD   5

UPPERLIMIT = 46

LOWERLIMIT = 1

;user's name

buffer               BYTE 21 DUP(0)

byteCount           DWORD   ?

;greet the user

hi                   BYTE   "Hi, ",0

;validate

highError           BYTE   "The number you entered is too high! Please enter number below 46", 0

lowError           BYTE   "The number you entered is too low! Please eneter number above 1", 0

;EC -> Setting Background Color and Text Color

val1 DWORD 11

val2 DWORD 16

.code

main PROC

  ; setting text color to teal

      mov eax, val2

      imul eax, 16

      add eax, val1

      call setTextColor

  ; introduction

      mov       edx, OFFSET programTitle

      call   WriteString

      mov       edx, OFFSET programmerName

      call   WriteString

      call   CrLf

      ; EC Prompt

      mov       edx, OFFSET ec_prompt

      call   WriteString

      call   CrLf

      mov       edx, OFFSET prompt_1

      call   WriteString

      call   CrLf

      ; get user's name

      mov       edx, OFFSET buffer   ;point to the buffer

      mov       ecx, SIZEOF   buffer   ; specify max characters

      call   ReadString

      mov       byteCount, eax

      ; greet the user

      mov       edx, OFFSET hi

      call   WriteString

      mov       edx, OFFSET buffer

      call   WriteString

      call   CrLf

      ;userInstructions

topPrompt:

          mov       edx, OFFSET prompt_2

          call   WriteString

          call   CrLf

  ;getUserData

      call   ReadInt

      mov       num_fibo, eax

  ; Validate user data

      cmp       eax, UPPERLIMIT

      jg       TooHigh

      cmp       eax, LOWERLIMIT

      jl       TooLow

      je       JustOne

      cmp       eax, 2

      je       JustTwo

  ; displayFibs

      mov       ecx, num_fibo

      sub       ecx, 3           ; we start at iteration 3, the first two are taken care of by JustOne and JustTwo

      mov       eax, 1

      call   WriteDec

      mov       edx, OFFSET spaces

      call   WriteString

      call   WriteDec

      mov       edx, OFFSET spaces

      call   WriteString

      mov       previous2, eax

      mov       eax, 2

      call   WriteDec

      mov       edx, OFFSET spaces

      call   WriteString

      mov       previous1, eax

      fib:

          add       eax, previous2

          call   WriteDec

          mov       edx, OFFSET spaces

          call   WriteString

          mov       temp, eax

          mov       eax, previous1

          mov       previous2, eax

          mov       eax, temp

          mov       previous1, eax

          mov       edx, ecx

          cdq

          div       moduloFive

          cmp       edx, 0

          jne       skip

          call   CrLf

      skip:

              mov       eax, temp

              loop   fib

              jmp       TheEnd

TooHigh:

          mov       edx, OFFSET highError

          call   WriteString

          jmp       TopPrompt

TooLow:

          mov       edx, OFFSET lowError

          call   WriteString

          jmp       TopPrompt

JustOne:

          mov       edx, OFFSET first1

          call   WriteString

          jmp       TheEnd

JustTwo:

          mov       edx, OFFSET first2

          call   WriteString

          jmp       TheEnd

;farewell

TheEnd:

          call   CrLf

          mov       edx, OFFSET goodbye

          call   WriteString

          mov       edx, OFFSET buffer

          call   WriteString

          call   CrLf

  exit   ; exit to operating system

main ENDP

END main

You might be interested in
"As a ____ database management system, Access is particularly powerful because you can enter data once and then retrieve informa
Galina-37 [17]

Answer:

d.Relational

Explanation:

With the help of Access users can successfully manage valuable information by saving it easily for future reporting it , and analysis.In access users can have access to organized data in their database with minimal effort.

You can enter the data and you can select which data you want and use queries for that accordingly for example:- joins,select statements etc.

7 0
3 years ago
Evaluate if the following function is a good candidate to be placed in a library. Why or why not?
Anastaziya [24]

Answer:

No, this would not be a good candidate because it can't be used in creating new programs.

Explanation:

^

8 0
2 years ago
Read 2 more answers
The one who will defeat me in this typing race I will mark the one brainliest:
fredd [130]

Answer:

yes

Explanation:

can you send the link....

5 0
3 years ago
Read 2 more answers
The a0 is the part of the central processing unit that performs arithmetic calculations for the computer.
Serga [27]

Answer:

It is the ALU or the Arithmetic Logic Unit.

Explanation:

It is the ALU. However, keep in mind that registers and buses do a very important task. The number of registers we have, faster is the processing, and the opposite is true as well. And there is a reason behind this if we have different channels for sending and receiving the data from the memory, and several registers for storing the data, and we can formulate the requirement seeing the requirements for full adder and half adders. Remember we need to store several variables in case of the full adder, and which is the carry, and if we have separate registers for each of them, our task becomes easier. Remember its the CU that tells the ALU what operation is required to be performed. Also remember we have the same channel for input and output in the case of Van Neumann architecture, as we have a single bus. and we also have a single shared memory. And Harvard architecture is an advanced version of it.

6 0
2 years ago
Often, a single source does not contain the data needed to draw a conclusion. It may be necessary to combine data from a variety
nlexa [21]

To measure the pollution of a particular river, one must take the sample of the river and take the sample of pure water, then draw the conclusion, it will tell the amount of pollution in the river water.

<h3>What is pollution?</h3>

Pollution is the mixing of unwanted or harmful things in any substance or compound.

Water pollution is the mixing of toxics and chemicals in water.

Thus, to measure the pollution of a particular river, one must take the sample of the river and take the sample of pure water, then draw the conclusion, it will tell the amount of pollution in the river water.

Learn more about pollution

brainly.com/question/23857736

#SPJ1

6 0
2 years ago
Other questions:
  • Recall that book ciphers do not necessarily require a full book to decode, but instead any written text, such as the Declaration
    6·1 answer
  • The Modified Greiss chemical test is used to detect the presence of what chemicals that indicate muzzle to target distance?
    11·1 answer
  • I need help to find out what is wrong with this program and my variable, "exponent" comes out as 0 in the output instead of the
    14·1 answer
  • On the Insert tab, select Table &gt; _______ to create a table from selected text.
    14·1 answer
  • Write a method for the Customer class that that will return a string representing a bill notice when passed a double value repre
    14·1 answer
  • I need urgent help. which of these network has minimum data loss. a. LAN b. MAN c. WAN ​
    11·1 answer
  • How is a microkernel architecture different from a monolithic architecture?
    5·1 answer
  • Which command can be used to find errors on a hard drive​
    6·1 answer
  • Match the desired outcome to the appropriate action.
    6·1 answer
  • Which of the following items in the folder window allows users to view locations which have been visited before?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!