Complete the associated exercises before attempting the assignment
Aim
This assignment provides some limited experience with assembly language programming.
ObjectivesOn completion of this assignment and its associated exercise, you will be able to: Explain how assembly language programs are prepared using a two pass assembler, are loaded and executed Explain the operation of a simple assembler and the use of conventional assembly language directives for setting origins, defining variables, strings, and blocks of initialized data Explain how input and output can be realised using wait loops and interrupt mechanisms Explain op-codes and addressing modes Use assembly language to implement simple programming constructs such as indexed array accessing, use of pointers, simple subroutine calls, and use of a primitive operating system implemented with trap (svc) system call instructions.TaskYou are to implement a simple data processing application in PDP11 assembly language, making use of the supplied primitive operating system to handle I/O.A simple program for summary statisticsThe program is to produce some summary statistics for an array of data. The outline of a C version (which you should implement in full first) is as follows:The program determines the mean, mode of the data in an array, and also identifies the largest and smallest value.You should be able to work out the code for the functions mean() and maxandmin(). Code for the mode() function could be as follows:The data for the array are to be created using a supplied datagen program.Example data your values will differ:An executable version of the datagen program for the Ubuntu computers in the lab can be downloaded from http://www.uow.edu.au/~nabg/131/Resources/datagen (after download,change the permission to make the file executable). This program will generate apersonalized set of data values; it will generate the same set of values each time you run the program, and can output the data in a form for pasting into C code or into your assembly language program.Output for C:Output for assembly language (same values, just reformatted and printed in octal):Assembly language implementationAs in the exercise, start your assembly language version by taking the code of the example os2btrap.txt and cutting out the example application code to leave just the operating system andlibrary components.The operating system offers five system functions that are invoked via traps (supervisor calls):Remove the application code; leave the operating system and librarycodeSupervisor calls: Exit:Terminate execution of application program, return to OS (which then halts). Readline:This trap takes one argument in the following memory location; this is the addressof a buffer (character array) where input characters will be stored. The implementation of the supervisor call reads characters from the keyboard (underinterrupt control) until a newline character has been read. All characters read arestore in the input buffer. Writeline:This trap takes one argument in the following memory location; this is the addressof a buffer (character array) with a generated message. The implementation of the supervisor call writes the content of the array to the tty. Atoi:(Not used in this application). This trap takes one argument; this is the address of a buffer that is supposed to contain the ASCII representation of an integer. Theinteger value will be returned. Itoa:This trap takes two arguments; the first is the address of a variable containing aninteger value, the second is the address of a buffer where an ASCII string should be generated to represent that value (in decimal).Start by implementing an application that invokes stub functions that output fixed values rather than actual data:These stub functions simply print messages and output a fixed value. A stub implementation of mean() is shown below; the mode() and maxandmin() stub functions are similar:You will need message strings and some variables:This stubbed out version of the application should run:You can then add the actual data to your code:Your real task is implementing the functions mean(), mode(), and maxandmin(), using simple assembly language constructs for array access and counting loops.Your completed assembly language program should produce the same output as your C version:Assignment reportYou do not submit your code files!You are marked on a report that you write. This report presents details of your assemblylanguage program. You must include the assembly language code for the three functions(screen shots can be used). For each function, explain how you have encoded the loopconstructs in assembly language and how you are accessing the array elements.SubmissionPrepare your report and convert to PDF format as the file A2.pdf.Submission is done electronically via a program called turnin that runs on banshee themain CS undergraduate machine. You must first transfer your A2.pdf file to your homedirectory on banshee (this is different from the home directory that you access on the Linuxmachines). You can transfer the file using a SSH file-transfer program. The Ubuntu OSallows you to open a file-browser connected to your banshee home directory and you cansimply drag your A2.pdf file across using the visual file browser.For CSCI131, assignments are submitted electronically via the turnin system. For thisassignment you submit your assignment via the command:turnin -c csci131 -a 2 A2.pdfLate submissions would be submitted as:turnin -c csci131 -a 2late A2.pdfThe program turnin only works when you are logged in to the main banshee undergraduateserver machine. From an Ubuntu workstation in the lab, you must open a terminal session onthe local machine, and then login to banshee via ssh and run the turnin program.MarkingThe assignment is worth 8 marks total. Appearance and structure of report: 1 mark Evidence for correct operation (screenshots from both C and assembly language versions): 1 mark Code and explanations of each of the three functions: 6 marks total
Reviews
There are no reviews yet.