Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

CS 354 - Machine Organization

Monday, October 24, 2016

Project p3 (6%) due 10 pm TODAY Monday, October 24th (exam week)


Midterm Exam Thursday October 27th, 7:15 - 9:15 pm
Lec 1: room 272 of Bascom Hall
Lec 2: room B10 Ingraham Hall
UW ID required
see page L20-5 for topics list

Last Time
Cache Parameters and Performance
Coding for Caches
Memory Mountain
Today
Assembly Language Intro
 C, Assembly & Machine Code
 ISAs
 Compiling Steps
 Registers
Next Time
Read: B&O 3 Intro, 3.4
Operands and Data Movement Instructions

Copyright 2016 Jim Skrentny

CS 354 (F16): L21 - 1

C, Assembly & Machine Code


C

Assembly

Machine Code

Why Learn Assembly?

Assembly Data Formats


C
char
short
int
long int
long long int
char*
float
double
long double

Intel
Assembly Suffix
byte
word
double word
double word
---double word
single precision
double prec
extended prec

Copyright 2016 Jim Skrentny

Size in Bytes

CS 354 (F16): L21 - 2

ISAs

Instruction Set Architecture

Moores Law

IA-32

x86-64

Copyright 2016 Jim Skrentny

CS 354 (F16): L21 - 3

Compiling Steps

Compiler

Optimizing compilers

1. Preprocessor

2. Compiler

3. Assembler

4. Linker

Copyright 2016 Jim Skrentny

CS 354 (F16): L21 - 4

Compiling Example
C Function

Assembly

int accum = 0;
int sum(int x, int y)
{

AT&T
sum:
pushl %epb
55
movl %esp, %ebp
89
movl 12(%ebp), %eax
8b
addl 8(%ebp), %eax
03
addl %eax, accum
01
popl %ebp
5D
ret
C3
Intel
sum:
push ebp
mov ebp, esp
edx, DWORD PTR [ebp+12]
add eax, DWORD PTR [ebp+8]
add eax, accum
pop ebp
ret

int t = x + y;
accum += t;
return t;
}

mov

Machine

e5
45 0C
45 08
05 -- -- -- --

What aspects of machine does C hide from us?

Cs vs. machines view of data:

What does assembly remove?

IA-32 Machine Code

Copyright 2016 Jim Skrentny

CS 354 (F16): L21 - 5

Registers

What?

Program Counter

General Registers

bit 31

15

87

Condition Code Registers

Floating Point Registers

Copyright 2016 Jim Skrentny

CS 354 (F16): L21 - 6

You might also like