2.9 KiB
2.9 KiB
Analog programming
Two exercises to activate the body and the mind
Common goal of both exercises is to sort a deck of tarot cards by value
Before starting, make yourself acquainted with the meaning and the power of the tarot cards. Carefully read this booklet
First experiment: human sorting
Setup
- 1 volunteer to keep the time spent sorting
- each person picks up a tarot card from the randomly shuffled deck on the table
- moving around and speaking is allowed until the tarot cards are displayed sorted on the table
Second experiment: machine sorting
Setup
We will keep some timings:
- time spent programming and compiling
- time spent executing the program
Programming in groups
Divide in groups and write pseudo-code on paper to sort a randomly shuffled deck of tarot cards.
Rules
- You have to "compile" the program in our special Assembly language, which consists of the following instructions:
fetch(ADDR, REG)
: fetch a value from the memory addressADDR
and store it into registerREG
push(ADDR, REG)
: push a value from the registerREG
into the memory addressADDR
sort(REG_X, REG_Y)
: sort the values inREG_X
andREG_Y
so that the value inREG_X
is bigger or equal than the value inREG_Y
stop
: stop the execution of the program
- "compile" in this context means translating the pseudo-code in a long sequence of the four instructions above
- note that if you use loops, you have to "unroll" them when you compile the program
- you are going to be using the hardware described below to execute the compiled program
Present your solution to the general assembly and choose one implementation to try out!
Hardware setup
- 4 empty seats will be the 4 CPU registers:
REG0
,REG1
,REG2
,REG3
- distribute memory addresses (in hexadecimal) to all the remaining seats which are occupied by a participant
- distribute the shuffled cards to every participant: they represent values and are hold by participants
- A tutor will be the CPU. A CPU can only execute one of the above instructions at a time
- Everyone who is not a CPU is data:
- you'll have an address when you are stored in memory
- you'll have a value (the value of the tarot card you hold on your hand): don't let it go!
- when
fetch
-ed by the CPU, you'll take the PCI-bus and go sit on the corresponding register, taking the card with you - when
push
-ed by the CPU, you'll take the PCI-bus and go sit on the corresponding memory address, taking the card with you - when
sort
-ed, move to the appropriate register, according the semantics of thesort
instruction defined above
Run the compiled code!
The CPUs will run the program by saying the instructions out loud and everyone else will move around accordingly. You can also literally "run" if you want to speed up the process a bit.
Do not forget to start the timing!