Question

Write a full assembly language program that calls a subroutine to help implement the following algorithm:...

Write a full assembly language program that calls a subroutine to help implement the following algorithm:

short int ary[15]; //array of 15 elements of short int type
ary[0] = 1;
ary[1] = 1;
for(int i=2; i<5; i++)
{
ary[i] = ary[i-1]+ ary[i-2];

}

0 0
Add a comment Improve this question Transcribed image text
Answer #1
DATA SEGMENT
A DW 8,2,5,6,1,3
DATA ENDS
CODE SEGMENT
      ASSUME DS:DATA,CS:CODE
START:
      MOV AX,DATA
      MOV DS,AX
      MOV CX,0000
      MOV CL,06
      LEA BX,A
      MOV DX,WORD PTR[BX]
      MOV AX,0000
   L1:CMP AX,WORD PTR[BX]
      JNC L2
      MOV AX,WORD PTR[BX]
   L2:CMP DX,WORD PTR[BX]
      JC L3
      MOV DX,WORD PTR[BX]
   L3:ADD BX,02
      DEC CL
      CMP CL,00
      JNZ L1
      MOV AH,4CH
      INT 21H
CODE ENDS
END START

OUTPUT:->
-G CS: 002
Add a comment
Know the answer?
Add Answer to:
Write a full assembly language program that calls a subroutine to help implement the following algorithm:...
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
  • must be written in assembly code Write an MSP430 assembly language subroutine, REP_FREE, to examine the...

    must be written in assembly code Write an MSP430 assembly language subroutine, REP_FREE, to examine the elements of an array of positive word-size numbers stored at location ARRAY_IN. The array is already sorted in an ascending order. The first element is the number, n,which is the length of the array. The subroutine will copy the elements from location ARRAY_IN to location ARRAY_OUT. While copying, if an element appears more than once (repeated), then the repeated copies are ignored. In essence,...

  • Assembly Language Program Help Write a procedure named CountNearMatches that receives pointers to two arrays of...

    Assembly Language Program Help Write a procedure named CountNearMatches that receives pointers to two arrays of signed doublewords, a parameter that indicates the length of the two arrays, and a parameter that indicates the maximum allowed difference (called diff) between any two matching elements. For each element x(i) in the first array, if the difference between it and the corresponding y(i) in the second array is less than or equal to diff, increment a count. At the end, return a...

  • In C language Write a program that includes a function search() that finds the index of...

    In C language Write a program that includes a function search() that finds the index of the first element of an input array that contains the value specified. n is the size of the array. If no element of the array contains the value, then the function should return -1. The program takes an int array, the number of elements in the array, and the value that it searches for. The main function takes input, calls the search()function, and displays...

  • MIPS assembly language Implement the following code in MIPS int array [ ] {2, 3, 4,...

    MIPS assembly language Implement the following code in MIPS int array [ ] {2, 3, 4, 5, 6); int main) int num, position; scanf("%d",&num) ; position search(array, printf("The position is: num, 5); %d\n",positio int search(int array, int num, int size int position =-1; for(int i-0;i<size; i++) if(array [i]=num) { position-i; break; return position; Register map $s1: position $a0: array address $a1: num . $a2: size . $VO: return value

  • please show work and explain steps Implement the following subroutine in PIC24 assembly language. Use the...

    please show work and explain steps Implement the following subroutine in PIC24 assembly language. Use the policy estab- lished in this chapter for using working registers for subroutine parameters and loca II this subroutine implements an uint16 t swap. void u16-swap(uint16-t* pul 6-х, uint8-t u8-1, uint8-t u8.j)( ls uint16-t u16_k; u16-k = pu16-XLu8-1);

  • Write a program in ARM assembly language that copies each element of array A to consecutive...

    Write a program in ARM assembly language that copies each element of array A to consecutive fourth elements of array B, i.e., A[0] to B[0], A[1] to B[3], A[2] to B[7], etc. The array A is 12 elements long, and each element is a number that is 32 bits (1 word) wide. Assume the base address of array A is in register R2, and the base address of array B is in R3.

  • Write an ARM assembly language subroutine (named nfibo) to calculate and return the n-th Fibonacci number....

    Write an ARM assembly language subroutine (named nfibo) to calculate and return the n-th Fibonacci number. Fibonacci numbers (or a Fibonacci sequence) are a series of numbers with a property that the next number in the series is a sum of previous two numbers. Starting the series from 0, 1 as the first two numbers we have 0, 1, (0 + 1) = 1, (1 + 1) = 2, (1 + 2) = 3, (2 + 3) = 5, (3...

  • Please, implement these subroutine. Write assembly language subroutines to perform the calculations listed hereunder: Table 1:...

    Please, implement these subroutine. Write assembly language subroutines to perform the calculations listed hereunder: Table 1: List of required subroutines. z= ABS (1) umber z=MAX(x, y) Get absolute value of a x: 16-bit signed z: 16-bit unsigned signed number. integer integer for the Assume signed number are absolute value of x represented in 2's i.e. X complement format. Given the elements x and x, y: 16-bit z: 16-bit unsigned y. Return the element with unsigned integers. integer storing the greater...

  • Write a program that finds (ANSWER IN C LANGUAGE!): 1. The sum of all elements at...

    Write a program that finds (ANSWER IN C LANGUAGE!): 1. The sum of all elements at even subscripts 2. The sum of all elements at odd subscripts 3. The sum of all elements You are allowed to perform this functionality within main. Main program: ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #include <stdio.h> int main() { /* Declare array variables */ const int NUM_VALS = 4; int userValues[NUM_VALS]; int i; // counter int even = 0; int odd = 0; int sum = 0; /* Initialize...

  • i am trying to write a subroutine in assembly that removes all occurrences of a given...

    i am trying to write a subroutine in assembly that removes all occurrences of a given character in a string. The subroutine takes two parameters: the string pointer, and the character to be removed. Write a C code that calls this subroutine. The string is defined in the C source code file as global. Assume the assembly and C code are in separate files. Use Keil/uVision to test your program where the C code should ask the assembly subroutine to...

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
ADVERTISEMENT