wisconsin
Chapter 3: Machine-Level Representation of Programs

Chapter 3: Machine-Level Representation of Programs

Content locked

The catalog is public. Reading this content requires approved access.

Sign in to read
Chapter 3: Machine-Level Representation of Programs
Machine-Level Representation of Programs
Web Aside ASM:IA32 IA32 programming
3.1 A Historical Perspective
3.2 Program Encodings
3.2.1 Machine-Level Code
Aside The ever-changing forms of generated code
3.2.2 Code Examples
Aside How do I display the byte representation of a program?
3.2.3 Notes on Formatting
Aside ATT versus Intel assembly-code formats
3.3 Data Formats
Web Aside ASM:EASM Combining assembly code with C programs
3.4 Accessing Information
3.4.1 Operand Specifiers
Practice Problem 3.1 (solution page 361)
3.4.2 Data Movement Instructions
Aside Understanding how data movement changes a destination register
Practice Problem 3.2 (solution page 361)
Aside Comparing byte movement instructions
Practice Problem 3.3 (solution page 362)
3.4.3 Data Movement Example
Practice Problem 3.4 (solution page 362)
New to C? Some examples of pointers
Practice Problem 3.5 (solution page 363)
3.4.4 Pushing and Popping Stack Data
3.5 Arithmetic and Logical Operations
3.5.1 Load Effective Address
Practice Problem 3.6 (solution page 363)
Practice Problem 3.7 (solution page 364)
3.5.2 Unary and Binary Operations
Practice Problem 3.8 (solution page 364)
3.5.3 Shift Operations
Practice Problem 3.9 (solution page 364)
3.5.4 Discussion
Practice Problem 3.10 (solution page 365)
Practice Problem 3.11 (solution page 365)
3.5.5 Special Arithmetic Operations
Practice Problem 3.12 (solution page 365)
3.6 Control
3.6.1 Condition Codes
3.6.2 Accessing the Condition Codes
Practice Problem 3.13 (solution page 366)
Practice Problem 3.14 (solution page 366)
3.6.3 Jump Instructions
3.6.4 Jump Instruction Encodings
Aside What do the instructions rep and repz do?
Practice Problem 3.15 (solution page 366)
3.6.5 Implementing Conditional Branches with Conditional Control
Aside Describing machine code with C code
Practice Problem 3.16 (solution page 367)
Practice Problem 3.17 (solution page 367)
3.6.6 Implementing Conditional Branches with Conditional Moves
Aside How did you determine this penalty?
Practice Problem 3.19 (solution page 368)
Practice Problem 3.20 (solution page 369)
Practice Problem 3.21 (solution page 369)
3.6.7 Loops
Do-While Loops
Practice Problem 3.22 (solution page 369)
Aside Reverse engineering loops
While Loops
Practice Problem 3.24 (solution page 371)
Practice Problem 3.25 (solution page 371)
Practice Problem 3.26 (solution page 372)
For Loops
Practice Problem 3.27 (solution page 372)
Practice Problem 3.28 (solution page 372)
Practice Problem 3.29 (solution page 373)
3.6.8 Switch Statements
Practice Problem 3.30 (solution page 374)
Practice Problem 3.31 (solution page 374)
3.7 Procedures
3.7.1 The Run-Time Stack
3.7.2 Control Transfer
Practice Problem 3.32 (solution page 375)
3.7.3 Data Transfer
Practice Problem 3.33 (solution page 375)
3.7.4 Local Storage on the Stack
3.7.5 Local Storage in Registers
Practice Problem 3.34 (solution page 376)
3.7.6 Recursive Procedures
Practice Problem 3.35 (solution page 376)
3.8 Array Allocation and Access
3.8.1 Basic Principles
Practice Problem 3.36 (solution page 377)
3.8.2 Pointer Arithmetic
Practice Problem 3.37 (solution page 377)
3.8.3 Nested Arrays
Practice Problem 3.38 (solution page 377)
3.8.4 Fixed-Size Arrays
Practice Problem 3.39 (solution page 378)
Practice Problem 3.40 (solution page 378)
3.8.5 Variable-Size Arrays
3.9 Heterogeneous Data Structures
3.9.1 Structures
New to C? Representing an object as a struct
New to C? Representing an object as a struct (continued)
Practice Problem 3.42 (solution page 379)
3.9.2 Unions
Practice Problem 3.43 (solution page 380)
3.9.3 Data Alignment
Practice Problem 3.44 (solution page 381)
Practice Problem 3.45 (solution page 381)
Aside A case of mandatory alignment
3.10 Combining Control and Data in Machine-Level Programs
3.10.1 Understanding Pointers
New to C? Function pointers
3.10.2 Life in the Real World: Using the GDB Debugger
3.10.3 Out-of-Bounds Memory References and Buffer Overflow
Practice Problem 3.46 (solution page 382)
3.10.4 Thwarting Buffer Overflow Attacks
Stack Randomization
Aside Worms and viruses
Practice Problem 3.47 (solution page 383)
Stack Corruption Detection
Practice Problem 3.48 (solution page 383)
Limiting Executable Code Regions
3.10.5 Supporting Variable-Size Stack Frames
Practice Problem 3.49 (solution page 383)
3.11 Floating-Point Code
3.11.1 Floating-Point Movement and Conversion Operations
Practice Problem 3.50 (solution page 383)
Practice Problem 3.51 (solution page 384)
3.11.2 Floating-Point Code in Procedures
Practice Problem 3.52 (solution page 384)
3.11.3 Floating-Point Arithmetic Operations
Practice Problem 3.53 (solution page 384)
Practice Problem 3.54 (solution page 385)
3.11.4 Defining and Using Floating-Point Constants
Practice Problem 3.55 (solution page 385)
3.11.5 Using Bitwise Operations in Floating-Point Code
Practice Problem 3.56 (solution page 386)
3.11.6 Floating-Point Comparison Operations
Practice Problem 3.57 (solution page 386)
3.11.7 Observations about Floating-Point Code
3.12 Summary
Bibliographic Notes
Homework Problems
3.58 ◆
3.59 ◆◆
3.60 ◆◆
3.61 ◆◆
3.62 ◆◆
3.63 ◆◆
3.64 ◆◆◆
3.65 ◆
3.66 ◆
3.67 ◆◆
3.68 ◆◆◆
3.69
3.71 ◆
3.72 ◆◆
3.73 ◆
3.74 ◆◆
3.75 ◆
Solutions to Practice Problems
Solution to Problem 3.1 (page 218)
Solution to Problem 3.2 (page 221)
Solution to Problem 3.3 (page 222)
Solution to Problem 3.4 (page 223)
Solution to Problem 3.5 (page 225)
Solution to Problem 3.6 (page 228)
Solution to Problem 3.7 (page 229)
Solution to Problem 3.8 (page 230)
Solution to Problem 3.9 (page 231)
Solution to Problem 3.10 (page 232)
Solution to Problem 3.11 (page 233)
Solution to Problem 3.12 (page 236)
Solution to Problem 3.13 (page 240)
Solution to Problem 3.14 (page 241)
Solution to Problem 3.15 (page 245)
Solution to Problem 3.16 (page 248)
Solution to Problem 3.17 (page 248)
Solution to Problem 3.18 (page 249)
Solution to Problem 3.19 (page 252)
Solution to Problem 3.20 (page 255)
Solution to Problem 3.21 (page 255)
Solution to Problem 3.22 (page 257)
Solution to Problem 3.23 (page 258)
Solution to Problem 3.24 (page 260)
Solution to Problem 3.25 (page 262)
Solution to Problem 3.26 (page 264)
Solution to Problem 3.27 (page 267)
Solution to Problem 3.28 (page 267)
Solution to Problem 3.29 (page 268)
Solution to Problem 3.30 (page 272)
Solution to Problem 3.31 (page 273)
Solution to Problem 3.32 (page 280)
Solution to Problem 3.33 (page 282)
Solution to Problem 3.34 (page 288)
Solution to Problem 3.35 (page 290)
Solution to Problem 3.36 (page 292)
Solution to Problem 3.37 (page 294)
Solution to Problem 3.38 (page 295)
Solution to Problem 3.39 (page 298)
Solution to Problem 3.40 (page 298)
Solution to Problem 3.41 (page 304)
Solution to Problem 3.42 (page 305)
Solution to Problem 3.43 (page 308)
Solution to Problem 3.44 (page 311)
Solution to Problem 3.45 (page 311)
Solution to Problem 3.46 (page 318)
Solution to Problem 3.47 (page 322)
Solution to Problem 3.48 (page 324)
Solution to Problem 3.49 (page 329)
Solution to Problem 3.50 (page 336)
Solution to Problem 3.51 (page 336)
Solution to Problem 3.52 (page 337)
Solution to Problem 3.53 (page 339)
Solution to Problem 3.54 (page 339)
Solution to Problem 3.55 (page 341)
Solution to Problem 3.56 (page 341)
Solution to Problem 3.57 (page 344)
Source footnotes