You are on page 1of 45

Carnegie Mellon

1
Mach|ne-Leve| rogramm|ng I: 8as|cs

13-213/18-213: lnLroducuon Lo CompuLer SysLems
3
Lh
LecLure, Sep. 10, 2013
Instructors:
8andy 8ryanL, uave C'Pallaron, and Creg kesden
Carnegie Mellon
2
1oday: Mach|ne rogramm|ng I: 8as|cs
! n|story of Inte| processors and arch|tectures
! C, assemb|y, mach|ne code
! Assemb|y 8as|cs: keg|sters, operands, move
! Intro to x86-64
Carnegie Mellon
3
Inte| x86 rocessors
! 1ota||y dom|nate |aptop]desktop]server market
! Lvo|unonary des|gn
! 8ackwards compauble up unul 8086, lnLroduced ln 1978
! Added more feaLures as ume goes on
! Comp|ex |nstrucnon set computer (CISC)
! Many dlerenL lnsLrucuons wlLh many dlerenL formaLs
! 8uL, only small subseL encounLered wlLh Llnux programs
! Pard Lo maLch performance of 8educed lnsLrucuon SeL CompuLers
(8lSC)
! 8uL, lnLel has done [usL LhaL!
! ln Lerms of speed. Less so for low power.
Carnegie Mellon
4
Inte| x86 Lvo|unon: M||estones
"#$% &#'% ()#*+,+'-)+ ./0
! 8086 1978 29k S-10
! llrsL 16-blL lnLel processor. 8asls for l8M C & uCS
! 1M8 address space
! 386 198S 27Sk 16-33
! llrsL 32 blL lnLel processor , referred Lo as lA32
! Added aL addresslng", capable of runnlng unlx
! ennum 4I 2004 12SM 2800-3800
! llrsL 64-blL lnLel processor, referred Lo as x86-64
! Core 2 2006 291M 1060-3S00
! llrsL mulu-core lnLel processor
! Core |7 2008 731M 1700-3900
! lour cores (our shark machlnes)
Carnegie Mellon
5
Inte| x86 rocessors, cont.
! Mach|ne Lvo|unon
! 386 1983 0.3M
! enuum 1993 3.1M
! enuum/MMx 1997 4.3M
! enuumro 1993 6.3M
! enuum lll 1999 8.2M
! enuum 4 2001 42M
! Core 2 uuo 2006 291M
! Core l7 2008 731M
! Added Ieatures
! lnsLrucuons Lo supporL mulumedla operauons
! lnsLrucuons Lo enable more emclenL condluonal operauons
! 1ransluon from 32 blLs Lo 64 blLs
! More cores
Carnegie Mellon
6
2013 State of the Art
! Core l7 Paswell 2013 1.48
! Ieatures:
! 4 cores Max 4.0 CPz Clock 84 Waus
Carnegie Mellon
7
x86 C|ones: Advanced M|cro Dev|ces (AMD)
! n|stor|ca||y
! AMu has followed [usL behlnd lnLel
! A llule blL slower, a loL cheaper
! 1hen
! 8ecrulLed Lop clrculL deslgners from ulglLal LqulpmenL Corp. and
oLher downward Lrendlng companles
! 8ullL CpLeron: Lough compeuLor Lo enuum 4
! ueveloped x86-64, Lhelr own exLenslon Lo 64 blLs
Carnegie Mellon
8
Inte|'s 64-8|t n|story
! Inte| Auempted kad|ca| Sh|h from IA32 to IA64
! 1oLally dlerenL archlLecLure (lLanlum)
! LxecuLes lA32 code only as legacy
! erformance dlsappolnung
! AMD Stepped |n w|th Lvo|unonary So|unon
! x86-64 (now called AMu64")
! Inte| Ie|t Cb||gated to Iocus on IA64
! Pard Lo admlL mlsLake or LhaL AMu ls beuer
! 2004: Inte| Announces LM641 extens|on to IA32
! LxLended Memory 64-blL 1echnology
! AlmosL ldenucal Lo x86-64!
! A|| but |ow-end x86 processors support x86-64
! 8uL, loLs of code sull runs ln 32-blL mode
Carnegie Mellon
9
Cur Coverage
! IA32
! 1he Lradluonal x86
! shark> gcc m32 hello.c
! x86-64
! 1he emerglng sLandard
! shark> gcc hello.c
! shark> gcc m64 hello.c
! resentanon
! 8ook presenLs lA32 ln Secuons 3.1-3.12
! Covers x86-64 ln 3.13
! We wlll cover boLh slmulLaneously
! Some labs wlll be based on x86-64, oLhers on lA32
Carnegie Mellon
10
1oday: Mach|ne rogramm|ng I: 8as|cs
! n|story of Inte| processors and arch|tectures
! C, assemb|y, mach|ne code
! Assemb|y 8as|cs: keg|sters, operands, move
! Intro to x86-64

Carnegie Mellon
11
Dehn|nons
! Arch|tecture: (a|so ISA: |nstrucnon set arch|tecture) 1he
parts of a processor des|gn that one needs to understand
to wr|te assemb|y code.
! Lxamples: lnsLrucuon seL speclcauon, reglsLers.
! M|croarch|tecture: Imp|ementanon of the arch|tecture.
! Lxamples: cache slzes and core frequency.

! Lxamp|e ISAs (Inte|): IA32, x86-64
Carnegie Mellon
12
CU
Assemb|y rogrammer's V|ew
rogrammer-V|s|b|e State
! C: rogram counter
! Address of nexL lnsLrucuon
! Called Ll" (lA32) or 8l" (x86-64)
! keg|ster h|e
! Peavlly used program daLa
! Cond|non codes
! SLore sLaLus lnformauon abouL mosL
recenL arlLhmeuc or loglcal operauon
! used for condluonal branchlng
C
keg|sters
Memory
Code
Data
Stack
Addresses
uaLa
lnsLrucuons
Cond|non
Codes
! Memory
! 8yLe addressable array
! Code and user daLa
! SLack Lo supporL procedures
Carnegie Mellon
13
'%1'
'%1'
2,*#)3
2,*#)3
Comp||er (gcc -S)
Assemb|er (gcc or as)
L|nker (gcc or ld)
C program (p1.c p2.c)
Asm program (p1.s p2.s)
Cb[ect program (p1.o p2.o)
Lxecutab|e program (p)
Stanc ||brar|es
(.a)
1urn|ng C |nto Cb[ect Code
! Code ln les p1.c p2.c
! Complle wlLh command: gcc O1 p1.c p2.c -o p
! use baslc opumlzauons (-O1)
! uL resulung blnary ln le p
Carnegie Mellon
14
Comp|||ng Into Assemb|y
C Code (p1.c)

int sum(int x, int y)
{
int t = x+y;
return t;
}
Generated IA32 Assemb|y

sum:
pushl %ebp
movl %esp,%ebp
movl 12(%ebp),%eax
addl 8(%ebp),%eax
popl %ebp
ret
Cbta|n (on shark mach|ne) w|th command
gcc O1 m32 S p1.c
roduces h|e p1.s
4#)*,*5: W||| get very d|erent resu|ts on non-Shark
mach|nes (Andrew L|nux, Mac CS-k, .) due to d|erent
vers|ons of gcc and d|erent comp||er semngs.

Carnegie Mellon
15
Assemb|y Character|sncs: Data 1ypes
! "Integer" data of 1, 2, or 4 bytes
! uaLa values
! Addresses (unLyped polnLers)
! I|oanng po|nt data of 4, 8, or 10 bytes
! No aggregate types such as arrays or structures
! !usL conuguously allocaLed byLes ln memory
Carnegie Mellon
16
Assemb|y Character|sncs: Cperanons
! erform ar|thmenc funcnon on reg|ster or memory data
! 1ransfer data between memory and reg|ster
! Load daLa from memory lnLo reglsLer
! SLore reglsLer daLa lnLo memory
! 1ransfer contro|
! uncondluonal [umps Lo/from procedures
! Condluonal branches
Carnegie Mellon
17
Code for sum

0x08483f4 <sum>:
0x55
0x89
0xe5
0x8b
0x45
0x0c
0x03
0x45
0x08
0x5d
0xc3
Cb[ect Code
! Assemb|er
! 1ranslaLes .s lnLo .o
! 8lnary encodlng of each lnsLrucuon
! nearly-compleLe lmage of execuLable code
! Mlsslng llnkages beLween code ln dlerenL
les
! L|nker
! 8esolves references beLween les
! Comblnes wlLh sLauc run-ume llbrarles
! L.g., code for malloc, printf
! Some llbrarles are !"#$%&'$((" (&#*+!
! Llnklng occurs when program beglns
execuuon
- 1ota| of 11 bytes
- Lach |nstrucnon
1, 2, or 3 bytes
- Starts at address
0x401040
Carnegie Mellon
18
Mach|ne Instrucnon Lxamp|e
! C Code
! Add Lwo slgned lnLegers
! Assemb|y
! Add 2 4-byLe lnLegers
! Long" words ln CCC parlance
! Same lnsLrucuon wheLher slgned
or unslgned
! Cperands:
x: 8eglsLer %eax
y: Memory M[%ebp+8]
t: 8eglsLer %eax
- 8eLurn funcuon value ln %eax
! Cb[ect Code
! 3-byLe lnsLrucuon
! SLored aL address 0x80483fa
int t = x+y;
addl 8(%ebp),%eax
0x80483fa: 03 45 08
S|m||ar to express|on:
x += y
More prec|se|y:
int eax;
int *ebp;
eax += ebp[2]
Carnegie Mellon
19
D|sassemb|ed

D|sassemb||ng Cb[ect Code
! D|sassemb|er
objdump -d p
! useful Lool for examlnlng ob[ecL code
! Analyzes blL pauern of serles of lnsLrucuons
! roduces approxlmaLe rendluon of assembly code
! Can be run on elLher a.out (compleLe execuLable) or .o le
080483f4 <sum>:
80483f4: 55 push %ebp
80483f5: 89 e5 mov %esp,%ebp
80483f7: 8b 45 0c mov 0xc(%ebp),%eax
80483fa: 03 45 08 add 0x8(%ebp),%eax
80483fd: 5d pop %ebp
80483fe: c3 ret
Carnegie Mellon
20
D|sassemb|ed

Dump of assembler code for function sum:
0x080483f4 <sum+0>: push %ebp
0x080483f5 <sum+1>: mov %esp,%ebp
0x080483f7 <sum+3>: mov 0xc(%ebp),%eax
0x080483fa <sum+6>: add 0x8(%ebp),%eax
0x080483fd <sum+9>: pop %ebp
0x080483fe <sum+10>: ret
A|ternate D|sassemb|y
! W|th|n gdb Debugger
gdb p
disassemble sum
! ulsassemble procedure
x/11xb sum
! Lxamlne Lhe 11 byLes sLarung aL sum
Cb[ect

0x080483f4:
0x55
0x89
0xe5
0x8b
0x45
0x0c
0x03
0x45
0x08
0x5d
0xc3
Carnegie Mellon
21
What Can be D|sassemb|ed?
! Anyth|ng that can be |nterpreted as executab|e code
! D|sassemb|er exam|nes bytes and reconstructs assemb|y source
% objdump -d WINWORD.EXE

WINWORD.EXE: file format pei-i386

No symbols in "WINWORD.EXE".
Disassembly of section .text:

30001000 <.text>:
30001000: 55 push %ebp
30001001: 8b ec mov %esp,%ebp
30001003: 6a ff push $0xffffffff
30001005: 68 90 10 00 30 push $0x30001090
3000100a: 68 91 dc 4c 30 push $0x304cdc91
Carnegie Mellon
22
1oday: Mach|ne rogramm|ng I: 8as|cs
! n|story of Inte| processors and arch|tectures
! C, assemb|y, mach|ne code
! Assemb|y 8as|cs: keg|sters, operands, move
! Intro to x86-64

Carnegie Mellon
23
Integer keg|sters (IA32)
%eax
%ecx
%edx
%ebx
%esi
%edi
%esp
%ebp
%ax
%cx
%dx
%bx
%si
%di
%sp
%bp
%ah
%ch
%dh
%bh
%al
%cl
%dl
%bl
16-b|t v|rtua| reg|sters
(backwards companb|||ty)
g
e
n
e
r
a
|

p
u
r
p
o
s
e

accumulate
counter
data
base
source
index
destination
index
stack
pointer
base
pointer
Cr|g|n
(most|y obso|ete)
Carnegie Mellon
24
Mov|ng Data: IA32
! Mov|ng Data
movl 6-7)8%, &%+':
! Cperand 1ypes
! 9$$%:,#'%; ConsLanL lnLeger daLa
! Lxample: $0x400, $-533
! Llke C consLanL, buL prexed wlLh $
! Lncoded wlLh 1, 2, or 4 byLes
! <%5,+'%); Cne of 8 lnLeger reglsLers
! Lxample: %eax, %edx
! 8uL %esp and %ebp reserved for speclal use
! CLhers have speclal uses for parucular lnsLrucuons
! .%$-)3; 4 consecuuve byLes of memory aL address glven by reglsLer
! SlmplesL example: (%eax)
! varlous oLher address modes"
%eax
%ecx
%edx
%ebx
%esi
%edi
%esp
%ebp
Carnegie Mellon
25
movl Cperand Comb|nanons
=#**-' :- $%$-)3>$%$-)3 ')#*+?%) @,'A # +,*5B% ,*+')78C-*
movl
9$$
<%5
.%$
<%5
.%$
<%5
.%$
<%5
Source Dest C Ana|og
movl $0x4,%eax temp = 0x4;
movl $-147,(%eax) *p = -147;
movl %eax,%edx temp2 = temp1;
movl %eax,(%edx) *p = temp;
movl (%eax),%edx temp = *p;
Src,Dest
Carnegie Mellon
26
S|mp|e Memory Address|ng Modes
! Norma| (k) Mem[keg[k]]
! 8eglsLer 8 specles memory address
! Aha! olnLer dereferenclng ln C

movl (%ecx),%eax
! D|sp|acement D(k) Mem[keg[k]+D]
! 8eglsLer 8 specles sLarL of memory reglon
! ConsLanL dlsplacemenL u specles oseL

movl 8(%ebp),%edx
Carnegie Mellon
27
Lxamp|e of S|mp|e Address|ng Modes
void swap(int *xp, int *yp)
{
int t0 = *xp;
int t1 = *yp;
*xp = t1;
*yp = t0;
}
8ody
Set
Up
I|n|sh
swap:
pushl %ebp
movl %esp,%ebp
pushl %ebx

movl 8(%ebp), %edx
movl 12(%ebp), %eax
movl (%edx), %ecx
movl (%eax), %ebx
movl %ebx, (%edx)
movl %ecx, (%eax)

popl %ebx
popl %ebp
ret
Carnegie Mellon
28
Us|ng S|mp|e Address|ng Modes
void swap(int *xp, int *yp)
{
int t0 = *xp;
int t1 = *yp;
*xp = t1;
*yp = t0;
}
swap:
pushl %ebp
movl %esp,%ebp
pushl %ebx

movl 8(%ebp), %edx
movl 12(%ebp), %eax
movl (%edx), %ecx
movl (%eax), %ebx
movl %ebx, (%edx)
movl %ecx, (%eax)

popl %ebx
popl %ebp
ret
8ody
Set
Up
I|n|sh
Carnegie Mellon
29
Understand|ng Swap
void swap(int *xp, int *yp)
{
int t0 = *xp;
int t1 = *yp;
*xp = t1;
*yp = t0;
}
Stack
(|n memory)
keg|ster Va|ue
%edx xp
%eax yp
%ecx t0
%ebx t1
yp
xp
ktn adr
C|d ebp %ebp 0
4
8
12
Cset
-
-
-
C|d ebx -4 %esp
movl 8(%ebp), %edx # edx = xp
movl 12(%ebp), %eax # eax = yp
movl (%edx), %ecx # ecx = *xp (t0)
movl (%eax), %ebx # ebx = *yp (t1)
movl %ebx, (%edx) # *xp = t1
movl %ecx, (%eax) # *yp = t0
Carnegie Mellon
30
Understand|ng Swap
0x120
0x124
ktn adr
%ebp
0
4
8
12
Cset
-4
123
456
Address
0x124
0x120
0x11c
0x118
0x114
0x110
0x10c
0x108
0x104
0x100
yp
xp
%eax
%edx
%ecx
%ebx
%esi
%edi
%esp
%ebp 0x104
movl 8(%ebp), %edx # edx = xp
movl 12(%ebp), %eax # eax = yp
movl (%edx), %ecx # ecx = *xp (t0)
movl (%eax), %ebx # ebx = *yp (t1)
movl %ebx, (%edx) # *xp = t1
movl %ecx, (%eax) # *yp = t0
Carnegie Mellon
31
Understand|ng Swap
0x120
0x124
ktn adr
%ebp
0
4
8
12
Cset
-4
123
456
Address
0x124
0x120
0x11c
0x118
0x114
0x110
0x10c
0x108
0x104
0x100
yp
xp
%eax
%edx
%ecx
%ebx
%esi
%edi
%esp
%ebp
0x124
0x104
0x120
movl 8(%ebp), %edx # edx = xp
movl 12(%ebp), %eax # eax = yp
movl (%edx), %ecx # ecx = *xp (t0)
movl (%eax), %ebx # ebx = *yp (t1)
movl %ebx, (%edx) # *xp = t1
movl %ecx, (%eax) # *yp = t0
Carnegie Mellon
32
Understand|ng Swap
0x120
0x124
ktn adr
%ebp
0
4
8
12
Cset
-4
123
456
Address
0x124
0x120
0x11c
0x118
0x114
0x110
0x10c
0x108
0x104
0x100
yp
xp
%eax
%edx
%ecx
%ebx
%esi
%edi
%esp
%ebp
0x120
0x104
0x124
0x124
movl 8(%ebp), %edx # edx = xp
movl 12(%ebp), %eax # eax = yp
movl (%edx), %ecx # ecx = *xp (t0)
movl (%eax), %ebx # ebx = *yp (t1)
movl %ebx, (%edx) # *xp = t1
movl %ecx, (%eax) # *yp = t0
Carnegie Mellon
33
456
Understand|ng Swap
0x120
0x124
ktn adr
%ebp
0
4
8
12
Cset
-4
123
456
Address
0x124
0x120
0x11c
0x118
0x114
0x110
0x10c
0x108
0x104
0x100
yp
xp
%eax
%edx
%ecx
%ebx
%esi
%edi
%esp
%ebp
0x124
123
0x104
0x120
movl 8(%ebp), %edx # edx = xp
movl 12(%ebp), %eax # eax = yp
movl (%edx), %ecx # ecx = *xp (t0)
movl (%eax), %ebx # ebx = *yp (t1)
movl %ebx, (%edx) # *xp = t1
movl %ecx, (%eax) # *yp = t0
Carnegie Mellon
34
Understand|ng Swap
0x120
0x124
ktn adr
%ebp
0
4
8
12
Cset
-4
123
456
Address
0x124
0x120
0x11c
0x118
0x114
0x110
0x10c
0x108
0x104
0x100
yp
xp
%eax
%edx
%ecx
%ebx
%esi
%edi
%esp
%ebp
0x120
0x124
123
0x104
123
456
movl 8(%ebp), %edx # edx = xp
movl 12(%ebp), %eax # eax = yp
movl (%edx), %ecx # ecx = *xp (t0)
movl (%eax), %ebx # ebx = *yp (t1)
movl %ebx, (%edx) # *xp = t1
movl %ecx, (%eax) # *yp = t0
Carnegie Mellon
35
456
456
Understand|ng Swap
0x120
0x124
ktn adr
%ebp
0
4
8
12
Cset
-4
Address
0x124
0x120
0x11c
0x118
0x114
0x110
0x10c
0x108
0x104
0x100
yp
xp
%eax
%edx
%ecx
%ebx
%esi
%edi
%esp
%ebp 0x104
movl 8(%ebp), %edx # edx = xp
movl 12(%ebp), %eax # eax = yp
movl (%edx), %ecx # ecx = *xp (t0)
movl (%eax), %ebx # ebx = *yp (t1)
movl %ebx, (%edx) # *xp = t1
movl %ecx, (%eax) # *yp = t0
0x120
0x124
123
456
Carnegie Mellon
36
Understand|ng Swap
0x120
0x124
ktn adr
%ebp
0
4
8
12
Cset
-4
456
123
Address
0x124
0x120
0x11c
0x118
0x114
0x110
0x10c
0x108
0x104
0x100
yp
xp
%eax
%edx
%ecx
%ebx
%esi
%edi
%esp
%ebp 0x104
movl 8(%ebp), %edx # edx = xp
movl 12(%ebp), %eax # eax = yp
movl (%edx), %ecx # ecx = *xp (t0)
movl (%eax), %ebx # ebx = *yp (t1)
movl %ebx, (%edx) # *xp = t1
movl %ecx, (%eax) # *yp = t0
0x120
0x124
123
456
Carnegie Mellon
37
Comp|ete Memory Address|ng Modes
! Most Genera| Iorm
D(kb,k|,S) Mem[keg[kb]+S*keg[k|]+ D]
! u: ConsLanL dlsplacemenL" 1, 2, or 4 byLes
! 8b: 8ase reglsLer: Any of 8 lnLeger reglsLers
! 8l: lndex reglsLer: Any, excepL for %esp
! unllkely you'd use %ebp, elLher
! S: Scale: 1, 2, 4, or 8 (,-" .-+/+ #0%1+2/3)
! Spec|a| Cases
(kb,k|) Mem[keg[kb]+keg[k|]]
D(kb,k|) Mem[keg[kb]+keg[k|]+D]
(kb,k|,S) Mem[keg[kb]+S*keg[k|]]
Carnegie Mellon
38
1oday: Mach|ne rogramm|ng I: 8as|cs
! n|story of Inte| processors and arch|tectures
! C, assemb|y, mach|ne code
! Assemb|y 8as|cs: keg|sters, operands, move
! Intro to x86-64

Carnegie Mellon
39
Data kepresentanons: IA32 + x86-64
! S|zes of C Cb[ects (|n 8ytes)
C uaLa 1ype Cenerlc 32-blL lnLel lA32 x86-64
! unslgned 4 4 4
! lnL 4 4 4
! long lnL 4 4 8
! char 1 1 1
! shorL 2 2 2
! oaL 4 4 4
! double 8 8 8
! long double 8 10/12 10/16
! char * 4 4 8
- Cr any oLher polnLer
Carnegie Mellon
40
%rsp
x86-64 Integer keg|sters
! LxLend exlsung reglsLers. Add 8 new ones.
! Make %ebp/%rbp general purpose
%eax
%ebx
%ecx
%edx
%esi
%edi
%esp
%ebp
%r8d
%r9d
%r10d
%r11d
%r12d
%r13d
%r14d
%r15d
%r8
%r9
%r10
%r11
%r12
%r13
%r14
%r15
%rax
%rbx
%rcx
%rdx
%rsi
%rdi
%rbp
Carnegie Mellon
41
Instrucnons
! Long word l (4 8ytes) uad word q (8 8ytes)
! New |nstrucnons:
! movl ! movq
! addl ! addq
! sall ! salq
! eLc.
! 32-b|t |nstrucnons that generate 32-b|t resu|ts
! SeL hlgher order blLs of desunauon reglsLer Lo 0
! Lxample: addl
Carnegie Mellon
42
32-b|t code for swap
void swap(int *xp, int *yp)
{
int t0 = *xp;
int t1 = *yp;
*xp = t1;
*yp = t0;
}
8ody
Set
Up
I|n|sh
swap:
pushl %ebp
movl %esp,%ebp
pushl %ebx

movl 8(%ebp), %edx
movl 12(%ebp), %eax
movl (%edx), %ecx
movl (%eax), %ebx
movl %ebx, (%edx)
movl %ecx, (%eax)

popl %ebx
popl %ebp
ret
Carnegie Mellon
43
64-b|t code for swap
! Cperands passed |n reg|sters (why usefu|?)
! llrsL (xp) ln %rdi, second (yp) ln %rsi
! 64-blL polnLers
! No stack operanons requ|red
! 32-b|t data
! uaLa held ln reglsLers %edx and %eax
! movl operauon
void swap(int *xp, int *yp)
{
int t0 = *xp;
int t1 = *yp;
*xp = t1;
*yp = t0;
}
8ody
Set
Up
I|n|sh
swap:


movl (%rdi), %eax
movl (%rsi), %edx
movl %edx, (%rdi)
movl %eax, (%rsi)

ret
Carnegie Mellon
44
64-b|t code for |ong |nt swap
! 64-b|t data
! uaLa held ln reglsLers %rdx and %rax
! movq operauon
! q" sLands for quad-word
void swap(long *xp, long *yp)
{
long t0 = *xp;
long t1 = *yp;
*xp = t1;
*yp = t0;
}
8ody
Set
Up
I|n|sh
swap_l:


movq (%rdi), %rax
movq (%rsi), %rdx
movq %rdx, (%rdi)
movq %rax, (%rsi)

ret
Carnegie Mellon
45
Mach|ne rogramm|ng I: Summary
! n|story of Inte| processors and arch|tectures
! Lvoluuonary deslgn leads Lo many qulrks and arufacLs
! C, assemb|y, mach|ne code
! Compller musL Lransform sLaLemenLs, expresslons, procedures lnLo
low-level lnsLrucuon sequences
! Assemb|y 8as|cs: keg|sters, operands, move
! 1he x86 move lnsLrucuons cover wlde range of daLa movemenL
forms
! Intro to x86-64
! A ma[or deparLure from Lhe sLyle of code seen ln lA32

You might also like