C Java Tutor 客服在線

代做國外C C++ Java程序 QQ: 1067665373 Email:cjtutor@foxmail.com

« 代寫True Basic 代做mae5 Cartoons and Sketches »

代寫MIPS LC3 X86 Y86 Systems and Architecture (AE1SYS) Assembly Programming

Systems and Architecture (AE1SYS) Assembly Programming 
1. Write a program in MIPS32 assembly language which reads a number
n from
the console, and prints out the factorial of
n:
n! = n· (n - 1)· (n - 2) · · · 2· 1:
The procedure in Java, given n, might look like:
int f = 1;
for(int i = 1; i <= n; i++){
f = f * i;
}
(15 marks)
2. Implement a program which prompts user two integers inputs
x, y from the
console and calculate the following expression in signed 32-bit arithmetic:
x2 + 9y2 + 6xy - 6x - 18y + 9
Note that you are NOT allowed to use pseudo-instructions with overflow
checking for the calculation (i.e. you can not use
mulo). If an overflow occurs
during any step of the calculation, you should print an error message instead,
and stop the program.
Hint: You could simplify the expression before calculation. Please remember
to test your program with a range of different inputs, e.g.
x = 2; y = 3;
x = -3; y = 4; x = 1 000; y = 150 000. . .
(25 marks)
3. Implement the following specification of the
strchr function which, given an
ASCII character code and the starting address of a string, returns the offset
of the first occurrence of the character in the string, or
-1 if the character
cannot be found:
1

int strchr(char needle, char[] haystack){
for(int i = 0; haystack[i] != NUL; i++)
if(haystack[i] == needle)
return i;
return -1;
}
void main(void){
int offset;
char haystack[256];
char needle[2];
haystack <- read_string; // $a0 == haystack; $a1 == 256
needle <- read_string; // $a0 == needle; $a1 == 2
offset = strchr(needle[0], haystack);
if(offset >= 0)
printf("found at offset: %d", offset);
else
printf("not found");
}
To declare a char buffer[n] of n bytes, use the .space n directive in the
.data segment.
Please implement the main function above as well. Insert a comment in your
program to illustrate how you would use
strchr to calculate the length of a
string.
(25 marks)
4. In this exercise you will use the Newton-Raphson method to calculate the
positive square root of a number n 0. In summary, the method is:
x0 ≈ pn
x
i+1 =
1 2
xi + x n i 
with pn = limi!1 xi.
Since we are working with a finite representation of floating point numbers,
we can stop when the difference between
xi and xi+1 is small enough. The
following pseudo-C program illustrates the Newton-Raphson method:
// input a floating point number n
float x0 = n, x1 = 0.5 * n;
while(abs(x0 - x1) > 1e-6):
x0 = x1;
x1 = 0.5 * (x0 + n / x0);
// The square-root of n is approximately x1
2
Implement a MIPS assembly program which implements the above method
for single-precision (32-bit) floating point numbers, without using the
sqrt.s
instruction.
(35 marks)
3
  

  • 相關文章:

發表評論:

澳大利亚代写assignment,代写论文,essay代写推荐-cs小码神代写◎歡迎參與討論,請在這里發表您的看法、交流您的觀點。

最新評論及回復

最近發表

Powered By

Copyright 代寫C.

在線客服

售前咨詢
售后咨詢
微信號
Essay_Cheery
微信
悉尼assignment代写,北美作业代写,代写毕业论文-100%原创 北美代写,Homework代写,Essay代寫-准时✔️高质✔最【靠谱】 墨尔本assignment代写,代写毕业论文,paper代写-51作业君 北美代写,程序代做,程序代写,java代写,python代写,c++代写,c代写 英国代写paper,python代写,Report代写,编程代写-程序代写网 北美代写essay,程序代写,Java代写代做,Java代考-焦点论文 澳大利亚essay代写,编程代写,代码代写,程序代写-三洋编程 加拿大essay代写|程序代写代做||Python代写|Matlab代写-Meeloun 澳大利亚代写,代写essay,代写毕业论文,留学生代写-小马代写 日本代写,北美作业代写,新加坡代写,essay代写-无时差服务