20
1 A Simple but Realistic Assembly Language for a Course in Computer Organization Eric Larson Moon Ok Kim Seattle University October 25, 2008

A Simple but Realistic Assembly Language for a Course in Computer Organization

  • Upload
    brigid

  • View
    86

  • Download
    0

Embed Size (px)

DESCRIPTION

A Simple but Realistic Assembly Language for a Course in Computer Organization. Eric Larson Moon Ok Kim Seattle University October 25, 2008. Problem. A few years ago we had two computer hardware courses: Assembly Language Programming Computer Organization - PowerPoint PPT Presentation

Citation preview

Page 1: A Simple but Realistic Assembly Language for a Course in Computer Organization

1

A Simple but Realistic Assembly Language for a Course in Computer OrganizationEric LarsonMoon Ok KimSeattle University

October 25, 2008

Page 2: A Simple but Realistic Assembly Language for a Course in Computer Organization

Problem

A few years ago we had two computer hardware courses: Assembly Language Programming Computer Organization

Now we only have one course that combines the two courses.

Result: Too much material to cover in one course.

2

Page 3: A Simple but Realistic Assembly Language for a Course in Computer Organization

Solution

Use a simple, yet realistic, assembly language (ANNA) throughout the course.

Focus on key concepts of assembly language programming.

Does not burden students with the complexities of large instruction sets.

ANNA can be used in illustrating the datapath and pipelining units.

3

Page 4: A Simple but Realistic Assembly Language for a Course in Computer Organization

Outline

Background about the courseANNA assembly language and toolsHow ANNA was used in the courseFeedback and Observations

4

Page 5: A Simple but Realistic Assembly Language for a Course in Computer Organization

Computer Organization Course 5 credit (quarter) sophomore level class

requirement for CS majors Main topics:

Data representation Digital logic Assembly language programming Datapath and control Memory hierarchy

Material from other classes: OS: virtual memory, some I/O Discrete math: Boolean algebra

Taught using ANNA three times

5

Page 6: A Simple but Realistic Assembly Language for a Course in Computer Organization

Assembly Language Concepts

Key concepts in assembly language in our course: Registers and memory Conditional branches and jumps Translating high-level languages constructs into

assembly: if-else statements loops procedure calls arrays and pointers

Most importantly – experience actually writing assembly programs

6

Page 7: A Simple but Realistic Assembly Language for a Course in Computer Organization

ANNA Assembly Language v1 Memory is word addressable, words are 16 bits. Memory is shared by instructions or data. Data in memory / registers is either an integer or

an address. Can actually store anything – no instruction

support for other data types. Load / store architecture 16 general purpose registers, register r0 is 0.

Wise to introduce a calling convention that reserves a register for the stack pointer.

16 instructions (next slide).

7

Page 8: A Simple but Realistic Assembly Language for a Course in Computer Organization

ANNA Instruction Set v1

8

Opcode Operands Descriptionadd Rd Rs1 Rs2 Additionsub Rd Rs1 Rs2 Subtractionlli Rd Imm8 Set lower bits using immediatelui Rd Imm8 Set upper bits using immediateand Rd Rs1 Rs2 Bitwise andor Rd Rs1 Rs2 Bitwise ornot Rd Rs1 Bitwise notshf Rd Rs1 Rs2 Bit shiftlw Rd Rs1 Imm4 Load word from memorysw Rd Rs1 Imm4 Store word from memoryin Rd Get a word from user inputout Rd Send a word to outputbez Rd Imm8 Branch if equal to zerobgz Rd Imm8 Branch if greater than zerojalr Rd Rs1 Jump and link registerhalt Halt the program

Page 9: A Simple but Realistic Assembly Language for a Course in Computer Organization

ANNA Instruction Set v2 Added a new add immediate “addi” instruction.

Stack pointer updates Loop control variables

Removed halt: made it a special case of the output instruction (out r0). Input / output / halt already greatly simplified

Reduced the number of registers from 16 to 8. Restricts register usage (function calls in

particular). Increases immediate sizes in the machine code

format.

9

Page 10: A Simple but Realistic Assembly Language for a Course in Computer Organization

Tools Assembler: translates assembly language files

(.ac) into machine language files (.mc). Simulator: loads and runs machine language

files. Debugging support: breakpoints, stepping, etc.

First two quarters: used command-line tools on Linux. Worked fine – students already know Linux and

familiar with command line tools. Last quarter: students could use Windows GUI-

based tools or the Linux command line tools. Most, but not all, chose to use the Windows tools.

10

Page 11: A Simple but Realistic Assembly Language for a Course in Computer Organization

Assembler

11

Page 12: A Simple but Realistic Assembly Language for a Course in Computer Organization

Simulator

12

Page 13: A Simple but Realistic Assembly Language for a Course in Computer Organization

Computer Organization: Outline

Topic Lecture Hours

Data representation 4Digital design 10CPU components 3Assembly programming 15Datapath and pipelining 8Memory and caching 5Input / output 2Review / exams 3

13I did not require the students to purchase a textbook.

Page 14: A Simple but Realistic Assembly Language for a Course in Computer Organization

Computer Organization: Outline

Topic Lecture Hours

Data representation 4Digital design 10CPU components 3Assembly programming 15Datapath and pipelining 8Memory and caching 5Input / output 2Review / exams 3

14I did not require the students to purchase a textbook.

Page 15: A Simple but Realistic Assembly Language for a Course in Computer Organization

Course Information: Lectures

Assembly Language Introduction to assembly Converting C/C++ into assembly Comparing ANNA to IA-32 instruction set Overview of the compilation / linking process

Datapath / control Single cycle datapath (omits I/O instructions) Control ROM implementation Pipelining We no longer cover multiple cycle datapath

15

Page 16: A Simple but Realistic Assembly Language for a Course in Computer Organization

Course Information: Assignments Assembly Language Programming

Find the highest number entered by a user. Compute the log2 of a number. Find the mode of a set of numbers entered by the

user. Implement linked list functions.

Control & Datapath Add instruction X to the datapath and control

ROM. Create a control ROM for a different datapath /

instruction set. Trace the execution of a program in a pipelined

implementation.

16

Page 17: A Simple but Realistic Assembly Language for a Course in Computer Organization

Students Feedback

Most students felt… they learned a lot when completing the

ANNA programming assignments. the ANNA tools were easy to use. there was adequate documentation.

There were several suggestions for improving the Windows tools: line numbers in the assembler knowing what addresses labels map to in

the simulator

17

Page 18: A Simple but Realistic Assembly Language for a Course in Computer Organization

Course Outcomes

Students were asked to judge how well a particular topic was covered.

Scale: 1(not covered) to 5 (very well covered)

Most topics received a 4.No topic received a 2 or lower.

18

Page 19: A Simple but Realistic Assembly Language for a Course in Computer Organization

My Observations Using the ANNA assembly language helped

students learn the important concepts. No differences between the classes that use the

Windows tools and Linux tools except for implementing function calls. Could be due to improvements in lecture

ANNA, a simple toy assembly language, did not dampen student motivation.

The datapath and design went fairly well. Some “hand-waving” at times (pun intended)

Some students would benefit from having a textbook. Most textbooks are tied to particular language.

19

Page 20: A Simple but Realistic Assembly Language for a Course in Computer Organization

Questions?

More info? Contact me:Eric [email protected]

20