teaching machines

CS 352 Lecture 30 – Mouse

Dear students, Today we’re going to do something a little different. I don’t think me lecturing is the best way for you to learn, but I don’t think there’s enough time in a semester to do much better. I am always looking for ways to step back and let you more actively participate. Today, we […]

CS 352 Lecture 29 – Functions Cont’d

Dear students, We try as hard as we can to use registers for our calculations, but we cannot always avoid going to memory. Today we will look at how variables inside functions are allocated, accessed, and freed through a few more examples. Unlike registers and globals, stack and heap variables don’t have names. We must […]

CS 352 Lecture 28 – Functions

Dear students, Today we look at how functional abstractions are built atop rudimentary assembly instructions. The magic to make functions happen is really just two ideas: a register (lr), which places a bookmark for our program counter so we know where to return to after the function finishes a standard protocol for passing parameters and […]

CS 352 Lecture 27 – If * 3

Dear students, Let’s do another Program This: Translate the following code to ARM assembly: if n >= 0 && n <= 9 print ‘digit’ A straightforward implementation might take this approach: mov r1, #0 mov r2, #0 // Let’s assume n is in r0. cmp r0, #0 movgt r1, #1 cmp r0, #9 movlt r2, […]

CS 352 Lecture 26 – If++

Dear students, Let’s start with a Program This! Translate this high-level pseudocode into ARM assembly: if n == 0 print ‘R’ else if n == 1 print ‘Y’ else if n == 2 print ‘G’ A straightforward translation of this might look something like this: // Let’s assume n is in r0. cmp r0, #0 […]

CS 352 Lecture 25 – Branching

Dear students, We ended our discussion of ARM assembly last time wanting to tell the user if they answered a math problem correctly or incorrectly. To support this, we needed to branch between two different sequences of code. We’ve seen unconditional branches that jump our program counter to some other labeled section, but what we […]

CS 352 Lecture 24 – Memory and Branching

Dear students, Sometimes in the middle of a semester, we forget why we are here. Let’s step back a moment and check out what the ACM/IEEE Computer Science 2013 Curriculum has to say about computer architecture. Are we hitting upon any of the expected ideas? Let’s then write some programs that will grow our understanding […]

CS 352 Lecture 23 – Hello ARM, For Real

Dear students, Let’s have a look at some ARM instructions. We’ll start with the simplest ones: add a, b, c // a = b + c sub a, b, c // a = b – c Identifiers a, b, and c are just placeholders, not legal operands. In their place, we can either have registers […]