26 Pages

lecture27

Course: CSC 246, Fall 2008
School: N.C. State
Rating:
 
 
 
 
 

Word Count: 1185

Document Preview

Conventions October Procedure-Calling 30 CSC201 Section 002 Fall, 2000 Saving registers Registers are inevitably used by subroutines; changes their value! Registers have global scope; calling procedures also use their contents Conclusion: somebody needs to save registers before the subroutine executes, and restore values afterwards CSC201 Section Copyright 2000, Douglas Reeves 2 Approaches...

Register Now

Unformatted Document Excerpt

Coursehero >> North Carolina >> N.C. State >> CSC 246

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.
Conventions October Procedure-Calling 30 CSC201 Section 002 Fall, 2000 Saving registers Registers are inevitably used by subroutines; changes their value! Registers have global scope; calling procedures also use their contents Conclusion: somebody needs to save registers before the subroutine executes, and restore values afterwards CSC201 Section Copyright 2000, Douglas Reeves 2 Approaches "Caller saves" model caller saves/restores just the registers that it knows have important values "Callee saves" model callee saves just the registers that it knows it will modify "Hybrid" model callee saves / restores the registers it modifies that are "important" to the caller Our convention: "callee saves" model CSC201 Section Copyright 2000, Douglas Reeves 3 Example of Callee Saves main: . call upcase nextinstruction: upcase proc push EAX ; save EAX value get_ch add AL, 23 put_ch pop EAX ; restore EAX value ret upcase endp CSC201 Section Copyright 2000, Douglas Reeves 4 Just after the push EAX and before the get_ch popping ESP Saved Value of EAX Address of nextinstr uction The stack pushing 5 CSC201 Section Copyright 2000, Douglas Reeves Passing Input Parameters and Return Values Registers are global variables; not a great idea to use for this purpose Better choice: the stack Before calling the procedure allocate room on the stack for the return value Push a copy of the input parameter values on the stack Some parameters are modified by the procedure as part of its output In this case, push the parameter *address* instead of its value Procedure can modify the parameter using indirect addressing CSC201 Section Copyright 2000, Douglas Reeves 6 Parameter Passing (cont.) Callee reads parameter values on stack, using based-displacement addressing EBP = based register Before using EBP, must save its value and restore it on exit! CSC201 Section Copyright 2000, Douglas Reeves 7 "Cleaning Up" the Stack After calling a procedure and returning, the stack should look just like it did before the call The callee must 1. Deallocate memory it allocated 2. Pop saved register values from the stack 3. Pop the return address What about input parameters and the return value? "callee" can deallocate input parameters with "ret x" statement "x" = # of bytes to deallocate (i.e., value to add to ESP) CSC201 Section only "caller" can deallocate the return value, after copying Copyright 2000, Douglas Reeves 8 Example Specification for a procedure: Write a procedure to read up to n characters from the standard input. Each alphabetic character is mapped to upper case and ouput. Stop when anything other than a lower-case alphabetic character is read, and return to the caller the number of lower case characters read and mapped to upper case. CSC201 Section Copyright 2000, Douglas Reeves 9 Activation record for procedure upcase EBP Saved old EBP value Return address Storage for local variables of upcase would go here EBP-8 Saved old ECX value Saved old EAX value EBP+4 EBP+8 Input paramet er Space for return value EBP-4 EBP+12 CSC201 Section Copyright 2000, Douglas Reeves The stack 10 main: ESP, 4 ; allocate 4 bytes ; for the return value mov maxch, 12 push maxch ; maximum number ; of characters to map call upcase nextinstruction: pop nummap ; get return value + de; allocate return val. space . sub CSC201 Section Copyright 2000, Douglas Reeves 11 Just after call to upcase ESP Address of nextinstr uction 12 Space for return value CSC201 Section Copyright 2000, Douglas Reeves The stack 12 upcase proc push mov push push mov loop1: cmp je get_ch cmp jl cmp jg add put_ch inc jmp endup: mov pop pop pop ret CSC201 Section EBP EBP, ESP EAX ; save EAX value ECX ECX, 0 ECX, [EBP+8] endup AL, a endup AL, z endup AL, 23 ECX loop1 [EBP+12], ECX ECX EAX ; restore EAX value ; EBP restore EBP value 4 ; deallocate input ; parameter space Copyright 2000, Douglas Reeves upcase endp 13 Just before loop1 EBP Saved old EBP value Address of nextinstr uction 12 EBP+12 Space for return value CSC201 Section Copyright 2000, Douglas Reeves EBP+4 ESP EBP+8 EBP-4 Saved old ECX value Saved old EAX value The stack 14 Just before ret 4 (assuming 6 characters mapped to upper case) ESP Address of nextinstr uction 12 6 The stack CSC201 Section Copyright 2000, Douglas Reeves 15 Just after ret 4 ESP 6 The stack CSC201 Section Copyright 2000, Douglas Reeves 16 Procedure Checklist 1. Caller allocates space for return value 2. Caller copies input parameters to stack using push 3. "call" statement 4. Callee pushes EBP 5. Caller copies ESP to EBP 6. Caller saves registers it will modify 7. Caller allocates space for local variables 8. --Body of procedure executes-CSC201 Section Copyright 2000, Douglas Reeves 17 Programming Checklist (cont.) 9. Callee copies result into return variable space 10. Callee deallocates space for local variables 11. Callee restores registers, pops off stack 12. Callee restores EBP, pops off stack 13. Callee returns, deallocates input parameters from stack 14. Caller copies return value 15. Caller deallocates space for return value CSC201 Section Copyright 2000, Douglas Reeves 18 Using Registers, Instead How would the above example change if the procedure didnt call any other procedure (no nesting)? + we used registers to hold input parameters? + we used a register to hold the return value? + the procedure used registers for all local variables? A lot simpler! If only we had enough registers... CSC201 Section Copyright 2000, Douglas Reeves 19 Example, Using Registers main: EDX, 12 upcase nummap, ECX ; value of ECX was ; changed by procedure nextinstruction: . mov call mov CSC201 Section Copyright 2000, Douglas Reeves 20 upcase proc push mov loop1: cmp je get_ch cmp jl cmp jg add put_ch inc jmp endup: pop ret upcase endp EAX ; save EAX value ECX, 0 ECX, EDX endup AL, a endup AL, z endup AL, 23 ECX loop1 EAX ; restore EAX value CSC201 Section Copyright 2000, Douglas Reeves 21 Recursion Procedure calling itself! Traversing a tree, divide and conquer algorithms, etc. Example in C: Int f, a; a = 10; f = factorial(a); factorial(int a) int b; if (a == 1) return(1); e...

Find millions of documents on Course Hero - Study Guides, Lecture Notes, Reference Materials, Practice Exams and more. Course Hero has millions of course specific materials providing students with the best way to expand their education.

Below is a small sample set of documents:

N.C. State - CSC - 246
Machine Code and AssemblersNovember 6CSC201 Section 002 Fall, 2000Definitions Assembly time vs. link time vs. load time vs. run time.C file compiler .ASM file assembler .OBJ file linker .EXE file Loader (O.S.) Running programCSC201 SectionCo
N.C. State - CSC - 246
Machine Code (cont.)November 8CSC201 Section 002 Fall, 2000Instruction Encoding Instructions = 1 to 9 bytes long First byte = Opcode, or Opcode+Reg Second byte (if needed) = the ModRegR/M byte Mod = 2 bits Reg = 3 bits R/M = 3 bits Third
N.C. State - CSC - 246
Address Resolution and LinkingNovember 10CSC201 Section 002 Fall, 2000LST (listing) File Generated by _ option to ml.exe (change the make file) Contains _ _ __ _ _ _ (see hw3a.lst)CSC201 SectionCopyright 2000, Douglas Reeves2_
N.C. State - CSC - 246
Loading and BootstrappingNovember 13CSC201 Section 002 Fall, 2000Loading a Program for Execution This is managed by the operating system (O.S.)1. Allocate memory for the program 2. Copy the data, stack, and code into memory Adjust operand a
N.C. State - CSC - 246
Exceptions and InterruptsNovember 15CSC201 Section 002 Fall, 2000Concepts from Operating Systems Many services are provided automatically to programs Some services must be requested explicitly, via a subroutine call Tasks, or processes Stat
N.C. State - CSC - 246
Exceptions and Interrupts (continued)November 17CSC201 Section 002 Fall, 2000Device Priorities Some devices are More important than others Or, need attention more quickly Low-priority interrupts should not be able to interrupt ISRs for high
N.C. State - CSC - 246
Input / OutputNovember 27CSC201 Section 002 Fall, 2000Why Study? Device drivers are an essential part of operating systems Drivers impact performance of I/O Drivers impact what devices can be usedCSC201 SectionCopyright 2000, Douglas Reev
N.C. State - CSC - 246
I/O Controllers and InterfacingNovember 27CSC201 Section 002 Fall, 2000Definitions Interface = a set of registers that allow CPU and device to exchange information Controller manages a device and handles bus access for the device Device drive
N.C. State - CSC - 246
I/O External Serial Interfaces, and TimersDecember 01CSC201 Section 002 Fall, 2000Codes ASCII - only uses 128 out of 256 (28) different values extensions to ASCII (specifying the other 128 characters) Unicode 16 bit characters; no multibyte
N.C. State - CSC - 246
Improving System Performance: CachesDecember 04CSC201 Section 002 Fall, 2000A Motivating Example Application: making a (mechanical) clock dozens of tools and pages of instructions, hundreds of parts / materials Current work: whats in hand Te
N.C. State - CSC - 246
Improving System Performance: PipeliningDecember 08CSC201 Section 002 Fall, 2000Goals Speed up the rate at which instructions are executed faster computers! Does *not* speed up the time to complete one instructionCSC201 SectionCopyright
N.C. State - CSC - 246
CSC201, Section 002,Fall 2000: HW#1file:/C:/Reeves/My%20Stuff/website-new/Classes/csc246-.CSC201, SECTION 002, Fall 2000: Homework Assignment #1DUE DATEMonday, September 11, at the start of class.INSTRUCTIONS FOR PREPARATIONNeat, in order, a
N.C. State - CSC - 246
CSC201, Section 002,Fall 2000: HW#2file:/C:/Reeves/My%20Stuff/website-new/Classes/csc246-.CSC201, SECTION 002, Fall 2000: Homework Assignment #2DUE DATEMonday, October 2, at the start of class.INSTRUCTIONS FOR PREPARATIONNeat, in order, answ
N.C. State - CSC - 246
CSC201, Section 002,Fall 2000: HW#3file:/C:/Reeves/My%20Stuff/website-new/Classes/csc246-.CSC201, SECTION 002, Fall 2000: Homework Assignment #3DUE DATEOctober 25 for the homework problems, in class. October 27 for the programs, in class.INST
N.C. State - CSC - 246
CSC201, Section 002,Fall 2000: HW#4 Problemsfile:/C:/Reeves/My%20Stuff/website-new/Classes/csc246-.CSC201, SECTION 002, Fall 2000: Homework Assignment #4 ProblemsDUE DATENovember 15 for the homework problems, in class.INSTRUCTIONS FOR HOMEWOR
N.C. State - CSC - 246
CSC201, Section 002,Fall 2000: HW#4file:/C:/Reeves/My%20Stuff/website-new/Classes/csc246-.CSC201, SECTION 002, Fall 2000: Homework Assignment #4 Program(Note: the homework problem descriptions are in a separate part of this assignment.)DUE DAT
N.C. State - CSC - 246
CSC201, Section 002,Fall 2000: HW#5 Problemsfile:/C:/Reeves/My%20Stuff/website-new/Classes/csc246-.CSC201, SECTION 002, Fall 2000: Homework Assignment #5 ProblemsDUE DATEDecember 6 for the homework problems, in class.INSTRUCTIONS FOR HOMEWORK
N.C. State - CSC - 246
CSC201, Section 002, Fall 2000: Exam #3file:/C:/Reeves/My%20Stuff/website-new/Classes/csc246-.message "Character = x", using the following data definitions.msg1 char1 db db "Character = ? ", 05. (4 points) Write the Pentium code to multiply th
N.C. State - CSC - 246
CSC201, Section 002, Fall 2000: Exam #4file:/C:/Reeves/My%20Stuff/website-new/Classes/csc246-.CSC201, Section 002 EXAM #4 November 20, 2000Name: _ Student ID __ Number: (Also fold your paper lengthwise and write your name on the outside before t
N.C. State - A - 1
Environmental Stewardship and Streamlining: Fact or Fiction2005 Joint TRB Summer MeetingNative American Transportation Issues Committee (ABE80), Environmental Analysis in Transportation Committee (ADC10), and Historic and Archaeological Preservatio
N.C. State - A - 1
Environmental Stewardship and Streamlining: Fact or Fiction Preliminary Program 2005 Joint TRB Summer MeetingNative American Transportation Issues Committee (ABE80), Environmental Analysis in Transportation Committee (ADC10), and Historic and Archae
N.C. State - A - 1
N.C. State - A - 1
N.C. State - E - 115
< HTML>BODYdene the document header background = URL bgcolor = color dene the document titleQUIC K REFERENCEdene the document bodyDocument TagsHTMLdene the beginning and end of the HTML document <HTML>content</HTML> <html>content</html>
N.C. State - ARE - 201005
College Aint High School!Whats The Difference? Class Attendance? Faculty Expectations?The High School Syndrome1. Go to class 2. Rarely crack a book 3. Take tests 4. Pass courses 5. Graduate 6. Hard to flunk out of High SchoolRx for Success in t
N.C. State - CONF - 2005
Assessing Administrative and Support AreasEphraim Schechter, Ph.D. NC State University Undergraduate Assessment Symposium April 14-16, 2005Session ObjectivesYes Ways to think about outcomes assessment in administrative & support areas Applicat
N.C. State - CONF - 2005
ResourcesAssessing Administrative and Support AreasE. Schechter NC State Undergraduate Assessment Symposium, April14-16, 2005 Peter Ewell (2002). An emerging scholarship: A brief history of assessment. In Trudy W. Banta & Associates, Building a Sc
N.C. State - CSC - 557
Digital Audio CompressionBy Davis Yen Panbegins with a summary of the basic audio digitization process. The next two sections present detailed descriptions of two relatively simple approaches to audio compression: -law and adaptive differential pul
N.C. State - CSC - 557
Introduction to IP Multicast Routingby Chuck Semeria and Tom MauferAbstractThe first part of this paper describes the benefits of multicasting, the Multicast Backbone (MBONE), Class D addressing, and the operation of the Internet Group Management
N.C. State - CSC - 557
The key elements in DVMRP routing table include the following items: Source Subnet Subnet Mask From-Gateway TTL A subnetwork containing a host sourcing multicast datagrams. The subnet mask assigned to the Source Subnet. Note that the DVMRP provides t
N.C. State - CSC - 557
Operating SystemAn Overview of Inter-Domain Multicast RoutingWhite PaperAbstract Multicast routing is used to distribute data to multiple recipients. Until recently, the multicast routing protocols have concentrated on multicasting within a sing
N.C. State - CSC - 557
f wu e d cQA h u h "u h 3 ) & " ) 2 1 7 " & X ( 3 ( ' W( 2 A V T I ( U 2 7 ) " 0 T ) S G 3& 3 I ( & SRQ 8 I ( & 'P E 3& 3 & E 8 & H & 3 6& & " ( 7 & & 2 ) &" G & & & E FD B & CA " &6 3 & & & @ ') & 9 8
N.C. State - CSC - 557
Error Recovery for Interactive Video Transmission over the InternetInjong Rhee y Srinath R. JoshiDepartment of Computer Science North Carolina State University Raleigh, NC 27695-7534, USAfrhee,srjoshig@csc.ncsu.eduApril 1999AbstractReal-time
N.C. State - CSC - 557
Parity-Based Loss Recovery for Reliable Multicast TransmissionJ rg Nonnenmacher, Ernst Biersack, o Institut Eurecom 06904 Sophia-Antipolis Cedex France nonnen,erbi @eurecom.frDon Towsley Dept. of Computer Science Univ. of Massachusetts, Amherst,
N.C. State - CSC - 557
Reliable Multicast Transport Protocol (RMTP)11 IntroductionMulticasting provides an efcient way of disseminating data from a sender to a group of receivers. Instead of sending a separate copy of the data to each individual receiver, the sender jus
N.C. State - CONF - 2006
Structure of Workshop Assessment 101: The Nuts and Bolts of AssessmentWorkshop at the NCSU Undergraduate Assessment SymposiumThursday, April 6, 2006 1. 2.3.What are the outcomes for our program? Part 1: Generating Outcomes How do we know if we
N.C. State - CONF - 2006
How To Use Course-Based Data For Academic Program Review Joni E. Spurlin, Ph.D. WorksheetExercise A: In the space below, answer the following questions:List any assessment methods you know about:What kinds of data do you already have for your pro
N.C. State - CONF - 2006
Institutions That Thriverespond to demands forTo Make Education More Effectivespecify outcomes devise measures for assessing performances efficient, effective undergraduate education graduates prepared to work and produce.-Leslie & Fretwell
N.C. State - CONF - 2006
Characteristics of Effective Outcomes Assessment Roughly two decades of practice in assessing outcomes in higher education suggest a number of characteristics that distinguish effective implementation. The primary sources from which these characteris
N.C. State - CONF - 2006
Floridas Academic Learning CompactsShared Responsibility for Student Learning Outcomes in Undergraduate Education2006 Undergraduate Assessment Symposium North Carolina State UniversityApril 6, 2006Session Objectives Participants Will: Understa
N.C. State - CONF - 2006
Policy Guideline# PG 05.02.15Academic Learning CompactsPolicy / Purpose:To establish policy guidelines and procedures for universities, through their boards of trustees, to develop and implement Academic Learning Compacts to account for student
N.C. State - CONF - 2006
N.C. State - CONF - 2006
A Multi-Faceted Model for the Assessment of Student Learning at a Community CollegeLorain County Community CollegeWendy F. Marley, Ph.D. wmarley@lorainccc.edu (440) 366-77432006 Undergraduate Assessment Symposium Raleigh, NC April 2006Robert L
N.C. State - CONF - 2006
Lorain County Community CollegeCourse NO: Course Description: Course Title:COURSE ASSESSMENT RECORD (CAR)Semester:Revised 2004/05Section #:Student Learning Outcomes [Select from course description and student outcomes CC document] What cogni
N.C. State - CONF - 2006
14/12/2006PROGRAM ASSESSMENT RECORD Lorain County Community College Division: Program Title: List the measurable Program Outcomes List the courses that Related course provide the related course outcomes learning outcomesWhat cognitive, affective
N.C. State - CONF - 2006
DivisonContact Person: Date Submitted:(e.g. HSTR 162 or HSTR 162 I)First and Last NamesFaculty Member Completing the CAR1=Full Time (e.g. 03-15) Course Specific Outcome(s) Gen Ed #1 (prof competence) Gen Ed #2 (tech literacy) Gen Ed #3 (sci
N.C. State - CONF - 2006
26,000 Students, 269 Programs, and One Tool for Managing AssessmentUsing Technology to Support and Guide the ProcessSue Brodasky & Kathy Cummings Western Michigan UniversityA Plethora of ReportsHigher Learning Commission/North Central Associatio
N.C. State - CONF - 2006
IntroductionUndergraduate Assessment Symposium April, 2006North Carolina State UniversityOvercoming faculty resistance to assessment The interest in assessment in higher education emanates from many different constituencies. Policy makers, the
N.C. State - CONF - 2006
Back to the FutureA Conceptual Model of Planning & EffectivenessThe Essential ModelImproving assessment by increasing our conceptual understanding of how it fits into Institutional Effectiveness Returning to our rootsSession outcomesIntroduce
N.C. State - CONF - 2006
Using Assessment Results for Continuous Program Improvement for New and Transfer Student ProgramsNew Student Orientation Division of Undergraduate Academic Programs NC State University (919) 515-1234 www.ncsu.edu/orientationQuestions for Participa
N.C. State - CONF - 2006
Outcomes Developing an Institution-wide Vision for AssessmentJoni E. Spurlin, Ph.D. University Director of Assessment NC State University By the end of this session, participants will be able to:Identify why Vision is important List ways to begin t
N.C. State - CONF - 2006
THE GUIDING PRINCIPLES OR VISION THAT THE ATTENDEES LISTED DURING BRAIN-STORMING SESSION PurposeGuiding PrinciplesImproved student learning (& Teaching Assessment) Make explicit what is implicit (for all parties) ~ Congruence Promote Learning Commu
N.C. State - CONF - 2006
The Heart of General Education AssessmentHonoring Faculty Hopes & FearsApril 7, 2006NCSU Undergraduate Assessment SymposiumAbout East Tennessee State University Bill KirkwoodAssistant Vice President for Academic AffairsEast Tennessee State
N.C. State - CONF - 2006
ASSESSMENT PROCESS AT A MARYLAND COMMUNITY COLLEGEASSESSMENT PROCESS AT A MARYLAND COMMUNITY COLLEGE2006 Undergraduate Assessment Symposium North Carolina State University April 7, 2006 _ Shree Iyengar, PhD Anne Arundel Community College Arnold, M
N.C. State - CONF - 2006
Strategically plan for learning-oriented services and programs, then,Learning Objectives Today, we will.Use a strategic assessment plan to align student learning outcomes, measurement methods and evidence with program objectives. Identify how valu
N.C. State - CONF - 2006
Strategically Plan for learning-oriented services and programs, thenMeasure what you value instead of valuing what you measure!Program Objectives: Self-Assessment: Provide tools for students to develop and apply knowledge about self when deciding
N.C. State - CONF - 2006
GoalsAssessment of Student Information Literacy Skills:An Investigation of a Rubric Approach Megan Oakleaf NCSU Assessment Symposium April 2006 To define and describe rubrics. To clarify theoretical support for using rubrics for assessment. To outl
N.C. State - CONF - 2006
Planning, Assessment, & Institutional Effectiveness: Faculty Ownership, Administrative LeadershipDr. Susan Lovegren Bosworth Associate Provost, Planning & Assessment College of William & Mary in VirginiaPrepared for North Carolina State Universitys
N.C. State - CONF - 2006
Ron Krug Assistant Professor of Management University of Pittsburgh at JohnstownOutcomes Assessment Research Project North Carolina State University Undergraduate Assessment Symposium April 6-8, 2006 Title: Analysis of the Characteristics and Perce
N.C. State - CONF - 2006
Improving General Education by Avoiding the Maintenance TrapUndergraduate Assessment Symposium North Carolina State University April 6 8, 2006 Track III, Academic DisciplinesMichael B. Daniel Director of General Education Sullivan University Louis
N.C. State - CONF - 2006
References Aper & Hinkle (1991). State policies for assessing student outcomes. The Journal of Higher Education, 62, 539-555. Anderson, L. W. & Kratwohl, D. R. (Eds.). (2001). A taxonomy for learning teaching and assessing: A revision of Blooms Taxon