Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write ARM assembly implementations for all of the functions below. The functions must be present in a single .s file.Your function/procedure names must be identical

Write ARM assembly implementations for all of the functions below. The functions must be present in a single .s file.Your function/procedure names must be identical to that presented below, as your implementations will be tested with generic C code. All of your functions must return a value such that the program will run to completion with no segmentation faults. If a function cannot be successfully implemented, it still must return a valid value: no function may be omitted. Attempting to omit a function will result in a compile error.

#include #include #include #include

extern uint64_t add64(uint32_t x, uint32_t y); // returns x + y extern uint64_t sub64(uint64_t x, uint64_t y); // returns x - y extern uint8_t minU8(uint8_t x, uint8_t y); // returns the minimum of x, y extern int16_t minS16(int16_t x, int16_t y); // returns the minimum of x, y extern bool isLessThanU8(uint8_t x, uint8_t y); // returns 1 if x < y, 0 else extern bool isLessThanS16(int16_t x, int16_t y); // returns 1 if x < y, 0 else extern uint16_t shiftLeftU16 (uint16_t x, uint16_t p); // returns x << p = x * 2p for p = 0 .. 31 extern uint32_t shiftU32(uint32_t x, int32_t p); // return x * 2p for p = -31 .. 31 extern int8_t shiftS8(int8_t x, int8_t p); // return x * 2p for p = -31 .. 31 extern bool isEqualU8(uint8_t x, uint8_t y); // returns 1 if x = y, 0 if x != y extern bool isEqualS16(int16_t x, int16_t y); // returns 1 if x = y, 0 if x != y

int main(void) { uint32_t a = 4000000000; uint32_t b = 3000000000; printf("Question 1, add64: Correct answer = %lld ", 7000000000); printf("Question 1, add64: Student answer = %lld ", add64(a, b)); uint64_t c = 9000000000; uint64_t d = 8000000000; printf("Question 2, sub64: Correct answer = %lld ", c - d); printf("Question 2, sub64: Student answer = %lld ", sub64(c, d)); uint8_t e = 254; uint8_t f = 4; printf("Question 3, minU8, test 1: Correct answer = %hhu ", f); printf("Question 3, minU8, test 1: Student answer = %hu ", minU8(e, f)); printf("Question 3, minU8, test 2: Correct answer = %hhu ", f); printf("Question 3, minU8, test 2: Student answer = %hu ", minU8(f, e)); int16_t g = -8; int16_t h = 8; printf("Question 4, minS16, test 1: Correct answer = %d ", g); printf("Question 4, minS16, test 1: Student answer = %d ", minS16(g, h)); printf("Question 4, minS16, test 2: Correct answer = %d ", g); printf("Question 4, minS16, test 2: Student answer = %d ", minS16(h, g)); uint8_t i = 32; uint8_t j = 16; printf("Question 5, isLessThanU8, test 1: Correct answer = %d ", 0); printf("Question 5, isLessThanU8, test 1: Student answer = %d ", isLessThanU8(i, j)); printf("Question 5, isLessThanU8, test 2: Correct answer = %d ", 1); printf("Question 5, isLessThanU8, test 2: Student answer = %d ", isLessThanU8(j, i)); int16_t k = -3; int16_t l = 2; printf("Question 6, isLessThanS16, test 1: Correct answer = %d ", 1); printf("Question 6, isLessThanS16, test 1: Student answer = %d ", isLessThanS16(k, l)); printf("Question 6, isLessThanS16, test 2: Correct answer = %d ", 0); printf("Question 6, isLessThanS16, test 2: Student answer = %d ", isLessThanS16(l, k)); uint16_t m = 3; uint16_t n = 4; printf("Question 7, shiftLeftU16: Correct answer = %hu ", 48); printf("Question 7, shiftLeftU16: Student answer = %hu ", shiftLeftU16(m, n));

uint32_t m_a = 8; uint32_t n_a = 12; printf("Question 8, shiftU32, test 1: Correct answer = %u ", 32768); printf("Question 8, shiftU32, test 1: Student answer = %u ", shiftU32(m_a, n_a)); printf("Question 8, shiftU32, test 2: Correct answer = %u ", 2); printf("Question 8, shiftU32, test 2: Student answer = %u ", shiftU32(m_a, -2)); int8_t o = -4; int8_t p = 4; printf("Question 9, shiftS8, test 1: Correct answer = %hhd ", -64); printf("Question 9, shiftS8, test 1: Student answer = %hhd ", shiftS8(o, p)); printf("Question 9, shiftS8, test 2: Correct answer = %hhd ", -2); printf("Question 9, shiftS8, test 2: Student answer = %hhd ", shiftS8(o, -1)); uint8_t q = 32; uint8_t r = 16; printf("Question 10, isEqualU8, test 1: Correct answer = %d ", 0); printf("Question 10, isEqualU8, test 1: Student answer = %d ", isEqualU8(q, r)); printf("Question 10, isEqualU8, test 2: Correct answer = %d ", 1); printf("Question 10, isEqualU8, test 2: Student answer = %d ", isEqualU8(q, q)); int16_t s = 32; int16_t t = 16; printf("Question 11, isEqualS16, test 1: Correct answer = %d ", 0); printf("Question 11, isEqualS16, test 1: Student answer = %d ", isEqualS16(s, t)); printf("Question 11, isEqualS16, test 2: Correct answer = %d ", 1); printf("Question 11, isEqualS16, test 2: Student answer = %d ", isEqualS16(s, s)); return EXIT_SUCCESS; }

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

Fundamentals Of Database System

Authors: Elmasri Ramez And Navathe Shamkant

7th Edition

978-9332582705

More Books

Students also viewed these Databases questions

Question

What are the objectives of Human resource planning ?

Answered: 1 week ago

Question

Explain the process of Human Resource Planning.

Answered: 1 week ago