CS237 Assembly Language Programming & Machine Organization Fall 2014 Credits: 3 units Instructor: Alan Riggins Office: GMCS 534 Email: ariggins@mail.sdsu.edu Office Hours: 10:00-11:30 Monday, 9:00-11:30 Wednesday, Friday. Course Materials Clicker, from Aztec Bookstore, Required. Ford & Topp, Assembly Language and Systems Programming for the M68000 Family, Course Reader, Aztec Publishing, Required. NOTE: You may be able to find a used copy of this text for much less than Aztec Shop is charging. Look on Amazon before buying! Riggins, CS237 Machine Organization & Assembly Language Programming, Supplementary Material. Auxiliary Reader Spring 2013. Aztec Publishing. Required. Motorola, Programmer's Reference Manual for the M68000 Family. Auxiliary Reader Spring 2013. Aztec Publishing. Required. Course Information Prerequisites: Computer Science 108. Description from the Official Course Catalog General concepts of machine and assembly language, data representation, looping and addressing techniques, arrays, subroutines, macros. Extensive assembly language programming. Course Type: Required lower division core curriculum course. Specific Goals for CS237 Course-Level Student Learning Outcomes 1. Students should gain a thorough understanding of basic computer organization. 2. Students should gain a thorough understanding of how data is represented in a computer system, including two’s complement, IEEE floating point numbers, and character data. 3. Enhance student understanding of the low-level operations of a computer system, including the interactions between the CPU and peripheral devices. 4. Ability to understand the difference between compilers and assemblers, and some of the optimization techniques compilers use. 5. Students should be able develop, assemble and deploy assembly language programs. 6. Students should understand the system stack and the mechanisms for subroutine calls. 7. Students should gain a thorough understanding of recursion. Relationship to CS Program Course Outcomes CS37 addresses the following outcomes: 1. An ability to apply knowledge of computing. 2. An ability to understand fundamental computer organization. 3. An ability to understand how data is represented within a computer system. 4. An ability to use current techniques, skills, and tools necessary for computing practice 5. An ability to apply mathematical foundations, algorithmic principles, and computer science theory in the modeling and design of computer-based systems in a way that demonstrates comprehension of the tradeoffs involved in design choices. 6. An ability to apply design and development principles in the construction of software systems of varying complexity. Topics Covered 1. Machine architecture. 2. Representation of data: two’s complement, floating point numbers, chacter data. 3. Addressing modes. 4. Bitwise operators. 5. Looping and branching in assembly language. 6. Hand translation of assembly language code to machine code. 7. Subroutines and the system stack. 8. Recursion. Schedule and Grading Policies Week Topic 1 Introduction to machine organization. CPU, bus, memory (ROM/RAM), peripheral devices. RISC vs. CISC architecture. 2-3 Two's complement representation. Addition and subtraction of binary/hex numbers. Overflow. 4-5 Introduction to assembly language programming, basic instructions. Assemblers, compilers, linkers, loaders. Introduction to the programming environment for the course. Representation of character data, I/O macros. Projects/Activities Midterm #1, Project #1 6-7 Storage allocation, memory management. Introduction to addressing modes. Pointers/references in higher level languages. 8 Logical operators, bitwise AND, OR, XOR. Errors in the programming process: Syntax errors, runtime errors, address (pointer) errors 9-10 Introduction to flow control in assembler. The Status Register and Condition Code Register. If/else/case statements. For/do/while loops. Signed and unsigned branches. Shift operations, bit operations. Compilers. Code optimization, unrolling loops, constant folding, common sub-expression elimination, invariants, optimizing register use. Hand translation into machine code. Floating point representation, and software emulation 11 12-13 Introduction to subroutines. Procedures and functions. The run-time stack. Structured programming principles. Parameter passing protocols. Saving state on the run-time stack. Stack frames. Creating reusable code, calling assembly language subroutines from higher level languages. 14-15 Recursion. Extensive coverage of recursive algorithms, and how they are implemented in assembler. Macros. Macros vs. subroutines, the tradeoffs. Interrupts and traps. Midterm #2, Project #2 Midterm #3, Project #3 Project #4 Projects/Assignments There are at least four programming assignments in assembler, examples of which follow: Program #1: A simple assignment designed to familiarize students with the simulator used in the course. The assignment typically uses all I/O macros to familiarize students with proper usage. Program #2: An iterative algorithm is given. Emphasis on debugging techniques and proper assembly language programming. Program #3: This is usually the major project for the semester. Much larger in scope than previous projects, a complete application program is developed. The project requires extensive flow control/branching code. Typically, a more complex algorithm is used. Past projects include finding primes with the Sieve of Eratosthenes method, reducing fractions with Euclid's algorithm (GCD), and binary search on data in an external file. Program #4: This programming assignment emphasizes subroutines and their proper implementation. Students will develop two to four subroutines in separate files in addition to a main or 'driver' program. One of the subroutines is always a recursive function. Grading Policy Grading is based on exams (60%), programming assignments (30%), and in-class exercises (10%). There are four programming assignments, three midterm exams, and a final exam. Grades are not curved, but based on percentages: 93% and above A 90%-92% A87%-89% B+ 83%-86% B 80%-82% B77%-79% C+ 73%-76% C 70%-72% C67%-69% D+ 63%-66% D 60%-62% Dbelow 60% F Students with Disabilities If you are a student with a disability and believe you will need accommodations for this class, it is your responsibility to contact Student Disability Services at 619 594-6473. To avoid any delay in the receipt of your accommodations, you should contact Student Disability Services as soon as possible. Please note that accommodations are not retroactive, and that accommodations based upon disability cannot be provided until you have presented your instructor with an accommodation letter from Student Disability Services. Your cooperation is appreciated.