1. September 28, 2015 In-class Activity

CS240: Fall 2015, Blank

For Wednesday, read chapter 7 and come prepared for a classroom activity.

Today, you will be assigned a partner. You will work in pairs on one computer, switching "drivers" every 15 minutes.

1.1 Draw a flow chart for Example 1

In [1]:
%%dot

digraph flowchart {
  rankdir=TB
  fontname=Helvetica
  node [peripheries=0, 
        style=filled, 
        fontname=Helvetica, 
        fixedsize=true, 
        width=1.8, 
        height=0.8]
  edge [fontname=Helvetica, 
        fontsize=12, 
        fontcolor=blue, 
        labeldistance=1.8]

  init  [shape=box, label="R0 \<- 0\nR1 \<- #-5"]
  load  [shape=box, label="R2 \<- R1"]
  test  [shape=diamond, label="BRz"]
  incr      [shape=box, label="R1 \<- R1 + 1"]
  complete  [shape=box, height=0.8, label="HALT"]

  init -> load
  load -> test     
  test -> incr     [headlabel="no"]
  incr -> load    
  test -> complete [headlabel="yes"]
  
  { rank=same; incr test }
}
flowchart init R0 <- 0 R1 <- #-5 load R2 <- R1 init->load test BRz load->test incr R1 <- R1 + 1 test->incr no complete HALT test->complete yes incr->load

1.2 Fix Example 4

1.3 Write a program to put the numbers 1 through 1,000 into memory starting at x3100.

1.4 Write a program to add up those numbers.

1.5 Write a program to count the number of 1 bits in a memory location

1.6 Write a program to count the number of 1 bits in itself

If you finish the above, do Exercises 6.7, 6.14, 6.19