logo

Crowdly

ECE2071 - Systems programming - S1 2025

Шукаєте відповіді та рішення тестів для ECE2071 - Systems programming - S1 2025? Перегляньте нашу велику колекцію перевірених відповідей для ECE2071 - Systems programming - S1 2025 в learning.monash.edu.

Отримайте миттєвий доступ до точних відповідей та детальних пояснень для питань вашого курсу. Наша платформа, створена спільнотою, допомагає студентам досягати успіху!

In this MIPS program, we will create a function sum_n, that can sum any number of integers. The function caller will push all integers onto the stack before calling the function. The number of integers to be summed will be passed to the function in register $a0. Inside the sum_n function, these integers will be accessed from the stack using offsets from the stack pointer ($sp).

 

Fill in the blanks in the following MIPS program. The main program will push some sample integers onto the stack (in order) and then call the sum_n function.

.text

.globl main

main:

# Sample integers to push onto the stack

li $t0, 5

li $t1, 10

li $t2, 15

li $t3, 20

# Push the integers onto the stack (in reverse order of use if reading sequentially)

addi $sp, $sp, -4

sw $t3, 0($sp)

addi $sp, $sp, -4

sw $t2, ($sp)

addi $sp, $sp, -4

sw $t1, ($sp)

addi $sp, $sp, -4

sw $t0, ($sp)

# Set the number of arguments in $a0

li $a0,

# Call the sum_n function

sum_n

# end in infinite loop:

end:

j end

# Function to sum an arbitrary number of integers from the stack

sum_n:

# Initialise the sum to zero

li $v0, 0

# Initialise a counter

li $t0, 0

sum_loop:

# Check if we have processed all arguments

bge $t0, , sum_loop_end

# Calculate the address of the next value in the stack

mul $t1, $t0, 4

add $t1, $t1, $

# Load the current argument from the stack

lw $t2, 0()

# Add the current argument to the sum

add $v0, $v0, $t2

# Increment the counter

addi $t0, $t0, 1

# Loop back

b sum_loop

sum_loop_end:

# Return the sum in $v0

jr $ra

Переглянути це питання

Complete the following MIPS program so that it displays the digit '1' on the right seven-segment display in the MARS Digital Lab Sim.

 

.data

DISPLAY_ADDRESS: .word 0xFFFF0010

.text

.globl start

start:

# Load the address of the seven-segment display into a register

li $t0,

# Load the value to display '1' into another register

li $t1,

# Write the value to the display

sb $t1,($t0)

end:

j end

Переглянути це питання

Using the following data (if b prefix, assume binary, otherwise, decimal. I.e. $t0=5 means 101 is stored in the bottom bits of $t0, $t0=b101 means the same thing)

    $t1 = b1110

    $t2 = 15

    $t3 = 12

    $t4 = 9

    $t5 = b1010

    $zero

What is in register $v0 after the execution of each of the following instructions: (answer in decimal, not hexademical or binary)

  1. and $v0, $t1, $zero:
  2. ori $v0, $t5, 15:
  3. xor $v0, $t3, $t3:
  4. and $v0, $t4, $t3:

 

 

Переглянути це питання

What single instruction could you use to create the 4-bit one’s complement (inverted) version of the value in register $t1 and store it in $v0?

WARNING: cannot be pseudo - ie “P” type instruction, as these are not “one instruction”.

You should enter your answer as a single instruction in the format:

  • For R-type instructions:

    • <instruction_name> <register>, <register>, <register> 

  • For I-type instructions:

    • <instruction_name> <register>, <register>, <immediate>

  • For J-type instructions:

    • <instruction_name> <label>

For example, if your answer was to use the add instruction with $t0, $t1, and $t2, you would enter the text:

add $t0, $t1, $t2

 

Переглянути це питання

For the table you filled out above, do you notice any patterns?

 

Переглянути це питання

Suppose we have a single bit, either 1 or 0. We will now consider what might happen if we perform any one of the following operations on this number:

  1. AND with 0
  2. OR with 0
  3. XOR with 0
  4. AND with 1
  5. OR with 1
  6. XOR with 1

What is the final value? Fill out the table below, using 0 for false, and 1 for true.

 

 01
AND with 0
OR with 0
XOR with 0
AND with 1
OR with 1
XOR with 1

 

 
Переглянути це питання

Select all of the lines that contains errors in the provided code.

0%
100%
0%
100%
100%
0%
0%
0%
0%
0%
0%
100%
0%
Переглянути це питання

Select all of the instructions from the program above that are pseudoinstructions. (If none are psuedoinstructions, select the "none of the other options" option)

0%
100%
0%
0%
0%
Переглянути це питання

Given the following struct definitions of a linked-list based queue:

 

struct QueueNode

{

struct QueueNode

*next;

unsigned int

value;

};

struct Queue

{

struct QueueNode

*front;

struct QueueNode

*rear;

};

// <![CDATA[

hljs.highlightAll();

// ]]>

 

Task 1: Write an insert function to insert an item at the end of the queue. The function prototype has been provided for you below.

void insert(struct Queue* queue, unsigned int value);

 

Task 2: Write a serve function to serve (remove) an item (from the front) of the queue. The function prototype has been provided for you below.

int serve(struct Queue* queue);

 

Task 3: In the main function, write code that does the following:

  • Reads in a single string of letters and numbers (you can assume that the only letter will be an 's' character)
  • For each single

    character in the string:

    • If it is a numerical character, convert that character to an integer and insert it into the queue
    • If it is an 's', serve the next item in the queue and print that integer to the console, followed by a single space character

 

 

Notes:

  • You may also use whatever editor/test environment you like to write your solution.
  • Your code MUST be submitted as a .txt file below BEFORE the end of the test
  • Your code will be run against test cases and manually reviewed
  • You may wish to define additional functions as needed
  • You should use good programming practices

Your code MUST be submitted as a .txt file BEFORE the end of the test (copy and paste into a .txt file).

Переглянути це питання

Suppose we have the following program, running on a 64-bit computer:

#include<stdio.h>

#include<string.h>

typedef struct {

int id;

char name[52];

float salary;

} Employee;

void printEmployee(Employee e) {

printf("ID: %d\n", e.id);

printf("Name: %s\n", e.name);

printf("Salary: %.2f\n", e.salary);

}

int main() {

Employee e1;

int e1ID = 1;

e1.id = e1ID;

strcpy(e1.name, "John Doe");

float e1Sal = 50000.00;

e1.salary = 50000.00;

printEmployee(e1);

Employee* e1Ptr = &e1;

return 0;

}

 

Select the correct statement about the size of variables in the main function from the options below:

0%
0%
0%
0%
Переглянути це питання

Хочете миттєвий доступ до всіх перевірених відповідей на learning.monash.edu?

Отримайте необмежений доступ до відповідей на екзаменаційні питання - встановіть розширення Crowdly зараз!