Fill This Form To Receive Instant Help
Homework answers / question archive / F28HS Coursework 2 - Assembly F28HS Hardware-Software Interface Coursework 2: Character Frequency Count in ARM Assembly Overview You are to write a program in the ARM assembly language to count and display how often each character occurs in the chorus of the Robert Burns poem, My Heart’s in the Highlands
F28HS Coursework 2 - Assembly
F28HS Hardware-Software Interface Coursework 2: Character Frequency Count in ARM Assembly |
|
You are to write a program in the ARM assembly language to count and display how often each character occurs in the chorus of the Robert Burns poem, My Heart’s in the Highlands.
A sample of the character count for this Robert Burns poem is:
0000000001 .
0000000001 ;
0000000001 C
0000000003 H
0000000001 I
0000000003 M
0000000011 a
0000000001 c
0000000007 d
0000000020 e
0000000001 f
0000000007 g
0000000017 h
0000000011 i
0000000006 l
0000000001 m
0000000011 n
This coursework is individual work. It is not group work, and you are assessed individually. Therefore, the code and report you submit for this lab must be entirely your own. You must not share your code with other students, and you must not copy code solutions from others. The university plagiarism policy[1] is clear:
“Plagiarism involves the act of taking the ideas, writings or inventions of another person and using these as if they were one’s own, whether intentionally or not.” Definition 2.1.
We run plagiarism software against all source code submissions, which identifies any code similarity across multiple submissions. The disciplinary action for plagiarism is an award of an F grade (fail) for the course. Serious instances of plagiarism will result in Compulsory Withdrawal from the university.
The coursework requires you to write and test ARM Assembly code. Your technology options are:
CPUlater An online ARM CPU simulator (Questions 1 and 2).
Cross compiler and ARM emulator A command line based approach using GCC’s cross compiler and the QEMU ARM emulator (Question 3, and also Questions 1 and 2 if you wish).
We have produced videos that show how to test and debug your ARM Assembly code:
Linux users install GCC’s cross compiler; install QEMU; log in remotely to university’s servers with ssh; use the CPUlator for debugging Questions 1 and 2.
Mac OSX users install GCC’s cross compiler; install QEMU; log in remotely to university’s servers with ssh; use the CPUlator for debugging Questions 1 and 2.
Windows users log in remotely to university’s servers with Putty; use the CPUlator for debugging Ques-
tions 1 and 2.
You can discussion ideas and ask questions about how to implement this coursework on Discourse: https://discourse.macs.hw.ac.uk/c/F28HS/51
As with coursework 1, you can also ask for help directly next to your partially written code on GitLab. A video tutorial is here.
This coursework involves writing a program in the ARM assembly language to count and display how often each character occurs in a string.
You are provided starter files, which is a template for your solution. Fork this project:
Thenhttps://gitlab-student.macs.hw.ac.uk/f28hs-2020-21/f28hs-2020-21-students/f28hs-2020-21-cwk2-asclone your fork on your own computer. m If you are using a terminal window, clone your fork (replacing username) with: git clone git@gitlab-student.macs.hw.ac.uk:username/f28hs-2020-21-cwk2-asm.git
Make sure that you can compile the starter code, or at least compile it with the web based CPUlater, before you start making changes.
As you progress through the coursework, push your work to GitLab. This will ensure that you don’t lose your work, and also enables you to ask for help directly next to your code on the GitLab website. Remember to create small incremental improvements with git commits, and refer to the coursework question (listed below) that the commit is working on. When you push your commits, GitLab will check that your files can be compiled.
Question 1 and 2 can be debugged using CPUlator. You should comment out any software interrupt instructions (SWI) before simulating it in CPUlator. Question 3 requires reading from a text file so can’t be tested with CPUlator. Instead, for Question 3 remotely log into the university’s Linux servers and run it in a terminal window (video tutorial above).
To submit coursework 2, push your code to your fork of f28hs-2020-21-cwk2-asm, to the MACS GitLab Student server.
Your project on GitLab should include: freq-hard-coded.s Your implementation of character frequency count for a hard-coded string ( Questions 1 and 2).
freq.s Your implementation of character frequency count for the contents of a file (Question 3). Report.md Your report describing your implementation.
For the last question for this coursework, you are to write a report about your implementation. To do this, in Report.md write about:
Use Markdown syntax in the Report.md file. GitLab will render your markdown syntax nicely. For instruction on markdown syntax, follow: https://www.markdownguide.org/basic-syntax
$ ./freq-hard-coded
0000000032
0000000003 '
0000000006 , 0000000002 etc ...
<count> <space> <character> <newline character> e.g.
0000000017 h
tion about ASCII characters that do not appear in the input string. E.g. do not print this line:
0000000000 z
In your ARM Assembly code, add documentation next to the code that adds this functionality to make it clear where your code is for this Question 2.
./freq RobertBurns.txt
0000000001
0000000032
0000000003 '
0000000006 , 0000000002 etc ...
Explain your algorithms, and your use of memory and registers to support those algorithms.
Describe the structural layout in your freq-hard-coded.s file. If you attempted Question 3, also describe the structural layout for adding the functionality of parsing file content into the frequency table.
Important Document your Assembly code with comments. To ensure you get all the marks you deserve for your efforts, in those comments refer to the question number that the code beneath each comment is implementing e.g. @ closes the file (Q3).
Question: |
1 |
2 |
3 |
4 |
Total |
Points: |
10 |
2 |
4 |
4 |
20 |
We recommend you base your algorithm design and implementation on the following procedure:
0000000017 h
It is fine if you wish to deviate from this algorithm. If you do, say why in your Report.md file, e.g. if you have a more efficient algorithm (either shorter runtime or using less memory).
There are 128 characters in the ASCII table, that may appear in the string. You could approach designing and implementing your algorithm by creating a continuous region in memory for the character counting. We’ll refer to this as the “frequency table”. That memory region you could split into 4 bytes, since storing an integer (to count each character) requires 4 bytes. For example if the memory cell at address 0 x7efff7e 0 is used to keep a count of the ’a’ character, then the memory cell for counting occurrences of the ’b’ character would be 0x7efff7e4.
The next page visualises the complete workflow.
Your program is likely going to need:
Hints
LDR Ri, = variable
LDR Rj, [ Ri ]
@ do stuff to value Rj ... STR Rj, [ Ri ]
This is the only way to communicate data between system calls and your ARM Assembly code ( e.g. read and write system functions), see Hint8!.
Syllabus
Learning outcomes
0000000001
0000000032
0000000003 '
0000000006 ,
0000000002 0000000001 .
0000000001 ;
0000000001 C
0000000003 H
0000000001 I
0000000003 M
0000000011 a
0000000001 c
0000000007 d
0000000020 e
0000000001 f
0000000007 g
0000000017 h
0000000011 i
0000000006 l
0000000001 m
0000000011 n
0000000005 o
0000000010 r
0000000009 s
0000000011 t
0000000001 v
0000000003 w
0000000004 y
Here is the memory content for the “coooow” string (the test string ASCII)
Here is the memory content for the Robert Burns poem (the robert burns ASCII):
You can see this for yourself by loading in the freq-hard-coded.s file into CPUlator.
For the two phases of the recommended algorithm, below is a list of the ARM Assembly programming lectures 1-5 and their corresponding GitLab projects, to help you complete each task.
Learning Material for algorithm phase 1 • Control flow with comparison and branching – Lecture 1: comparison, flags, branches.
– Lecture 4: sub-routines, parameter passing.
Learning Material for algorithm phase 2