Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

2. This question is meant to reinforce your understanding of how a CPU executes program code by focusing on the low-level instructions it executes, versus

image text in transcribedimage text in transcribedimage text in transcribed

2. This question is meant to reinforce your understanding of how a CPU executes program code by focusing on the low-level instructions it executes, versus higher-level instructions you would use in a programming language such as R. You will use the hypothetical assembly language outlined below in Table I, in addition to 10 registers referred to by SrO,... Sr10, and system RAM as needed instruction add reg1, reg2, reg3 | regl = reg2 + reg3 sub reg1, reg2. reg3 | regl = reg2-reg3 div regl, reg2. regi regl = reg2/reg mul regl, reg2, reg3 reg reg2 reg3 rnuli reg1, reg2 , x | reg 1 = reg2 *x, where x is some integer addi regl, reg2, x subi regi, reg2, x | regl-reg2-x, where x is some integer divr regl, reg2, xreg eg2/x, where x is real, truncates result mov regl, reg label name: .type, value create .type variable in RAM where name-value lw reg, RAM source move word from RAM to a register sw reg, RAM source move word from register to RAMM la reg, RAM source move address of RAM to a register sa reg, RAM_source move address in register to RAMM b label beq reg1.reg2.label | Jump to label if regl reg2 blt reg1,reg2,label bgt regl,reg2,label jump to label if reg1 > reg2 bqe regl.reg2.label jump to label if regl 2reg2 ble regl,reg2,label bne regl,reg2.label | jump to label if reglreg2 print reg prints reg read reg done meaning example add $r0, Srl, $r2 sub Sr0, Sr1, Sr2 div Sr0, Sr1, $r2 mul SrO, Srl, Sr2 mul $rO, $rl, 4 addi $rO, Sr1, 5 addi Sr0, Sr1, 5 divr Sr0, Sr1, 2 mov Sr0, Sr1 main: varl: .word 5 lw Sr4 varl sw Sr4,varl la $r4 varl sa Sr4,varl b main beq Sr0,Srl,main blt $r0,Srl,main bgt $r0,Srl,main bge SrO,Sr1,main ble SrO,Srl.main bne SrO,Sr1,main print SrO prints SrO reg reg2 + r, where x is some integer reg1 = reg2 create a reference label in the code jump to a label l in the program jump to label if reg1 0, F11 and F2-1): stringl: .asciiz "The result is:" value: .Wor main read $r9 ble Sr9,0, end lw $r0, value addi Sr0, Sr0. 1 beq Sr9, 1, end mov $r2, $rO mov $r1, Sr2 lw $r8, 1 add SrO, Sr1, Sr2 mov $r2, Srl mov $r1, Sr0 addi Sr8, Sr8, 1 beq Sr9, Sr8, end b l loop: oop sw $r0, value la Sr7, strinl prints Sr7 print SrO done en Create an assembly program using the above language for the following algorithm, that should perform a mathematical operation using all elements of arrays A and B. You can assume that function basicFunc works correctly. Make your solution as concise (fewest number of lines) as possible. When submitting your results show a table with two columns: (1 the original program, (2) your assembly code (a) (15 points) Create an assembly program using the above language for the following algorithm. In this algorithm, it searches 2 arrays and do basic mathematical operations. It is expected to return a number that is equal to 'SUM'. 1: A = {1, 10, 13, 15, 21, 55, 67) 2: B-11, 2, 3, 4, 5, 6, 7) 3: 0, L-length(A)-1, SUM 0 4: whilei reg2 bqe regl.reg2.label jump to label if regl 2reg2 ble regl,reg2,label bne regl,reg2.label | jump to label if reglreg2 print reg prints reg read reg done meaning example add $r0, Srl, $r2 sub Sr0, Sr1, Sr2 div Sr0, Sr1, $r2 mul SrO, Srl, Sr2 mul $rO, $rl, 4 addi $rO, Sr1, 5 addi Sr0, Sr1, 5 divr Sr0, Sr1, 2 mov Sr0, Sr1 main: varl: .word 5 lw Sr4 varl sw Sr4,varl la $r4 varl sa Sr4,varl b main beq Sr0,Srl,main blt $r0,Srl,main bgt $r0,Srl,main bge SrO,Sr1,main ble SrO,Srl.main bne SrO,Sr1,main print SrO prints SrO reg reg2 + r, where x is some integer reg1 = reg2 create a reference label in the code jump to a label l in the program jump to label if reg1 0, F11 and F2-1): stringl: .asciiz "The result is:" value: .Wor main read $r9 ble Sr9,0, end lw $r0, value addi Sr0, Sr0. 1 beq Sr9, 1, end mov $r2, $rO mov $r1, Sr2 lw $r8, 1 add SrO, Sr1, Sr2 mov $r2, Srl mov $r1, Sr0 addi Sr8, Sr8, 1 beq Sr9, Sr8, end b l loop: oop sw $r0, value la Sr7, strinl prints Sr7 print SrO done en Create an assembly program using the above language for the following algorithm, that should perform a mathematical operation using all elements of arrays A and B. You can assume that function basicFunc works correctly. Make your solution as concise (fewest number of lines) as possible. When submitting your results show a table with two columns: (1 the original program, (2) your assembly code (a) (15 points) Create an assembly program using the above language for the following algorithm. In this algorithm, it searches 2 arrays and do basic mathematical operations. It is expected to return a number that is equal to 'SUM'. 1: A = {1, 10, 13, 15, 21, 55, 67) 2: B-11, 2, 3, 4, 5, 6, 7) 3: 0, L-length(A)-1, SUM 0 4: whilei

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

1 2 3 Data Base Techniques

Authors: Dick Andersen

1st Edition

0880223464, 978-0880223461

More Books

Students also viewed these Databases questions

Question

How We Listen?

Answered: 1 week ago