代写CS3012 Translate Assembly Lang

2019-08-20  本文已影响0人  duizhishu

将C语言的FIFO queue用ASM重构。Part A: Global Variables and Separate CompilationA FIFO queue data structure can be implemented using an array, as shown in the following C program:123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136#include

#include #define QUEUESIZE 8#define MODMASK 0x7#define FALSE 0#define TRUE 1/* Function Prototypes */void enqueue(int value);int dequeue();int queueFull();int queueEmpty();void display();/* Global Variables */int queue[QUEUESIZE];int head = -1;int tail = -1;int main() int operation, value; do system(&"clear&"); printf(&"### Queue Operations ### &"); printf(&"Press 1 - Enqueue, 2 - Dequeue, 3 - Display, 4 - Exit &"); printf(&"Your option? &"); scanf(&"%d&", operation); switch (operation) case 1: printf(&" Enter the positive integer value to be enqueued: &"); scanf(&"%d&", value); enqueue(value); break; case 2: value = dequeue(); if (value != -1) printf(&" Dequeued value is %d &", value); break; case 3: display(); break; case 4: printf(&" Terminating program &"); exit(0); default: printf(&" Invalid option! Try again. &"); break; printf(&" Press the return key to continue . . . &"); getchar(); getchar(); while (operation != 4); return 0;void enqueue(int value) if (queueFull()) printf(&" Queue overflow! Cannot enqueue into a full queue. &"); return; if (queueEmpty()) head = tail = 0; else tail = ++tail MODMASK; queue[tail] = value;int dequeue() register int value; if (queueEmpty()) printf(&" Queue underflow! Cannot dequeue from an empty queue. &"); return (-1); value = queue[head]; if (head == tail) head = tail = -1; else head = ++head MODMASK; return value;int queueFull() if (((tail + 1) MODMASK) == head) return TRUE; else return FALSE;int queueEmpty() if (head == -1) return TRUE; else return FALSE;void display() register int i, j, count; if (queueEmpty()) printf(&" Empty queue &"); return; count = tail - head + 1; if (count <= 0) count += QUEUESIZE; printf(&" Current queue contents: &"); i = head; for (j = 0; j < count; j++) printf(&" %d&", queue[i]); if (i == head) printf(&" <-- head of queue&"); if (i == tail) printf(&" <-- tail of queue&"); printf(&" &"); i = ++i MODMASK; & Translate all functions except main() into ARMv8 assembly language, and put them into a separate assembly source code file called a5a.asm. These functions will be called from the main() function given above, which will be in its own C source code file called a5aMain.c. Also move the global variables into a5a.asm. Your assembly functions will call the printf() library routine. Be sure to handle the global variables and format strings in the appropriate way. Input will come from standard input. Run the program to show that it is working as expected, capturing its output using the script UNIX command, and name the output file script1.txt.Part B: External Pointer Arrays and Command-Line ArgumentsGiven the following declarations in C:1234char *month[] = &"January&", &"February&", &"March&", &"April&", &"May&", &"June&", &"July&", &"August&", &"September&", &"October&", &"November&", &"December&";char *season[] = “Winter”, “Spring”, “Summer”, “Fall”;& create an ARMv8 assembly language program to accept as command line arguments two strings representing a date in the format mm dd. Your program will print the name of month, the day (with the appropriate suffix), and the season for this date. For example:./a5b 12 25 December 25th is Winter Be sure to use the proper suffix for the day of the month. For example, one should distinguish the 11th from the 1st, 21st, and 31st. Your program should exit, printing this error message, if the user does not supply two command-line arguments:usage: a5b mm dd You will need to call atoi() to convert strings to numbers, and printf() to produce the output. Be sure to do range checking for the day and month. Assume that Winter ranges from December 21 to March 20, Spring from March 21 to June 20, Summer from June 21 to September 20, and Fall from September 21 to December 20. Name your source code file a5b.asm. Run your program three times with different input to illustrate that it works; capture the output using the script UNIX command. Name the output file script2.txt.New Skills need for this Assignment:Understanding and use of external variables in assemblySeparate compilationCalling assembly functions from main()Calling library functions from assembly routinesExternal arrays of pointersCommand line argumentsSubmit the following:Your source code and 2 scripts via electronic submission. Use the Assignment 5 Dropbox Folder in D2L to submit electronically. Your TA will assemble and run your programs to test them. Name your files a5aMain.c and a5a.asm for Part A, and a5b.asm for Part B, and the scripts as script1.txt and script2.txt.本团队核心人员组成主要包括BAT一线工程师,精通德英语!我们主要业务范围是代做编程大作业、课程设计等等。我们的方向领域:window编程 数值算法 AI人工智能 金融统计 计量分析 大数据 网络编程 WEB编程 通讯编程 游戏编程多媒体linux 外挂编程 程序API图像处理 嵌入式/单片机 数据库编程 控制台 进程与线程 网络安全 汇编语言 硬件编程 软件设计 工程标准规等。其中代写编程、代写程序、代写留学生程序作业语言或工具包括但不限于以下范围:C/C++/C#代写Java代写IT代写Python代写辅导编程作业Matlab代写Haskell代写Processing代写Linux环境搭建Rust代写Data Structure Assginment 数据结构代写MIPS代写Machine Learning 作业 代写Oracle/SQL/PostgreSQL/Pig 数据库代写/代做/辅导Web开发、网站开发、网站作业ASP.NET网站开发Finance Insurace Statistics统计、回归、迭代Prolog代写Computer Computational method代做因为专业,所以值得信赖。如有需要,请加QQ:99515681 或邮箱:99515681@qq.com 微信:codehelp QQ:99515681 或邮箱:99515681@qq.com 微信:codehelp

上一篇下一篇

猜你喜欢

热点阅读