Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The code has to be in Mars and only allowed the commands in Appendix (60%) Part A: generate the sample points via a right-up spiral.

The code has to be in Mars and only allowed the commands in Appendix

image text in transcribed

image text in transcribed

(60%) Part A: generate the sample points via a "right-up" spiral. Write MIPS code to generate n sample points from (x[1],y[1]) to (x[n],y[n]) in the following way: starting from (0, 0), always follow the sequence of going right, up, left, and down, in a "spiral fashion that can reach any point exactly once, within enough steps. Specifically: first 1 step then 1 step then 2 steps then 2 steps then 3 steps then 3 steps then 4 steps then 4 steps right (x1, y1) = (1, 0) up (x2, y2) = (1,1) left (x3, y3) = (0,1) down (x5, y5) = (-1,0) right (x7, y7) = (0,-1) up (x10, y10) = (2,0) left ... down ... (x4, y4) = (-1, 1) (x6, y6) = (-1,-1) (x8, y8) = (1,-1) (x11, y11) = (2, 1) (x9, y9) = (2,-1) (x12, y12) = (2, 2) Other Specifics: In the end, your program should store the word arrays: x[1] at M[0x2020), followed by x[2] at Ox2024, x[3] at Ox2028, etc y[1] at M[0x2420], followed by y[2] at 0x2424, y[3] at Ox2428, etc Your program must begin with the following line of code which is used to initialize the number of sample points (n=100). Therefore, if we modify this instruction, we can change the number of points to generate. (This should work for Part A, B, and C) addi $3, 90, 100 # n = 100 Appendix: allowed MIPS instructions - choose up to 15 different ones among them sll add rd, s, it Add sub rd, s, it Subtract Add Imm. addu , , t. Add Unsigned subu , , Subtract Unsigned addiu rt, s, imm Add Imm. Unsigned mult es, it Multiply dives, rt Divide multus, et Multiply Unsigned divus, Et Divide Unsigned mfhird Move From Hi mflord Move From Lo and And or Or nor Nor xord,, It eXclusive Or And Imm. ori It, Es, mm Or Imm. xori eXclusive Or Imm. Shift Left Logical srl rt, sh Shift Right Logical sra Shift Right Arithmetic sllv rd, t, Shift Left Logical Variable srlv Shift Right Logical Variable srav , Shift Right Arithmetic Variable slt rd, s, it Set if Less Than sltu , , It Set if Less Than Unsigned siti rt, E, Setif Less Than Imm. sltiu rt, , imm Set il Less Than Imm. Unsigned j addr Jump jalad Jump And Link jrs Jump Register jalrts Jump And Link Register begt, ts, imm Branch if Equal bnet, r, imm Branch if Not Equal sy scall System Call lui Load Upper Imm. lb rt, Inns) Load Byte lbu Load Byte Unsigned lht, ins) Load Half Load Half Unsigned It, Imm(s) Load Word Store Byte It, Imm(s) Store Half Store Word It, immer) Load Linked It, inn (ru) Store Conditional rd - rs + rt R0/20 rd - rs - It R0/22 rt - rs + imm I 8 rd - rs + It R0/21 rd - rs - It R0/23 rt - rs + imm+ I 9 {hi, lo} - Is * it R0/18 lo - rs / rt; hi - Isrt R0/la fhi, lo} - rs + rt R0/19 lo - rs / It; hi - Isrt R0/1b rd - hi R0/10 rd - lo R0/12 rd - rs & It R0/24 rd - rst R0/25 rd - (rsrt) R0/27 rd - rs It R0/26 rt - rs & immo rt - rs immo Id rt - rs immo le rd - rt >> sh R0/2 rd - rt >> sh R0/3 rd - rt >> rs R0/6 rd - rt >> rs R0/7 rd - rs >> sh R0/2 rd - rt >> sh R0/3 rd - rt >> rs R0/6 rd - rt >> rs R0/7 rd - rs

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design And SQL For DB2

Authors: James Cooper

1st Edition

1583473572, 978-1583473573

More Books

Students also viewed these Databases questions