Question

E2.15 In assembly code, write a program to count the number of elements in an array...

E2.15 In assembly code, write a program to count the number of elements in an array that are smaller than 16. The array is stored at memory locations starting from $1010. The array has 30 8-bit unsigned elements. Store the count in the memory location $C001.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

MVI B,30 // Assign the array size to the register B

MVI C,00 // Initialize the counter

LXI H,1010 // Assign the starting address to the memory

L1: MOV A,M // Load the content of the memory location(M) to Accumulator (A)

XRI 16 // Perform XOR operation with Accumulator, if accumulator value is equal to 16 then it produces 0 in Accumulator

JZ COUNT // If the accumulator value is 0, then it jumps to the loop count

INX H // Increment the memory location if the value is not equal to 16

COUNT: INR C // Count value is increased

INX H // Increment the memory location if value is equal to 16

DCR B // Decrease the Array size after one comparison.

JNZ L1 // the control is transferred to L1

MOV A,C // once the count is done then it is stored in accumulator

STA C001 // The result stored in accumulator is stored in the memory address C001

HLT

Add a comment
Know the answer?
Add Answer to:
E2.15 In assembly code, write a program to count the number of elements in an array...
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
  • PROGRAMMING ASSIGNMENT: Write a fully-commented program for the HC12 board, including appropriate directives and labels for...

    PROGRAMMING ASSIGNMENT: Write a fully-commented program for the HC12 board, including appropriate directives and labels for memory operands and constants. The program should do the following: • The program should start execution at address $2000. • Use directives to create an array of N=20 unsigned 8-bit decimal values: 15,20,14,13,17,9,10,5,18,7,19,8,1,3,4,11,2,6,12,16 stored in contiguous memory at locations start at $1000. • Sort given numbers in a descending order. • Store sorted numbers at memory locations starting from $1000. *assembly programming language*

  • Need to write a MIPS assembly program that finds the minimum and maximum and sum of...

    Need to write a MIPS assembly program that finds the minimum and maximum and sum of a stored array. It also finds the locations of the minimum and maximum. The interaction between the main program and the function is solely through the stack. The function stores $ra immediately after being called and restores $ra before returning to main. The main program reserves a static C like array (index starts from 0) of 10 elements and initializes it. The maximum should...

  • E 2.12 Write a program to compute the average of the square of all elements of...

    E 2.12 Write a program to compute the average of the square of all elements of an array with 32 8-bit unsigned numbers. the array is stored at $1000-$101F. Store the results at $1020-$1021.

  • Write common assembly language (RISC) programs to a) sum the first n elements of an array...

    Write common assembly language (RISC) programs to a) sum the first n elements of an array A, and b) compute r = ab for unsigned integers a and b. Each program will consist of a driver and a subprogram. The drivers will 1) read one or more values from the keyboard, 2) call the subprogram, and 3) print a result. The subprograms must not: ● store into memory, ● use registers $1 – $9, or ● make system calls

  • Please finish this Assembly code. Modify it to compute the number of elements in the deiiference...

    Please finish this Assembly code. Modify it to compute the number of elements in the deiiference of SetA and SetB (as in HW1-2) and store that number at the memory location labeled DifferenceSize. Again, assume that SetA has eight integers and SetB has ten, and that the two sets are “sets” in that there are no duplicate elements within an individual set but they may be in any order. # # This program determines difference of SetA (always of size...

  • In x86 architecture, write an assembly program for the following: Xarray is an unsigned array of...

    In x86 architecture, write an assembly program for the following: Xarray is an unsigned array of bytes. Yarray is a signed array of words that has same number of elements as Xarray. Zarray is an uninitialized signed array of doublewords. Write a program that adds each element of Xarray to the corresponding element in Yarray and stores the result as an element in Zarray.

  • 1. A system with a word length of 32-bit and byte-addressable memory has ten consecutive 32-bit...

    1. A system with a word length of 32-bit and byte-addressable memory has ten consecutive 32-bit signed numbers stored starting from memory location NUM. Write a RISC-style program to count the number of positive numbers in it and store the count in location COUNT.

  • 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,...

  • Write a program using PIC24 instructions yo add three 8-bit numbers stored in the successive memory...

    Write a program using PIC24 instructions yo add three 8-bit numbers stored in the successive memory locations starting from 0x0800. Store the result in the memory lpcation 0x0855.

  • In this problem, you will write a LC-3 assembly code that removes blank spaces from a...

    In this problem, you will write a LC-3 assembly code that removes blank spaces from a string. Assume that the string starts at memory location 0x5000, and is terminated by a ‘\0’ character (ASCII value = 0). Your program should store the modified string in the memory location starting at 0x5100. You do not need to modify the original string stored at 0x5000. You can assume that the original string at 0x5000 will always be less than 100 characters in...

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