Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

Commit

Permalink
Adding additional assignment materials
Browse files Browse the repository at this point in the history
  • Loading branch information
dluman committed Sep 28, 2023
1 parent c1d45e6 commit 802a806
Show file tree
Hide file tree
Showing 4 changed files with 133 additions and 0 deletions.
42 changes: 42 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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_.
Expand Down
13 changes: 13 additions & 0 deletions docs/hack.md
Original file line number Diff line number Diff line change
@@ -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`
30 changes: 30 additions & 0 deletions docs/report.md
Original file line number Diff line number Diff line change
@@ -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`
48 changes: 48 additions & 0 deletions gatorgrade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 802a806

Please sign in to comment.