IA32 Stack Discipline Aug 30, 2017
|
|
- Aron Parsons
- 6 years ago
- Views:
Transcription
1 A Experiece Like No Other IA32 Disciplie Aug 30, 2017 Dave Eckhardt Dave O Hallaro Slides origially stole from , F 17
2 Sychroizatio Registratio The wait list will probably be doe today or tomorrow I do't thik everybody will fit If you're here but ot o ay wait list, see me right away ECE udergrad: most likely 5/15 will fit (could be more) ECE M.S.: 4/7 likely? INI: most likely 10/20? If you are a M.S. or or Ph.D. studet ad have ot discussed this class with your advisor, do so today We will ot be registerig graduate studets without hearig from their advisors Some people are beig added this morig If you receive mail from a admiistrator, please reply the same day If you have't take (A/B, malloc lab ok) Cotact me o later tha today , F 17
3 Why Oly 32? You leared x86-64 i 213 Most machies (eve phoes!) are 64-bit these days x86-64 is simpler tha IA32 for user code Why will 410 be IA32? x86-64 is ot simpler for kerel code Machie begis i 16-bit mode, the 32, fially 64 Iterrupts are more complicated x86-64 is ot simpler durig debuggig More registers meas more registers to have wrog values x86-64 virtual memory is a bit of a drag More steps tha x86-32, but ot more itellectually stimulatig There are still a lot of 32-bit machies i the world...which ca boot ad ru your persoal OS , F 17
4 IA32 vs x86-64 Geeratig IA32 code: gcc m32 o hello hello.c Key differeces: IA32 has oly 8 32-bit geeral purpose registers IA32 might use %ebp as a stack frame poiter. gcc m32 -fo-stack-protector -fo-omit-frame-poiter IA32 passes argumets o the stack rather tha i registers IA32 has differet caller/callee-save register covetios Detailed IA32 Summary: , F 17
5 IA32/Liux Registers Iteger Registers Two have special uses %ebp, Three maaged as callee-save %ebx, %esi, %edi Old values saved o stack prior to usig Three maaged as caller-save %eax, %edx, %ecx Do what you please, but expect ay callee to do so, as well Register %eax also holds retur value Caller-Save Temporaries Callee-Save Temporaries Special 32 bits %eax %edx %ecx %ebx %esi %edi %ebp , F 17
6 Private Address Spaces Each process has its ow private address space. 0xffffffff 0xc kerel virtual memory (code, data, heap, stack) user stack (created at rutime) memory ivisible to user code (stack poiter) Warig: umbers specific to Liux 2.x o IA32!! 0x memory mapped regio for shared libraries ru-time heap (maaged by malloc) read/write segmets (.data,.bss) read-oly segmets (.iit,.text,.rodata) 0x uused , F 17 brk loaded from the executable file Warig: details vary by OS ad kerel versio!
7 IA32 Regio of memory maaged with stack disciplie Grows toward lower addresses Register idicates lowest stack address address of top elemet stack poiter Bottom Icreasig Addresses Poiter Grows Dow Top , F 17
8 IA32 Pushig Pushig pushl Src Fetch operad from Src Maybe a register: %ebp Maybe memory: 8(%ebp) Decremet by 4 Store operad i memory at address give by Bottom Icreasig Addresses Poiter -4 Grows Dow Top , F 17
9 IA32 Poppig Poppig popl Dest Read memory at address give by Icremet by 4 Store ito Dest operad Bottom Icreasig Addresses Poiter +4 Grows Dow Top , F 17
10 Operatio Examples pushl %eax popl %edx 0x110 0x110 0x110 0x10c 0x10c 0x10c 0x x x x x %eax 213 %eax 213 %eax 213 %edx 555 %edx 555 %edx x108 0x108 0x104 0x104 0x , F 17
11 Procedure Cotrol Flow Use stack to support procedure call ad retur Procedure call: call label Push retur address; Jump to label Retur address? Address of istructio after call Example from disassembly e:e8 3d call 8048b90 <mai> :50 pushl %eax» Retur address = 0x Procedure retur: ret Pop address from stack; Jump to address , F 17
12 Procedure Call Example e: e8 3d call 8048b90 <mai> : 50 pushl %eax call 8048b90 0x110 0x110 0x10c 0x10c 0x x x104 0x x108 0x108 0x104 %eip 0x804854e %eip 0x804854e 0x8048b90 %eip is program couter , F 17
13 Procedure Retur Example : c3 ret ret 0x110 0x110 0x10c 0x10c 0x x x104 0x x x104 0x104 0x108 %eip 0x %eip 0x x %eip is program couter , F 17
14 -Based Laguages Laguages that support recursio e.g., C, Pascal, Java Code must be reetrat Multiple istatiatios of a sigle procedure live at same time Need some place to store state of each istatiatio Argumets Local variables Retur poiter (maybe) Weird thigs (static liks, exceptio hadlig, ) disciplie key observatio State for give procedure eeded for limited time From time of call to time of retur Note: callee returs before caller does Therefore stack allocated i ested frames State for sigle procedure istatiatio , F 17
15 Call Chai Example Code Structure yoo( ) { who(); } who( ) { ami(); ami(); } Procedure ami() recursive ami( ) { ami(); } Call Chai yoo who ami ami ami ami , F 17
16 Frames Cotets Local variables Retur iformatio Temporary space Maagemet Poiters Space allocated whe eter procedure Set-up code Deallocated whe retur Fiish code poiter idicates stack top Frame poiter %ebp idicates start of curret frame yoo Frame Poiter %ebp Poiter who proc ami Top , F 17
17 IA32/Liux Frame Curret Frame ( Top to Bottom ) Parameters for fuctio we're about to call Argumet build Local variables If do't all fit i registers Caller's saved registers Caller's saved frame poiter Caller's Frame Retur address Pushed by call istructio Argumets for this call Caller Frame Frame Poiter (%ebp) Poiter () Argumets Retur Addr Old %ebp Saved Registers + Local Variables Argumet Build , F 17
18 swap() it zip1 = 15213; it zip2 = 91125; void call_swap() { swap(&zip1, &zip2); } Callig swap from call_swap call_swap: pushl $zip2 # Global var pushl $zip1 # Global var call swap void swap(it *xp, it *yp) { it t0 = *xp; it t1 = *yp; *xp = t1; *yp = t0; } &zip2 &zip1 Rt adr Resultig , F 17
19 swap() void swap(it *xp, it *yp) { it t0 = *xp; it t1 = *yp; *xp = t1; *yp = t0; } Core swap: pushl %ebp movl,%ebp pushl %ebx movl 12(%ebp),%ecx movl 8(%ebp),%edx movl (%ecx),%eax movl (%edx),%ebx movl %eax,(%edx) movl %ebx,(%ecx) Set Up Body movl -4(%ebp),%ebx movl %ebp, popl %ebp ret Fiish , F 17
20 swap() Setup Eterig %ebp &zip2 &zip1 Rt adr swap: pushl %ebp movl,%ebp pushl %ebx , F 17
21 swap() Setup #1 Eterig %ebp Resultig %ebp &zip2 &zip1 Rt adr yp xp Rt adr Old %ebp swap: pushl %ebp movl,%ebp pushl %ebx , F 17
22 swap() Setup #2 Eterig %ebp Resultig &zip2 &zip1 Rt adr swap: pushl %ebp movl,%ebp pushl %ebx yp xp Rt adr Old %ebp %ebp , F 17
23 swap() Setup #3 Eterig %ebp Resultig &zip2 &zip1 Rt adr swap: pushl %ebp movl,%ebp pushl %ebx Observatio yp xp Rt adr Old %ebp %ebp Old %ebx Savig caller s register %ebx , F 17
24 Effect of swap() Setup Eterig %ebp Offset (relative to %ebp) Resultig &zip2 &zip1 Rt adr 12 yp 8 xp 4 Rt adr 0 Old %ebp %ebp -4 Old %ebx movl 12(%ebp),%ecx # get yp movl 8(%ebp),%edx # get xp... Body , F 17
25 swap() Fiish #1 swap s Offset Observatio yp xp Rt adr 0 Old %ebp %ebp -4 Old %ebx Restorig caller s register %ebx Offset yp xp Rt adr 0 Old %ebp %ebp -4 Old %ebx movl -4(%ebp),%ebx movl %ebp, popl %ebp ret , F 17
26 swap() Fiish #2 swap s Offset yp xp Rt adr 0 Old %ebp %ebp -4 Old %ebx swap s Offset yp xp Rt adr 0 Old %ebp %ebp movl -4(%ebp),%ebx movl %ebp, popl %ebp ret , F 17
27 swap() Fiish #3 swap s Offset swap s Offset %ebp yp xp Rt adr 0 Old %ebp %ebp yp xp Rt adr movl -4(%ebp),%ebx movl %ebp, popl %ebp ret , F 17
28 swap() Fiish #4 swap s Offset yp xp Rt adr %ebp &zip2 &zip1 %ebp Exitig Observatio/query Saved & restored caller's register %ebx Did't do so for %eax, %ecx, or %edx! movl -4(%ebp),%ebx movl %ebp, popl %ebp ret , F 17
29 Register Savig Covetios Whe procedure yoo() calls who(): yoo() is the caller, who() is the callee Ca a register be used for temporary storage? yoo: movl $15213, %edx call who addl %edx, %eax ret who: movl 8(%ebp), %edx addl $91125, %edx ret Cotets of register %edx overwritte by who() , F 17
30 Register Savig Covetios Whe procedure yoo() calls who(): yoo() is the caller, who() is the callee Ca a register be used for temporary storage? Defiitios Caller Save register Caller saves temporary i its frame before callig Callee Save register Callee saves temporary i its frame before usig Covetios Which registers are caller-save, callee-save? , F 17
31 IA32/Liux Register Usage Iteger Registers Two have special uses %ebp, Three maaged as callee-save %ebx, %esi, %edi Old values saved o stack prior to usig Three maaged as caller-save %eax, %edx, %ecx Do what you please, but expect ay callee to do so, as well Register %eax also holds retur value Caller-Save Temporaries Callee-Save Temporaries Special 32 bits %eax %edx %ecx %ebx %esi %edi %ebp , F 17
32 Summary makes recursio work Private storage for each istace of procedure call Istatiatios do't clobber each other Addressig of locals + argumets ca be relative to stack positios Ca be maaged by stack disciplie Procedures retur i iverse order of calls IA32 procedures: istructios + covetios call / ret istructios mix %eip, i a fixed way Register usage covetios Caller / Callee save %ebp ad frame orgaizatio covetios Which argumet is pushed first , F 17
33 Before & After mai() it mai(it argc, char *argv[]) { if (argc > 1) { pritf( %s\, argv[1]); } else { char * av[3] = { 0, 0, 0 }; av[0] = argv[0]; av[1] = Fred ; execvp(av[0], av); } retur (0); } , F 17
34 The Mysterious Parts argc, argv Strigs from oe program Which part of the memory map are they i? How did they get there? What happes whe mai() does retur(0)??? There's o more program to ru...right? Where does the 0 go? How does it get there? 410 studets should seek to abolish mystery , F 17
35 The Mysterious Parts structure whe a ew program starts argc, argv, evp Come from the program that called execve Kerel copies strigs from old address space to ew 0xbffffa7c Null-termiated eviromet variable strigs Null-termiated commad-lie arg strigs evp[] == NULL evp[-1]... evp[0] argv[argc] = NULL argv[argc-1]... argv[0] evp argv argc retur address Future stack frame for mai Bottom of stack eviro Top of stack , F 17
36 The Mysterious Parts What happes whe mai() does retur(0)? Defied by C to have same effect as exit(0) But how?? , F 17
37 The Mysterious Parts What happes whe mai() does retur(0)? Defied by C to have same effect as exit(0) But how?? The mai() wrapper Receives argc, argv from OS Calls mai(), the calls exit() Provided by C library, traditioally i crt0.s Ofte has a strage ame /* ot actual code */ void mai(it argc, char *argv[]) { exit(mai(argc, argv, eviro)); } , F 17
38 Project 0 - Crawler C/Assembly fuctio Ca be called by ay C fuctio Prits stack frames i a symbolic way --- Trace Follows--- Fuctio fu3(c='c', d= ), i Fuctio fu2(f= ), i Fuctio fu1(cout=0), i Fuctio fu1(cout=1), i Fuctio fu1(cout=2), i , F 17
39 Project 0 - Crawler Coceptually easy Callig covetio specifies layout of stack is just memory - C happily lets you read & write Key questios How do I kow 0x is fu1? How do I kow fu3()'s secod parameter is called d? How do I kow whe to stop? , F 17
40 Project 0 Data Flow fu.c tb.c tb_globals.c symbol-table array may slots, blak , F 17
41 Project 0 Data Flow - Compilatio libtraceback.a fu.o tb.o tb_globals.o , F 17
42 Project 0 Data Flow - Likig fu fu.o tb.o tb_globals.o debugger ifo , F 17
43 Project 0 Data Flow - P0 Post-Likig fu mutate symtabge simplify fu.o tb.o tb_globals.o debugger ifo , F 17
44 Summary Review of stack kowledge What makes mai() special Project 0 overview Look for hadout this eveig Start iterviewig Project 2/3/4 parters! (visit ad select Web Asides ) , F 17
45 Movie Night Primer Thursday, August 29 th 19:30, GHC 4401 ( Rashid Auditorium ) $1 Pizza Preseted by #!/cmu/cc Fuded i part by your Studet Activities Fee , F 17
46 Upper 2 hex digits of address FF C0 BF 80 7F Red Hat v. 6.2 ~1920MB memory limit 40 3F Heap Shared Libraries Heap Data Text Liux Memory Layout Heap Rutime stack (8MB limit by default) Dyamically allocated storage Maaged by malloc(), calloc(), ew Shared/Dyamic Libraries aka Shared Objects Library routies (e.g., pritf(), malloc()) Liked ito object code whe first executed Widows has DLLs (sematic differeces) Data, BSS Statically allocated data (BSS starts all-zero) e.g., arrays & variables declared i code Text, RODATA Text - Executable machie istructios RODATA Read-oly (e.g., cost ) Strig literals , F 17
47 , F 17 Liux Memory Allocatio Loaded BF 7F 3F Libraries Text Data 08 Some Heap BF 7F 3F Libraries Text Data Heap 08 More Heap BF 7F 3F Libraries Text Data Heap Heap 08 ELF biary BF 7F 3F Text Data 08
Stack Discipline Jan. 19, 2018
15-410 An Experience Like No Other Discipline Jan. 19, 2018 Dave Eckhardt Brian Railing Slides originally stolen from 15-213 1 15-410, S 18 Synchronization Registration The wait list will probably be done
More informationAn Experience Like No Other. Stack Discipline Aug. 30, 2006
15-410 An Experience Like No Other Discipline Aug. 30, 2006 Bruce Maggs Dave Eckhardt Slides originally stolen from 15-213 15-410, F 06 Synchronization Registration If you're here but not registered, please
More informationASSEMBLY III: PROCEDURES. Jo, Heeseung
ASSEMBLY III: PROCEDURES Jo, Heeseung IA-32 STACK (1) Characteristics Region of memory managed with stack discipline Grows toward lower addresses Register indicates lowest stack address - address of top
More informationAssembly III: Procedures. Jo, Heeseung
Assembly III: Procedures Jo, Heeseung IA-32 Stack (1) Characteristics Region of memory managed with stack discipline Grows toward lower addresses Register indicates lowest stack address - address of top
More informationCS213. Machine-Level Programming III: Procedures
CS213 Machine-Level Programming III: Procedures Topics IA32 stack discipline Register saving conventions Creating pointers to local variables IA32 Region of memory managed with stack discipline Grows toward
More informationAssembly III: Procedures. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University
Assembly III: Procedures Jin-Soo Kim (jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu IA-32 (1) Characteristics Region of memory managed with stack discipline
More informationThe course that gives CMU its Zip! Machine-Level Programming III: Procedures Sept. 17, 2002
15-213 The course that gives CMU its Zip! Machine-Level Programming III: Procedures Sept. 17, 2002 Topics IA32 stack discipline Register saving conventions Creating pointers to local variables class07.ppt
More informationMachine-Level Programming III: Procedures
Machine-Level Programming III: Procedures IA32 Region of memory managed with stack discipline Grows toward lower addresses Register indicates lowest stack address address of top element Bottom Increasing
More informationMachine-level Programming (3)
Machine-level Programming (3) Procedures A: call A call A return Two issues How to return to the correct position? How to pass arguments and return values between callee to caller? 2 Procedure Control
More informationSystems I. Machine-Level Programming V: Procedures
Systems I Machine-Level Programming V: Procedures Topics abstraction and implementation IA32 stack discipline Procedural Memory Usage void swap(int *xp, int *yp) int t0 = *xp; int t1 = *yp; *xp = t1; *yp
More informationRegion of memory managed with stack discipline Grows toward lower addresses. Register %esp contains lowest stack address = address of top element
Machine Representa/on of Programs: Procedures Instructors: Sanjeev Se(a 1 IA32 Stack Region of memory managed with stack discipline Grows toward lower addresses Stack BoGom Increasing Addresses Register
More informationX86 Assembly -Procedure II:1
X86 Assembly -Procedure II:1 IA32 Object Code Setup Label.L61 becomes address 0x8048630 Label.L62 becomes address 0x80488dc Assembly Code switch_eg:... ja.l61 # if > goto default jmp *.L62(,%edx,4) # goto
More informationMachine Programming 3: Procedures
Machine Programming 3: Procedures CS61, Lecture 5 Prof. Stephen Chong September 15, 2011 Announcements Assignment 2 (Binary bomb) due next week If you haven t yet please create a VM to make sure the infrastructure
More informationIA32 Stack. Stack BoDom. Region of memory managed with stack discipline Grows toward lower addresses. Register %esp contains lowest stack address
IA32 Procedures 1 IA32 Stack Region of memory managed with stack discipline Grows toward lower addresses Stack BoDom Increasing Addresses Register contains lowest stack address address of top element Stack
More informationCS 11 C track: lecture 1
CS 11 C track: lecture 1 Prelimiaries Need a CMS cluster accout http://acctreq.cms.caltech.edu/cgi-bi/request.cgi Need to kow UNIX IMSS tutorial liked from track home page Track home page: http://courses.cms.caltech.edu/courses/cs11/material
More informationUniversity of Washington
Roadmap C: car *c = malloc(sizeof(car)); c->miles = 100; c->gals = 17; float mpg = get_mpg(c); free(c); Assembly language: Machine code: Computer system: get_mpg: pushq %rbp movq %rsp, %rbp... popq %rbp
More informationMachine- Level Programming III: Switch Statements and IA32 Procedures
Machine- Level Programming III: Switch Statements and IA32 Procedures CS 485: Systems Programming Fall 2015 Instructor: James Griffioen Adapted from slides by R. Bryant and D. O Hallaron (hjp://csapp.cs.cmu.edu/public/instructors.html)
More informationAssembly I: Basic Operations. Jo, Heeseung
Assembly I: Basic Operations Jo, Heeseung Moving Data (1) Moving data: movl source, dest Move 4-byte ("long") word Lots of these in typical code Operand types Immediate: constant integer data - Like C
More informationASSEMBLY I: BASIC OPERATIONS. Jo, Heeseung
ASSEMBLY I: BASIC OPERATIONS Jo, Heeseung MOVING DATA (1) Moving data: movl source, dest Move 4-byte ("long") word Lots of these in typical code Operand types Immediate: constant integer data - Like C
More informationSungkyunkwan University
Switch statements IA 32 Procedures Stack Structure Calling Conventions Illustrations of Recursion & Pointers long switch_eg (long x, long y, long z) { long w = 1; switch(x) { case 1: w = y*z; break; case
More informationAssembly Language: Function Calls
Assembly Language: Function Calls 1 Goals of this Lecture Help you learn: Function call problems: Calling and returning Passing parameters Storing local variables Handling registers without interference
More informationAssembly Language: Function Calls" Goals of this Lecture"
Assembly Language: Function Calls" 1 Goals of this Lecture" Help you learn:" Function call problems:" Calling and returning" Passing parameters" Storing local variables" Handling registers without interference"
More informationAssembly Language: Function Calls" Goals of this Lecture"
Assembly Language: Function Calls" 1 Goals of this Lecture" Help you learn:" Function call problems:" Calling and urning" Passing parameters" Storing local variables" Handling registers without interference"
More informationAssembly Language: Function Calls. Goals of this Lecture. Function Call Problems
Assembly Language: Function Calls 1 Goals of this Lecture Help you learn: Function call problems: Calling and urning Passing parameters Storing local variables Handling registers without interference Returning
More informationIA32 Stack The course that gives CMU its Zip! Machine-Level Programming III: Procedures Sept. 17, IA32 Stack Popping. IA32 Stack Pushing
15-213 The course that gives CMU its Zip! Machine-Level Programming III: Procedures Sept. 17, 2002 Topics IA32 stack discipline Register saving conventions Creating pointers to local variables IA32 Region
More informationTurning C into Object Code Code in files p1.c p2.c Compile with command: gcc -O p1.c p2.c -o p Use optimizations (-O) Put resulting binary in file p
Turning C into Object Code Code in files p1.c p2.c Compile with command: gcc -O p1.c p2.c -o p Use optimizations (-O) Put resulting binary in file p text C program (p1.c p2.c) Compiler (gcc -S) text Asm
More informationIA32 Stack. Lecture 5 Machine-Level Programming III: Procedures. IA32 Stack Popping. IA32 Stack Pushing. Topics. Pushing. Popping
Lecture 5 Machine-Level Programming III: Procedures Topics IA32 stack discipline Register saving conventions Creating pointers to local variables IA32 Region of memory managed with stack discipline Grows
More informationCS 31: Intro to Systems Functions and the Stack. Martin Gagne Swarthmore College February 23, 2016
CS 31: Intro to Systems Functions and the Stack Martin Gagne Swarthmore College February 23, 2016 Reminders Late policy: you do not have to send me an email to inform me of a late submission before the
More informationhnp://
The bots face off in a tournament against one another and about an equal number of humans, with each player trying to score points by elimina&ng its opponents. Each player also has a "judging gun" in addi&on
More informationAssembly I: Basic Operations. Computer Systems Laboratory Sungkyunkwan University
Assembly I: Basic Operations Jin-Soo Kim (jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Moving Data (1) Moving data: movl source, dest Move 4-byte ( long )
More informationGiving credit where credit is due
CSCE 230J Computer Organization Machine-Level Programming III: Procedures Dr. Steve Goddard goddard@cse.unl.edu Giving credit where credit is due Most of slides for this lecture are based on slides created
More informationFunction Calls COS 217. Reading: Chapter 4 of Programming From the Ground Up (available online from the course Web site)
Function Calls COS 217 Reading: Chapter 4 of Programming From the Ground Up (available online from the course Web site) 1 Goals of Today s Lecture Finishing introduction to assembly language o EFLAGS register
More informationProcedure Calls. Young W. Lim Mon. Young W. Lim Procedure Calls Mon 1 / 29
Procedure Calls Young W. Lim 2017-08-21 Mon Young W. Lim Procedure Calls 2017-08-21 Mon 1 / 29 Outline 1 Introduction Based on Stack Background Transferring Control Register Usage Conventions Procedure
More informationCOSC 1P03. Ch 7 Recursion. Introduction to Data Structures 8.1
COSC 1P03 Ch 7 Recursio Itroductio to Data Structures 8.1 COSC 1P03 Recursio Recursio I Mathematics factorial Fiboacci umbers defie ifiite set with fiite defiitio I Computer Sciece sytax rules fiite defiitio,
More informationCMSC Computer Architecture Lecture 3: ISA and Introduction to Microarchitecture. Prof. Yanjing Li University of Chicago
CMSC 22200 Computer Architecture Lecture 3: ISA ad Itroductio to Microarchitecture Prof. Yajig Li Uiversity of Chicago Lecture Outlie ISA uarch (hardware implemetatio of a ISA) Logic desig basics Sigle-cycle
More informationMachine- Level Programming III: Switch Statements and IA32 Procedures
Machine- Level Programming III: Switch Statements and IA32 Procedures 15-213: Introduc;on to Computer Systems 6 th Lecture, Sep. 9, 2010 Instructors: Randy Bryant and Dave O Hallaron Today Switch statements
More informationProcedure Calls. Young W. Lim Sat. Young W. Lim Procedure Calls Sat 1 / 27
Procedure Calls Young W. Lim 2016-11-05 Sat Young W. Lim Procedure Calls 2016-11-05 Sat 1 / 27 Outline 1 Introduction References Stack Background Transferring Control Register Usage Conventions Procedure
More informationMachine-Level Programming I: Introduction Jan. 30, 2001
15-213 Machine-Level Programming I: Introduction Jan. 30, 2001 Topics Assembly Programmer s Execution Model Accessing Information Registers Memory Arithmetic operations IA32 Processors Totally Dominate
More informationCISC 360. Machine-Level Programming I: Introduction Sept. 18, 2008
CISC 360 Machine-Level Programming I: Introduction Sept. 18, 2008 Topics Assembly Programmerʼs Execution Model Accessing Information Registers Memory Arithmetic operations IA32 Processors Totally Dominate
More informationRecursion. Computer Science S-111 Harvard University David G. Sullivan, Ph.D. Review: Method Frames
Uit 4, Part 3 Recursio Computer Sciece S-111 Harvard Uiversity David G. Sulliva, Ph.D. Review: Method Frames Whe you make a method call, the Java rutime sets aside a block of memory kow as the frame of
More informationMachine Programming 1: Introduction
Machine Programming 1: Introduction CS61, Lecture 3 Prof. Stephen Chong September 8, 2011 Announcements (1/2) Assignment 1 due Tuesday Please fill in survey by 5pm today! Assignment 2 will be released
More informationCS241 Computer Organization Spring 2015 IA
CS241 Computer Organization Spring 2015 IA-32 2-10 2015 Outline! Review HW#3 and Quiz#1! More on Assembly (IA32) move instruction (mov) memory address computation arithmetic & logic instructions (add,
More informationPage # CISC 360. Machine-Level Programming I: Introduction Sept. 18, IA32 Processors. X86 Evolution: Programmerʼs View.
Machine-Level Programming I: Introduction Sept. 18, 2008 Topics CISC 360 Assembly Programmerʼs Execution Model Accessing Information Registers Memory Arithmetic operations IA32 Processors Totally Dominate
More informationCSE 351: Week 4. Tom Bergan, TA
CSE 35 Week 4 Tom Bergan, TA Does this code look okay? int binarysearch(int a[], int length, int key) { int low = 0; int high = length - ; while (low
More informationx86 assembly CS449 Fall 2017
x86 assembly CS449 Fall 2017 x86 is a CISC CISC (Complex Instruction Set Computer) e.g. x86 Hundreds of (complex) instructions Only a handful of registers RISC (Reduced Instruction Set Computer) e.g. MIPS
More informationX86 Stack Calling Function POV
X86 Stack Calling Function POV Computer Systems Section 3.7 Stack Frame Reg Value ebp xffff FFF0 esp xffff FFE0 eax x0000 000E Memory Address Value xffff FFF8 xffff FFF4 x0000 0004 xffff FFF4 x0000 0003
More information1 /* file cpuid2.s */ 4.asciz "The processor Vendor ID is %s \n" 5.section.bss. 6.lcomm buffer, section.text. 8.globl _start.
1 /* file cpuid2.s */ 2.section.data 3 output: 4.asciz "The processor Vendor ID is %s \n" 5.section.bss 6.lcomm buffer, 12 7.section.text 8.globl _start 9 _start: 10 movl $0, %eax 11 cpuid 12 movl $buffer,
More informationPython Programming: An Introduction to Computer Science
Pytho Programmig: A Itroductio to Computer Sciece Chapter 1 Computers ad Programs 1 Objectives To uderstad the respective roles of hardware ad software i a computig system. To lear what computer scietists
More informationAssembly Programmer s View Lecture 4A Machine-Level Programming I: Introduction
Assembly Programmer s View Lecture 4A Machine-Level Programming I: Introduction E I P CPU isters Condition Codes Addresses Data Instructions Memory Object Code Program Data OS Data Topics Assembly Programmer
More informationCMSC 313 Lecture 12. Project 3 Questions. How C functions pass parameters. UMBC, CMSC313, Richard Chang
Project 3 Questions CMSC 313 Lecture 12 How C functions pass parameters UMBC, CMSC313, Richard Chang Last Time Stack Instructions: PUSH, POP PUSH adds an item to the top of the stack POP
More informationCMSC Computer Architecture Lecture 12: Virtual Memory. Prof. Yanjing Li University of Chicago
CMSC 22200 Computer Architecture Lecture 12: Virtual Memory Prof. Yajig Li Uiversity of Chicago A System with Physical Memory Oly Examples: most Cray machies early PCs Memory early all embedded systems
More informationPython Programming: An Introduction to Computer Science
Pytho Programmig: A Itroductio to Computer Sciece Chapter 6 Defiig Fuctios Pytho Programmig, 2/e 1 Objectives To uderstad why programmers divide programs up ito sets of cooperatig fuctios. To be able to
More informationExceptions. Your computer takes exception. The Exception Class. Causes of Exceptions
Your computer takes exceptio s s are errors i the logic of a program (ru-time errors). Examples: i thread mai java.io.filenotfoud: studet.txt (The system caot fid the file specified.) i thread mai java.lag.nullpoiter:
More informationThe course that gives CMU its Zip! Machine-Level Programming I: Introduction Sept. 10, 2002
15-213 The course that gives CMU its Zip! Machine-Level Programming I: Introduction Sept. 10, 2002 Topics Assembly Programmer s Execution Model Accessing Information Registers Memory Arithmetic operations
More informationn Some thoughts on software development n The idea of a calculator n Using a grammar n Expression evaluation n Program organization n Analysis
Overview Chapter 6 Writig a Program Bjare Stroustrup Some thoughts o software developmet The idea of a calculator Usig a grammar Expressio evaluatio Program orgaizatio www.stroustrup.com/programmig 3 Buildig
More informationCS241 Computer Organization Spring Addresses & Pointers
CS241 Computer Organization Spring 2015 Addresses & Pointers 2-24 2015 Outline! Addresses & Pointers! leal - load effective address! Condition Codes & Jumps! conditional statements: if-then-else! conditional
More informationCSC 220: Computer Organization Unit 11 Basic Computer Organization and Design
College of Computer ad Iformatio Scieces Departmet of Computer Sciece CSC 220: Computer Orgaizatio Uit 11 Basic Computer Orgaizatio ad Desig 1 For the rest of the semester, we ll focus o computer architecture:
More informationtop() Applications of Stacks
CS22 Algorithms ad Data Structures MW :00 am - 2: pm, MSEC 0 Istructor: Xiao Qi Lecture 6: Stacks ad Queues Aoucemets Quiz results Homework 2 is available Due o September 29 th, 2004 www.cs.mt.edu~xqicoursescs22
More informationInstruction Set Architecture
CS:APP Chapter 4 Computer Architecture Instruction Set Architecture Randal E. Bryant Carnegie Mellon University http://csapp.cs.cmu.edu CS:APP Instruction Set Architecture Assembly Language View Processor
More informationCMSC 313 Lecture 12 [draft] How C functions pass parameters
CMSC 313 Lecture 12 [draft] How C functions pass parameters UMBC, CMSC313, Richard Chang Last Time Stack Instructions: PUSH, POP PUSH adds an item to the top of the stack POP removes an
More informationMACHINE-LEVEL PROGRAMMING I: BASICS COMPUTER ARCHITECTURE AND ORGANIZATION
MACHINE-LEVEL PROGRAMMING I: BASICS COMPUTER ARCHITECTURE AND ORGANIZATION Today: Machine Programming I: Basics History of Intel processors and architectures C, assembly, machine code Assembly Basics:
More informationInstruction Set Architecture
CS:APP Chapter 4 Computer Architecture Instruction Set Architecture Randal E. Bryant Carnegie Mellon University http://csapp.cs.cmu.edu CS:APP Instruction Set Architecture Assembly Language View! Processor
More informationThreads and Concurrency in Java: Part 1
Cocurrecy Threads ad Cocurrecy i Java: Part 1 What every computer egieer eeds to kow about cocurrecy: Cocurrecy is to utraied programmers as matches are to small childre. It is all too easy to get bured.
More informationTHEORY OF COMPILATION
Lecture 10 Activation Records THEORY OF COMPILATION EranYahav www.cs.technion.ac.il/~yahave/tocs2011/compilers-lec10.pptx Reference: Dragon 7.1,7.2. MCD 6.3,6.4.2 1 You are here Compiler txt Source Lexical
More informationThreads and Concurrency in Java: Part 1
Threads ad Cocurrecy i Java: Part 1 1 Cocurrecy What every computer egieer eeds to kow about cocurrecy: Cocurrecy is to utraied programmers as matches are to small childre. It is all too easy to get bured.
More informationOverview. Chapter 18 Vectors and Arrays. Reminder. vector. Bjarne Stroustrup
Chapter 18 Vectors ad Arrays Bjare Stroustrup Vector revisited How are they implemeted? Poiters ad free store Destructors Iitializatio Copy ad move Arrays Array ad poiter problems Chagig size Templates
More informationIA32 Processors The course that gives CMU its Zip! Machine-Level Programming I: Introduction Sept. 10, X86 Evolution: Programmer s View
Machine-Level Programming I: Introduction Sept. 10, 2002 class05.ppt 15-213 The course that gives CMU its Zip! Topics Assembly Programmer s Execution Model Accessing Information Registers Memory Arithmetic
More informationCOP4020 Programming Languages. Compilers and Interpreters Prof. Robert van Engelen
COP4020 mig Laguages Compilers ad Iterpreters Prof. Robert va Egele Overview Commo compiler ad iterpreter cofiguratios Virtual machies Itegrated developmet eviromets Compiler phases Lexical aalysis Sytax
More information! Starting in 1978 with ! Added more features as time goes on. ! Still support old features, although obsolete
Machine-Level Programming I: Introduction Sept. 10, 2002 class05.ppt 15-213 The course that gives CMU its Zip! Topics! Assembly Programmer s Execution Model! Accessing Information " Registers " Memory!
More informationPage 1. IA32 Stack CISC 360. Machine-Level Programming III: Procedures Sept. 22, IA32 Stack Popping Stack Bottom. IA32 Stack Pushing
CISC 36 Machine-Level Programming III: Procedures Sept. 22, 2 IA32 Region of memory managed with stack discipline Grows toward lower addresses Register indicates lowest stack address address of top element
More informationChapter 9. Pointers and Dynamic Arrays. Copyright 2015 Pearson Education, Ltd.. All rights reserved.
Chapter 9 Poiters ad Dyamic Arrays Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Overview 9.1 Poiters 9.2 Dyamic Arrays Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Slide 9-3
More informationCOP4020 Programming Languages. Subroutines and Parameter Passing Prof. Robert van Engelen
COP4020 Programmig Laguages Subrouties ad Parameter Passig Prof. Robert va Egele Overview Parameter passig modes Subroutie closures as parameters Special-purpose parameters Fuctio returs COP4020 Fall 2016
More informationCS 111: Program Design I Lecture # 7: First Loop, Web Crawler, Functions
CS 111: Program Desig I Lecture # 7: First Loop, Web Crawler, Fuctios Robert H. Sloa & Richard Warer Uiversity of Illiois at Chicago September 18, 2018 What will this prit? x = 5 if x == 3: prit("hi!")
More informationBasic allocator mechanisms The course that gives CMU its Zip! Memory Management II: Dynamic Storage Allocation Mar 6, 2000.
5-23 The course that gives CM its Zip Memory Maagemet II: Dyamic Storage Allocatio Mar 6, 2000 Topics Segregated lists Buddy system Garbage collectio Mark ad Sweep Copyig eferece coutig Basic allocator
More informationThe Hardware/Software Interface CSE351 Spring 2015
The Hardware/Software Interface CSE351 Spring 2015 Lecture 7 Instructor: Katelin Bailey Teaching Assistants: Kaleo Brandt, Dylan Johnson, Luke Nelson, Alfian Rizqi, Kritin Vij, David Wong, and Shan Yang
More informationChapter 11. Friends, Overloaded Operators, and Arrays in Classes. Copyright 2014 Pearson Addison-Wesley. All rights reserved.
Chapter 11 Frieds, Overloaded Operators, ad Arrays i Classes Copyright 2014 Pearso Addiso-Wesley. All rights reserved. Overview 11.1 Fried Fuctios 11.2 Overloadig Operators 11.3 Arrays ad Classes 11.4
More informationCMPT 125 Assignment 2 Solutions
CMPT 25 Assigmet 2 Solutios Questio (20 marks total) a) Let s cosider a iteger array of size 0. (0 marks, each part is 2 marks) it a[0]; I. How would you assig a poiter, called pa, to store the address
More informationMachine- level Programming
Machine- level Programming Topics Assembly Programmer s Execu:on Model Accessing Informa:on Registers Memory Arithme:c opera:ons 1! Evolu:onary Design Star:ng in 1978 with 8086 IA32 Processors Added more
More informationCISC 360 Instruction Set Architecture
CISC 360 Instruction Set Architecture Michela Taufer October 9, 2008 Powerpoint Lecture Notes for Computer Systems: A Programmer's Perspective, R. Bryant and D. O'Hallaron, Prentice Hall, 2003 Chapter
More informationCS429: Computer Organization and Architecture
CS429: Computer Organization and Architecture Warren Hunt, Jr. and Bill Young Department of Computer Sciences University of Texas at Austin Last updated: October 1, 2014 at 12:03 CS429 Slideset 6: 1 Topics
More informationCSC 2400: Computing Systems. X86 Assembly: Function Calls"
CSC 24: Computing Systems X86 Assembly: Function Calls" 1 Lecture Goals! Challenges of supporting functions" Providing information for the called function" Function arguments and local variables" Allowing
More informationLecture 1: Introduction and Strassen s Algorithm
5-750: Graduate Algorithms Jauary 7, 08 Lecture : Itroductio ad Strasse s Algorithm Lecturer: Gary Miller Scribe: Robert Parker Itroductio Machie models I this class, we will primarily use the Radom Access
More informationY86 Processor State. Instruction Example. Encoding Registers. Lecture 7A. Computer Architecture I Instruction Set Architecture Assembly Language View
Computer Architecture I Instruction Set Architecture Assembly Language View Processor state Registers, memory, Instructions addl, movl, andl, How instructions are encoded as bytes Layer of Abstraction
More informationUniversity*of*Washington*
Roadmap* C:* car *c = malloc(sizeof(car)); c->miles = 100; c->gals = 17; float mpg = get_mpg(c); free(c); Assembly* language:* Machine* code:* Computer* system:* get_mpg: pushq movq... popq %rbp %rsp,
More informationInstruction Set Architecture
CISC 360 Instruction Set Architecture Michela Taufer October 9, 2008 Powerpoint Lecture Notes for Computer Systems: A Programmer's Perspective, R. Bryant and D. O'Hallaron, Prentice Hall, 2003 Chapter
More informationx86 Assembly Tutorial COS 318: Fall 2017
x86 Assembly Tutorial COS 318: Fall 2017 Project 1 Schedule Design Review: Monday 9/25 Sign up for 10-min slot from 3:00pm to 7:00pm Complete set up and answer posted questions (Official) Precept: Monday
More informationMachine-Level Programming Introduction
Machine-Level Programming Introduction Today Assembly programmer s exec model Accessing information Arithmetic operations Next time More of the same Fabián E. Bustamante, Spring 2007 IA32 Processors Totally
More informationChapter 1. Introduction to Computers and C++ Programming. Copyright 2015 Pearson Education, Ltd.. All rights reserved.
Chapter 1 Itroductio to Computers ad C++ Programmig Copyright 2015 Pearso Educatio, Ltd.. All rights reserved. Overview 1.1 Computer Systems 1.2 Programmig ad Problem Solvig 1.3 Itroductio to C++ 1.4 Testig
More informationCS 33: Week 3 Discussion. x86 Assembly (v1.0) Section 1G
CS 33: Week 3 Discussion x86 Assembly (v1.0) Section 1G Announcements - HW2 due Sunday - MT1 this Thursday! - Lab2 out Info Name: Eric Kim (Section 1G, 2-4 PM, BH 5419) Office Hours (Boelter 2432) - Wed
More informationCIS 121 Data Structures and Algorithms with Java Spring Stacks and Queues Monday, February 12 / Tuesday, February 13
CIS Data Structures ad Algorithms with Java Sprig 08 Stacks ad Queues Moday, February / Tuesday, February Learig Goals Durig this lab, you will: Review stacks ad queues. Lear amortized ruig time aalysis
More informationProcess Layout and Function Calls
Process Layout and Function Calls CS 6 Spring 07 / 8 Process Layout in Memory Stack grows towards decreasing addresses. is initialized at run-time. Heap grow towards increasing addresses. is initialized
More information10/23/18. File class in Java. Scanner reminder. Files. Opening a file for reading. Scanner reminder. File Input and Output
File class i Java File Iput ad Output TOPICS File Iput Exceptio Hadlig File Output Programmers refer to iput/output as "I/O". The File class represets files as objects. The class is defied i the java.io
More informationX86 Assembly -Data II:1
X86 Assembly -Data II:1 Administrivia HW1 due tonight Paper to locker, file to blackboard Lab1 Check scoreboard Quiz0 Remind me if you don t see in the lecture slide online Reading: chapter 3 now! II:2
More informationChapter 4 The Datapath
The Ageda Chapter 4 The Datapath Based o slides McGraw-Hill Additioal material 24/25/26 Lewis/Marti Additioal material 28 Roth Additioal material 2 Taylor Additioal material 2 Farmer Tae the elemets that
More informationLecture 5: Recursion. Recursion Overview. Recursion is a powerful technique for specifying funclons, sets, and programs
CS/ENGRD 20 Object- Orieted Programmig ad Data Structures Sprig 202 Doug James Visual Recursio Lecture : Recursio http://seredip.brymawr.edu/exchage/files/authors/faculty/39/literarykids/ifiite_mirror.jpg!
More informationData Representa/ons: IA32 + x86-64
X86-64 Instruc/on Set Architecture Instructor: Sanjeev Se(a 1 Data Representa/ons: IA32 + x86-64 Sizes of C Objects (in Bytes) C Data Type Typical 32- bit Intel IA32 x86-64 unsigned 4 4 4 int 4 4 4 long
More informationMorgan Kaufmann Publishers 26 February, COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface. Chapter 5.
Morga Kaufma Publishers 26 February, 208 COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Iterface 5 th Editio Chapter 5 Virtual Memory Review: The Memory Hierarchy Take advatage of the priciple
More informationCSC 2400: Computing Systems. X86 Assembly: Function Calls
CSC 24: Computing Systems X86 Assembly: Function Calls 1 Lecture Goals Challenges of supporting functions Providing information for the called function Function arguments and local variables Allowing the
More informationimplement language system
Outlie Priciples of programmig laguages Lecture 3 http://few.vu.l/~silvis/ppl/2007 Part I. Laguage systems Part II. Fuctioal programmig. First look at ML. Natalia Silvis-Cividjia e-mail: silvis@few.vu.l
More informationEnd Semester Examination CSE, III Yr. (I Sem), 30002: Computer Organization
Ed Semester Examiatio 2013-14 CSE, III Yr. (I Sem), 30002: Computer Orgaizatio Istructios: GROUP -A 1. Write the questio paper group (A, B, C, D), o frot page top of aswer book, as per what is metioed
More information