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]
3 years ago
10

Write a MASM program to calculate Fibonacci numbers:

Computers and Technology
1 answer:
IceJOKER [234]3 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
A distortion of information about the demand for a product as it passes from one entity to the next across the supply chain is c
Rina8888 [55]

Answer:

The answer is "bullwhip".

Explanation:

It is an effect, that exists as a consumer, which has highly unstable to demand and, also, increases perceptions around. It also enables you to defines the System design to have a ripple effect.

  • The purpose of that kind of document is to offer an imaginative analysis of the fiction, complemented by simulations to make the situation more readable.
  • It is a large stock variation, that is triggered specifically by alterations throughout the production of the customers.
8 0
3 years ago
Which of the following is considered to be intellectual property?
ad-work [718]

The answer is actually A. I took the test and selected the wrong answer, but A was the one the test said was right. Plz mark brainliest!!! Hope this helped! ;^)

4 0
3 years ago
What science category includes physics and biology?
enyata [817]

Answer:

Physical science is the study of the inorganic world. That is, it does not study living things. (Those are studied in biological, or life, science.) The four main branches of physical science are astronomy, physics, chemistry, and the Earth sciences, which include meteorology and geology.

5 0
2 years ago
Electricity was seen as a mysterious force and began to creat a stir when people called​
atroni [7]

This isn't related to computers and when you look it up all it comes up with a Stars Wars.

3 0
3 years ago
Identify an advantage of the software as a service (SaaS) approach in public cloud computing. Group of answer choices The user h
adell [148]

Answer:

The user does not need to purchase and install additional hardware to provide increased capacity.

Explanation:

Cloud computing can be defined as a type of computing that requires shared computing resources such as cloud storage (data storage), servers, computer power, and software over the internet rather than local servers and hard drives.

Generally, cloud computing offers individuals and businesses a fast, effective and efficient way of providing services.

Cloud computing comprises of three (3) service models and these are;

1. Platform as a Service (PaaS).

2. Infrastructure as a Service (IaaS).

3. Software as a Service (SaaS).

Software as a Service (SaaS) can be defined as a cloud computing delivery model which involves the process of making licensed softwares available over the internet for end users on a subscription basis through a third-party or by centrally hosting it. Some examples of SaaS are Go-ogle apps, Bigcommerce, Salesforce, Slack, Dropbox, DocuSign, Microsoft Office 365, etc.

An advantage of the software as a service (SaaS) approach in public cloud computing is that the user do not have to purchase and install additional hardware to provide increased capacity because the software provider makes all of the necessary features for smooth operations and proper functioning available to the user.

7 0
2 years ago
Other questions:
  • In UNIX, how do I set the permissions on MyProgram.py to: rwx---r-x?
    7·1 answer
  • What is another term for accountability?
    7·2 answers
  • David would like to send a letter to more than one hundred people. He would like the letter to have names and addresses inserted
    12·2 answers
  • Write a class called Date that represents a date consisting of a day, month, and year. A date object should have the following m
    10·1 answer
  • HELP PLEASE 100 POINTS
    8·2 answers
  • JPG is considered a lossy file format. What does this mean?
    15·2 answers
  • Which of the following best describes the basic purpose of the internet?
    11·1 answer
  • In which situation would saving a Word document as a PDF be most useful?
    9·2 answers
  • Does analogue conversation take place in source as transmitter?
    5·2 answers
  • Which of the following is not considered essential for an electronic device to be called a computer?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!