A Simple but Realistic Assembly Language for a
A Simple but Realistic Assembly Language for a Course in Computer Organization Eric Larson Moon Ok Kim Seattle University October 25, 2008 1
Problem l A few years ago we had two computer hardware courses: m Assembly Language Programming m Computer Organization l Now we only have one course that combines the two courses. l Result: Too much material to cover in one course. 2
Solution l Use a simple, yet realistic, assembly language (ANNA) throughout the course. l Focus on key concepts of assembly language programming. l Does not burden students with the complexities of large instruction sets. l ANNA can be used in illustrating the datapath and pipelining units. 3
Outline l l Background about the course ANNA assembly language and tools How ANNA was used in the course Feedback and Observations 4
Computer Organization Course l 5 credit (quarter) sophomore level class m requirement for CS majors l Main topics: m m m Data representation Digital logic Assembly language programming Datapath and control Memory hierarchy l Material from other classes: m OS: virtual memory, some I/O m Discrete math: Boolean algebra l Taught using ANNA three times 5
Assembly Language Concepts Key concepts in assembly language in our course: l Registers and memory l Conditional branches and jumps l Translating high-level languages constructs into assembly: m if-else statements m loops m procedure calls m arrays and pointers l Most importantly – experience actually writing assembly programs 6
ANNA Assembly Language v 1 l Memory is word addressable, words are 16 bits. l Memory is shared by instructions or data. l Data in memory / registers is either an integer or an address. m Can actually store anything – no instruction support for other data types. l Load / store architecture l 16 general purpose registers, register r 0 is 0. m Wise to introduce a calling convention that reserves a register for the stack pointer. l 16 instructions (next slide). 7
ANNA Instruction Set v 1 Opcode Operands Description add sub lli lui and or not shf lw sw in out bez bgz jalr halt Rd Rs 1 Rs 2 Rd Imm 8 Rd Rs 1 Rs 2 Rd Rs 1 Imm 4 Rd Rd Rd Imm 8 Rd Rs 1 Addition Subtraction Set lower bits using immediate Set upper bits using immediate Bitwise and Bitwise or Bitwise not Bit shift Load word from memory Store word from memory Get a word from user input Send a word to output Branch if equal to zero Branch if greater than zero Jump and link register Halt the program 8
ANNA Instruction Set v 2 l Added a new add immediate “addi” instruction. m Stack pointer updates m Loop control variables l Removed halt: made it a special case of the output instruction (out r 0). m Input / output / halt already greatly simplified l Reduced the number of registers from 16 to 8. m Restricts register usage (function calls in particular). m Increases immediate sizes in the machine code format. 9
Tools l Assembler: translates assembly language files (. ac) into machine language files (. mc). l Simulator: loads and runs machine language files. m Debugging support: breakpoints, stepping, etc. l First two quarters: used command-line tools on Linux. m Worked fine – students already know Linux and familiar with command line tools. l Last quarter: students could use Windows GUIbased tools or the Linux command line tools. m Most, but not all, chose to use the Windows tools. 10
Assembler 11
Simulator 12
Computer Organization: Outline Topic Data representation Digital design CPU components Assembly programming Datapath and pipelining Memory and caching Input / output Review / exams Lecture Hours 4 10 3 15 8 5 2 3 I did not require the students to purchase a textbook. 13
Computer Organization: Outline Topic Data representation Digital design CPU components Assembly programming Datapath and pipelining Memory and caching Input / output Review / exams Lecture Hours 4 10 3 15 8 5 2 3 I did not require the students to purchase a textbook. 14
Course Information: Lectures l Assembly Language m Introduction to assembly m Converting C/C++ into assembly m Comparing ANNA to IA-32 instruction set m Overview of the compilation / linking process l Datapath / control m Single cycle datapath (omits I/O instructions) m Control ROM implementation m Pipelining m We no longer cover multiple cycle datapath 15
Course Information: Assignments l Assembly Language Programming m Find the highest number entered by a user. m Compute the log 2 of a number. m Find the mode of a set of numbers entered by the user. m Implement linked list functions. l Control & Datapath m Add instruction X to the datapath and control ROM. m Create a control ROM for a different datapath / instruction set. m Trace the execution of a program in a pipelined implementation. 16
Students Feedback l Most students felt… m they learned a lot when completing the ANNA programming assignments. m the ANNA tools were easy to use. m there was adequate documentation. l There were several suggestions for improving the Windows tools: m line numbers in the assembler m knowing what addresses labels map to in the simulator 17
Course Outcomes l Students were asked to judge how well a particular topic was covered. l Scale: 1(not covered) to 5 (very well covered) l Most topics received a 4. l No topic received a 2 or lower. 18
My Observations l Using the ANNA assembly language helped students learn the important concepts. l No differences between the classes that use the Windows tools and Linux tools except for implementing function calls. m Could be due to improvements in lecture l ANNA, a simple toy assembly language, did not dampen student motivation. l The datapath and design went fairly well. m Some “hand-waving” at times (pun intended) l Some students would benefit from having a textbook. m Most textbooks are tied to particular language. 19
Questions? More info? Contact me: Eric Larson elarson@seattleu. edu 20
- Slides: 20