Riscv Program 1

Share Embed Donate


Short Description

asdasfsafsafasf...

Description

Assembly programming using RISCV-ISA simulator tool chain 1. Testing esting the RISCV RISCV-T -Tool ool chain chain

All the lab machines have been installed with the RISC-V tools. To check if the installation is correct, please run the followin code to check the spike RISCV ISA simulator. !" mkdi mkdirr risc riscvv-te test stss #" cd ris riscv cv-t -tes ests ts $" echo -e %&include 'stdio.h()n int main*void" + printf*ello world))n"/ return 0/ 1% ( hello.c 2" riscv32-unknown-elf-cc -o hello hello.c 4" spike pk hello Alternatel5 5ou ma5 install the riscv-tool chain on 5our laptops b5 followin the steps at the link https677ithub.com7riscv7riscv-tools . 2. Getting Getting starte started d ith RISC RISC-V -V assemb assembly ly progra programs ms

 

a. Create a file called link.ld in the current workin director5 with the followin contents. 89T:9T;ARC* riscv " S 0?#00/ .te?t 6 + @*.te?t" 1 .data AIB=*0?!000" 6 + @*.data" 1 .bss 6 + @*.bss" 1 ;end > ./ 1

b. All 5our RISC-V asm prorams that 5ou code in this tutorial will have the followin code at the beinnin in the 5our;file.s .globl _start;  _start:

& :ut 5our own code here

 _exit:

c. To compile please use ! riscv$#-unknown-elf-cc -nostdlib -nostartfiles -march>rv$#i -T.7link.ld 5our;file.s d. To e?ecute please use6 spike pk a.out

". #rogramming $uestions

8nce the hello world proram is workin, the oal of this tutorial is to write the below prorams usin RISCV ISA in assembl5 lanuae. a" Compute the sum of nD natural numbers assumin reister ?4 has the value n. et the result of the sum be in reister ?3. Test 5our assembl5 proram for different values of n *i" ! *ii" !0#2 *iii" #02E and *iv" 20F3 . Rename these prorams as sum;!.s, sum;!0#2.s, sum;#02E.s, and sum;20F3.s respectivel5 before submission. b" The Gibonacci numbers are the numbers in the followin inteer seHuence, called the Gibonacci seHuence, and characteried b5 the fact that ever5 number after the first two is the sum of the two precedin ones6 !,!,#,$,4,E,!$,#!,$2,44,EF J Assume an inteer nD is in reister ?4 and compute the last inteer in a seHuence of n Gibonacci numbers. Return the last inteer in reister ?3. Test 5our assembl5 proram for different values of n *i" ! *ii" # *iii" !0 *iv" !4 and *v" #0 Rename these prorams as fib;!.s,fib;#.s, fib;!0.s, fib;!4.s and fib;#0.s respectivel5 before submission. c" Compute the reatest common divisor *cd" of two inteers, assumin the two inteers are in reisters ?4 and ?3. :ut the result of the computation in ?K. Test 5our assembl5 proram for different values of ?4 and ?3 for the followin6 *i" 0,4 *ii" 4,0 *iii" $, 4 *iv" #43,#02E *v" 20F4, !4 Rename these prorams as cd;0;4.s, cd;4;0.s, cd;$;4.s, cd;#43;#02E.s and cd;20F4;!4.s respectivel5 before submission.

2. %oodle submission Tar ip the folder with all the appropriatel5 named assembl5 prorams and submit the ip file with 5our roll number as the ip file name.

Challenge $uestion Currentl5 the proram after e?ecutin prints the contents of all the i. reisters and the statement An illeal instruction was e?ecutedD. 8ne eas5 wa5 of overcomin this statement is b5 loopin back to the last instruction, b5 addin e?it6 Lal e?it to the end of the assembl5 proram.

8ther than loopin back to the last instruction an5 other interestin wa5s of overcomin the above illeal instruction messae are welcome. owever, the proram does e?ecute and chane the reister values despite this messae and 5ou can check the contents of the reisters for 5our proram correctness.

View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF