From 802a8060cab365555e63244cdad39917a11953fc Mon Sep 17 00:00:00 2001 From: dluman Date: Thu, 28 Sep 2023 09:39:35 -0400 Subject: [PATCH] Adding additional assignment materials --- README.md | 42 ++++++++++++++++++++++++++++++++++++++++++ docs/hack.md | 13 +++++++++++++ docs/report.md | 30 ++++++++++++++++++++++++++++++ gatorgrade.yml | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 133 insertions(+) create mode 100644 docs/hack.md create mode 100644 docs/report.md diff --git a/README.md b/README.md index 7f6e626..a6519c5 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,48 @@ This program will: * use the `print` and `loop` labels to designate relevant subroutines * integrate the `CMP` and new `Bxx` instructions +### Lab: Polarity Checker + +Complete this work in [polarity_checker/program.S](polarity_checker/program.S) + +After having mined many tons of rocks, we noticed that they have various _polarities_ (that is some are negatively charged and others are positive). Both kinds of rocks are useful, be we need to separate them. The point of this program is to: + +* print the number of positive values accompanied by the _highest positive_ value +* print the number of negative values accompanied by the _highest negative_ value + +### Assignment "Hacks" + +See the `Suggestion` below to challenge yourself to implement a Hack. As always, you are allowed to develop +your own Hack to satisfy this stretch goal. Place the code for the Hack inline with the code in the corresponding +file. + +In order to recieve credit for the Hack, you must fill out the [hack.md](docs/hack.md) file located in the +`docs` folder. + +#### `polarity_checker` + +It seems like there are a lot of instructions in `polarity_checker`. Can "bum" the program in _fewer_ lines? + +##### A brief history of "bumming" + +From the ubiquitous [jargon file](http://www.jargon.net/jargonfile/b/bum.html): + +> bum 1. /vt./ To make highly efficient, either in time or space, often at the expense of clarity. "I managed to bum three more instructions out of that code." "I spent half the night bumming the interrupt code." In 1996, this term and the practice it describes are semi-obsolete. In elder days, John McCarthy (inventor of LISP) used to compare some efficiency-obsessed hackers among his students to "ski bums"; thus, optimization became "program bumming", and eventually just "bumming". 2. To squeeze out excess; to remove something in order to improve whatever it was removed from (without changing function; this distinguishes the process from a featurectomy). 3. /n./ A small change to an algorithm, program, or hardware device to make it more efficient. "This hardware bum makes the jump instruction faster." Usage: now uncommon, largely superseded by /v./ tune (and /n./ tweak, hack), though none of these exactly capture sense. + +The tradition of "bumming" code is an old and well-loved test of a coder's ability to not only demonstrate cleverness, but to be _the best_. Unofficial competitions used to crown programs that were the most "bummed" as the canonical versions, even if just saving a few bytes. Good code bums were celebrated figures in the small communities rising up around computers. + +#### `processor` + +Having a processor that can do arrays seems pretty neat. But, how far can we push this thing? Let's find out how it changes our approach. + +Replace the `arr` entry in the `.data` section with the following line: + +```asm +.arr: .word 710206984, 2264095319, 2199662663, 360294422 +``` + +This change _seems_ small, but it means a great deal in terms of how we explore our saved memory. Can you make the `processor` use these numbers? The first thing you need to figure out about them: what makes them different than the one we started with (the `.hword` ones). + ### Changes to files in `.vscode` Based on your system setup (refer to your `hello-blinky` assignment), you will need switch out the `.vscode` folder in each exercise with the _last working copy_. diff --git a/docs/hack.md b/docs/hack.md new file mode 100644 index 0000000..4d44d19 --- /dev/null +++ b/docs/hack.md @@ -0,0 +1,13 @@ +# Ore Processing: Hack documentation + +## Describe the Hack you discovered. + +`TODO` + +## What steps did you take to introduce the conditions supporting the Hack? + +`TODO` + +## What is the potential knowledge value of the Hack? + +`TODO` \ No newline at end of file diff --git a/docs/report.md b/docs/report.md new file mode 100644 index 0000000..8230e7b --- /dev/null +++ b/docs/report.md @@ -0,0 +1,30 @@ +# Ore Processing: General report + +This week's work introduced: + +* how binary representations influence assembly-level instructions +* use of the xPSR register to determine how instructions "branch" and when to implement program logic + +Respond to the following prompts about the programs illustrating these concepts. + +## `math_test` required you to evalute numbers for their bit and byte size. Speculate: why do you think these quantites matter? + +`TODO` + +## `processor` and the `polarity_checker` use two different number sizes. Name and describe each. + +`TODO` + +`TODO` + +## Discuss branching instructions and how they work (be sure to include discussion of the `xPSR` register). + +`TODO` + +## `polarity_checker` likely required many more branches than you originally planned. Why are so many branches necessary for the program logic? + +`TODO` + +## `polarity_checker` also used a new instruction -- `LDRSB`. What is this instruction, and what does it do? Why is that significant? + +`TODO` \ No newline at end of file diff --git a/gatorgrade.yml b/gatorgrade.yml index 842f49e..e0c744a 100644 --- a/gatorgrade.yml +++ b/gatorgrade.yml @@ -245,4 +245,52 @@ options: regex: '[bl|BL](\s|\t)+printf' count: 1 + exact: true +- polarity_checker/program.S: + - description: polarity_checker/program.S uses correct B.. insructions to branch after CMP + category: ARMv6 Assembly + check: MatchFileRegex + options: + regex: '[b|B][GT|gt|LT|lt|GE|ge](\s|\t)+[a-zA-Z_]+' + count: 3 + exact: false +- polarity_checker/program.S: + - description: polarity_checker/program.S loads signed bytes from byte array + category: ARMv6 Assembly + check: MatchFileRegex + options: + regex: '[LDRSB|ldrsb](\s|\t)+[r|R][0-7],(\s)?\[[R|r][0-7],(\s)+[R|r][0-7]\]' + count: 1 + exact: true +- polarity_checker/program.S: + - description: polarity_checker/program.S loads the byte array from memory + category: ARMv6 Assembly + check: MatchFileRegex + options: + regex: '[ldr|LDR](\s|\t)+[r|R][0-7],(\s)?=polarities' + count: 1 + exact: true +- polarity_checker/program.S: + - description: polarity_checker/program.S uses at least three labels + category: ARMv6 Assembly + check: MatchFileRegex + options: + regex: '[a-zA-Z_]+:\n' + count: 3 + exact: false +- polarity_checker/program.S: + - description: polarity_checker/program.S uses at least one unconditional branch instruction + category: ARMv6 Assembly + check: MatchFileRegex + options: + regex: '[b|B](\s|\t)+[a-zA-Z_]' + count: 1 + exact: false +- docs/report.md: + - description: docs/report.md answers all questions + category: Documentation + check: MatchFileFragment + options: + fragment: "TODO" + count: 0 exact: true \ No newline at end of file