bly Programs

COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
1st Edition
ISBN:9780357392676
Author:FREUND, Steven
Publisher:FREUND, Steven
Chapter3: Working With Large Worksheets, Charting, And What-if Analysis
Section: Chapter Questions
Problem 2AYK
icon
Related questions
Question
1. RISC-V Assembly Programs
Write the following RISC-V assembly programs:
Program 1: Divisible by 9?
Write a RISC-V assembly program that determines if the value in register a0 is divisible by 9. If
it is, the register a0 should be 1 at the end of the program, otherwise a0 should be 0. Run, test,
and debug your program using the Venus simulator. Test enough different values of a0 to
convince yourself that your assembly code works. Be sure to comment each line of code (using
# ). You may use only the following subset of instructions: add, addi, sub, beq, blt, bge, bne,
and j. Be sure to comment each line of code (using #). Note: assume that a0 contains only
positive numbers. Name your text file div9.s.
Hint: think of the method of repeated subtraction to determine if a number is divisible by 9. Try
your algorithm out by hand (with several non-trivial but simple examples) before coding it.
Program 2: Big-endian to little-endian conversion
Write a RISC-V assembly language code snippet that converts 8 words of memory starting at
address 0x300 from big-endian to little-endian. Name your text file big2little.s.
Some hints: Start by doing an example by hand for a word starting at memory address 0. Be
sure to write out the byte addresses below each byte (for both big- and little-endian). For
example, the word Ox1234ABCD stored in big-endian at memory address 0 would have the
following byte addresses and data:
Address 0 holds 0x12
Address 1 holds 0x34
Address 2 holds OxAB
Address 3 holds 0xCD
To convert this to little-endian, you would move the bytes to the following addresses (i.e., by
first loading the bytes into registers using load byte: lb, and then storing them into different
address locations using store byte: sb):
Address 3 holds 0x12
Address 2 holds 0x34
Address 1 holds OxAB
Address 0 holds 0xCD
Transcribed Image Text:1. RISC-V Assembly Programs Write the following RISC-V assembly programs: Program 1: Divisible by 9? Write a RISC-V assembly program that determines if the value in register a0 is divisible by 9. If it is, the register a0 should be 1 at the end of the program, otherwise a0 should be 0. Run, test, and debug your program using the Venus simulator. Test enough different values of a0 to convince yourself that your assembly code works. Be sure to comment each line of code (using # ). You may use only the following subset of instructions: add, addi, sub, beq, blt, bge, bne, and j. Be sure to comment each line of code (using #). Note: assume that a0 contains only positive numbers. Name your text file div9.s. Hint: think of the method of repeated subtraction to determine if a number is divisible by 9. Try your algorithm out by hand (with several non-trivial but simple examples) before coding it. Program 2: Big-endian to little-endian conversion Write a RISC-V assembly language code snippet that converts 8 words of memory starting at address 0x300 from big-endian to little-endian. Name your text file big2little.s. Some hints: Start by doing an example by hand for a word starting at memory address 0. Be sure to write out the byte addresses below each byte (for both big- and little-endian). For example, the word Ox1234ABCD stored in big-endian at memory address 0 would have the following byte addresses and data: Address 0 holds 0x12 Address 1 holds 0x34 Address 2 holds OxAB Address 3 holds 0xCD To convert this to little-endian, you would move the bytes to the following addresses (i.e., by first loading the bytes into registers using load byte: lb, and then storing them into different address locations using store byte: sb): Address 3 holds 0x12 Address 2 holds 0x34 Address 1 holds OxAB Address 0 holds 0xCD
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Function Arguments
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
Computer Science
ISBN:
9780357392676
Author:
FREUND, Steven
Publisher:
CENGAGE L
Systems Architecture
Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning