Richard Blum9780764579011, 0764579010
Table of contents :
Team DDU……Page 1
Acknowledgments……Page 14
Contents……Page 16
Introduction……Page 26
Processor Instructions……Page 32
Instruction code handling……Page 33
Instruction code format……Page 34
High-Level Languages……Page 37
Types of high-level languages……Page 38
High-level language features……Page 40
Assembly Language……Page 41
Opcode mnemonics……Page 42
Defining data……Page 43
Directives……Page 45
Summary……Page 46
Core Parts of an IA-32 Processor……Page 48
Control unit……Page 50
Execution unit……Page 55
Registers……Page 56
Flags……Page 60
The x87 floating-point unit……Page 63
Streaming SIMD extensions (SSE)……Page 64
The IA-32 Processor Family……Page 65
Intel processors……Page 66
Non-Intel processors……Page 67
Summary……Page 68
The Development Tools……Page 70
The Assembler……Page 71
The Linker……Page 73
The Debugger……Page 74
The Profiler……Page 75
Installing the assembler……Page 76
Using the assembler……Page 78
A word about opcode syntax……Page 80
The GNU Linker……Page 81
Downloading and installing gcc……Page 84
Using gcc……Page 85
Downloading and installing gdb……Page 87
Using gdb……Page 88
Using kdbg……Page 91
The GNU Objdump Program……Page 93
Using objdump……Page 94
An objdump example……Page 95
Using the profiler……Page 96
A profile example……Page 99
The basics of Linux……Page 100
Downloading and running MEPIS……Page 101
Your new development system……Page 102
Summary……Page 103
The Parts of a Program……Page 104
Defining the starting point……Page 105
Creating a Simple Program……Page 106
The CPUID instruction……Page 107
The sample program……Page 108
Assembling using a compiler……Page 111
Using gdb……Page 112
Using C Library Functions in Assembly……Page 117
Using printf……Page 118
Linking with C library functions……Page 119
Summary……Page 121
The data section……Page 122
Defining static symbols……Page 125
The bss section……Page 126
The MOV instruction formats……Page 128
Moving immediate data to registers and memory……Page 129
Moving data between memory and registers……Page 130
Conditional Move Instructions……Page 137
The CMOV instructions……Page 138
Using CMOV instructions……Page 140
Exchanging Data……Page 141
The data exchange instructions……Page 142
Using the data exchange instruction……Page 147
How the stack works……Page 150
PUSHing and POPing data……Page 151
Optimizing Memory Access……Page 154
Summary……Page 155
The Instruction Pointer……Page 158
Jumps……Page 160
Calls……Page 163
Interrupts……Page 166
Conditional jump instructions……Page 167
The compare instruction……Page 169
Examples of using the flag bits……Page 171
The loop instructions……Page 175
Preventing LOOP catastrophes……Page 176
Duplicating High-Level Conditional Branches……Page 177
if statements……Page 178
for loops……Page 181
Branch prediction……Page 184
Optimizing tips……Page 186
Summary……Page 189
Numeric Data Types……Page 192
Standard integer sizes……Page 193
Unsigned integers……Page 195
Signed integers……Page 197
Using signed integers……Page 199
Extending integers……Page 200
Defining integers in GAS……Page 203
MMX integers……Page 204
Moving MMX integers……Page 205
SSE integers……Page 207
Moving SSE integers……Page 208
What is BCD?……Page 209
FPU BCD values……Page 210
Moving BCD values……Page 211
What are floating-point numbers?……Page 213
Standard floating-point data types……Page 215
IA-32 floating-point values……Page 217
Moving floating-point values……Page 218
Using preset floating-point values……Page 220
SSE floating-point data types……Page 221
Moving SSE floating-point values……Page 222
Conversion instructions……Page 227
A conversion example……Page 229
Summary……Page 230
Addition……Page 232
Subtraction……Page 241
Incrementing and decrementing……Page 246
Multiplication……Page 247
Division……Page 252
Shift Instructions……Page 254
Multiply by shifting……Page 255
Dividing by shifting……Page 256
Rotating bits……Page 257
Unpacked BCD arithmetic……Page 258
Packed BCD arithmetic……Page 260
Boolean logic……Page 262
Bit testing……Page 263
Summary……Page 264
The FPU Environment……Page 266
The FPU register stack……Page 267
The FPU status, control, and tag registers……Page 268
Using the FPU stack……Page 273
Basic Floating-Point Math……Page 276
Floating-point functions……Page 280
Partial remainders……Page 283
Trigonometric functions……Page 285
Logarithmic functions……Page 288
Floating-Point Conditional Branches……Page 290
The FCOM instruction family……Page 291
The FCOMI instruction family……Page 293
The FCMOV instruction family……Page 294
Saving and restoring the FPU environment……Page 296
Saving and restoring the FPU state……Page 297
Waiting versus Nonwaiting Instructions……Page 300
Summary……Page 301
Moving Strings……Page 304
The MOVS instruction……Page 305
The REP prefix……Page 309
The LODS instruction……Page 314
The STOS instruction……Page 315
Building your own string functions……Page 316
The CMPS instruction……Page 317
Using REP with CMPS……Page 319
String inequality……Page 320
Scanning Strings……Page 322
The SCAS instruction……Page 323
Scanning for multiple characters……Page 324
Finding a string length……Page 326
Summary……Page 327
Defining Functions……Page 328
Writing functions……Page 330
Accessing functions……Page 333
Using global data……Page 335
Passing function parameters on the stack……Page 337
Function prologue and epilogue……Page 339
Defining local function data……Page 340
An example……Page 343
Watching the stack in action……Page 345
Creating a separate function file……Page 348
Creating the executable file……Page 349
Debugging separate function files……Page 350
The anatomy of a program……Page 351
Analyzing the stack……Page 352
Viewing command-line parameters……Page 354
Viewing environment variables……Page 356
An example using command-line parameters……Page 357
Summary……Page 359
The Linux Kernel……Page 360
Parts of the kernel……Page 361
Linux kernel version……Page 367
Finding system calls……Page 368
Finding system call definitions……Page 369
Common system calls……Page 370
The system call format……Page 372
The sysinfo system call……Page 377
Using the return structure……Page 378
Viewing the results……Page 379
The strace program……Page 380
Advanced strace parameters……Page 381
Watching program system calls……Page 382
Attaching to a running program……Page 384
System Calls versus C Libraries……Page 386
The C libraries……Page 387
Tracing C functions……Page 388
Comparing system calls and C libraries……Page 389
Summary……Page 390
What Is Inline Assembly?……Page 392
The asm format……Page 396
Using global C variables……Page 398
Using an alternate keyword……Page 400
Specifying input and output values……Page 401
Using registers……Page 403
Using placeholders……Page 404
Referencing placeholders……Page 407
Changed registers list……Page 408
Using memory locations……Page 410
Using floating-point values……Page 411
Handling jumps……Page 413
C macro functions……Page 415
Creating inline assembly macro functions……Page 417
Summary……Page 418
Creating Assembly Functions……Page 420
Compiling the C and Assembly Programs……Page 422
Using assembly object code files……Page 423
The executable file……Page 424
Using Assembly Functions in C Programs……Page 426
Using integer return values……Page 427
Using string return values……Page 428
Using floating-point return values……Page 431
Using multiple input values……Page 432
Using mixed data type input values……Page 434
Using Assembly Functions in C++ Programs……Page 438
What is a static library?……Page 439
The ar command……Page 440
Creating a static library file……Page 441
What are shared libraries?……Page 443
Compiling with a shared library……Page 445
Running programs that use shared libraries……Page 446
Debugging C programs……Page 448
Debugging assembly functions……Page 449
Summary……Page 451
Optimized Compiler Code……Page 452
Compiler optimization level 1……Page 453
Compiler optimization level 2……Page 454
Generating the assembly language code……Page 456
Recompiling the optimized code……Page 460
Optimizing calculations……Page 461
Optimizing variables……Page 464
Optimizing loops……Page 468
Optimizing conditional branches……Page 473
Common subexpression elimination……Page 478
Summary……Page 481
The File-Handling Sequence……Page 484
Opening and Closing Files……Page 485
Access types……Page 486
UNIX permissions……Page 487
Open file code……Page 489
Open error return codes……Page 490
A simple write example……Page 491
Handling file errors……Page 493
Reading Files……Page 494
A simple read example……Page 495
A more complicated read example……Page 496
Reading, Processing, and Writing Data……Page 498
What are memory-mapped files?……Page 501
The mmap system call……Page 502
mmap assembly language format……Page 504
An mmap example……Page 506
Summary……Page 510
A Brief Review of SIMD……Page 512
MMX……Page 513
Detecting Supported SIMD Operations……Page 514
Detecting support……Page 515
SIMD feature program……Page 516
Loading and retrieving packed integer values……Page 518
Performing MMX operations……Page 519
Using SSE Instructions……Page 528
Moving data……Page 529
Processing data……Page 530
Using SSE2 Instructions……Page 535
Processing data……Page 536
Summary……Page 539
Index……Page 542
Reviews
There are no reviews yet.