
| 本书内容广博,但又讲解得非常深入,是汇编语言课程的很好教材。 |
| preface xxiii 1 basic concepts 1 1.1 welcome to assembly language 1 1.1.1 some good questions to ask 2 1.1.2 assembly language applications 7 1.1.3 section review 8 1.2 virtual machine concept 8 1.2.1 the history of pc assemblers 1 l 1.2.2 section review 12 1.3 data representation 12 1.3.1 binary numbers 13 1.3.1.1 unsigned binarylntegers 13 1.3.1.2 translating unsigned binary integers to decimal 14 1.3.1.3 translating unsigned decimal integers to binary 14 1.3.2 binary addition 15 1.3.3 integer storage sizes 16 1.3.4 hexadecimal integers 16 1.3.4.1 converting unsigned hexadecimal to decimal 17 1.3.4.2 converting unsigned decimal to hexadecimal 18 1.3.5 signed integers 18 .1.3.5.1 two's complement notation 19 1.3.5.2 maximum and minimum values 21 1.3.6 character storage 2i 1.3.7 section review 23 1.4 boolean operations 25 1.4.1 truth tables for boolean functions 27 1.4.2 section review 29 1.5 chapter summary 29 2 ia-32 processor architecture 31 2.1 general concepts 31 2.1.1 basic microcomputer design 32 2.1.2 instruction execution cycle 33 2.1.2.1 multi-stage pipeline 34 2.1.2.2 superscalar amhitecture 36 2.1.3 reading from memory 37 2.1.4 how programs run 38 2.1.4.1 load and execute process 38 2.1,4,2 multitasking 39 2.1.5 section review 40 2.2 ia-32 processor architecture 41 2.2.1 modes of operation 41 2.2.2 basic execution environment 41 2.2.2.1 address space 41 2.2.2.1 basic program execution registers 42 2.2.3 floating-point unit 44 2.2.3.1 other registers 44 2.2.4 intel microprocessor history 45 2.2.4.1 ia-32 processor family 46 2.2.4.2 p6 processor family 46 2,2.4.3 cisc and'risc 46 2.2.5 section review 47 2.3 ia-32 memory management 48 2.3.1 real-addressmode 48 2.3.1.1 20-bit linear address calculation 49 2.3.2 protected mode 50 2.3.2.1 flat segmentation model 50 2.3.2.2 multi-segment model 51 2.3.2.3 paging 52 2.3.3 section review 53 2.4 components of an ia-32 microcomputer 53 2.4.1 motherboard 53 2.4.1.1 pci bus architecture 54 2.4.1.2 motherboard chipset 54 2.4.2 video output 55 2.4.3 memory 55 2.4.4 input-output ports 56 2.4.5 section review 57 2.5 input-output system 57 2.5.1 how it all works 57 2.5.2 section review 60 2.6 chapter summary 60 3 assembly language fundamentals 63 3.1 basic elements of assembly language 64 3.1.1 integer constants 64 3.1.2 integer expressions 65 3.1.3 real number constants 66 3.1.4 character constants 67 3.1.5 string constants 67 3.1.6 reserved words 67 3.1.7 identifiers 67 3.1.8 directives 68 3.1.9 instructions 68 3.1.9.1 label 69 3.1.9.2 instruction mnemonic 70 3.1.9.3 operands 70 3.1.9.4 comments 71 3.1.10 section review 71 3.2 example: adding three integers 72 3.2.1 program listing 72 3.2.2 program output 72 3.2.3 program description 73 3.2.3.1 alternative version of addsub 74 3.2.4 program template 76 3.2.5 section review 76 3.3 assembling, linking, and running programs 77 3.3.1 the assemble-link-execute cycle 77 3.3.1.1 listing file 78 3.3.1.2 files created or updated by the linker 79 3.3.2 section review 80 3.4 defining data 80 3.4.1 intrinsic data types 80 3.4.2 data definition statement 81 3.4.3 defining byte and sbyte data 81 3.4.3.1 multiple initializers 82 3.4.3,2 defining strings 83 3.4.3.3 using the dup operator 83 3.4.4 defining word and sword data 84 3.4.5 defining dword and sdword data 84 3.4.6 defining qword data 85 3.4.7 defining tbyte data 85 3.4.8 defining real number data 85 3.4.9 little endian order 86 3.4.10 adding variables to the addsub program 87 3.4.11 declaring uninitialized data 87 3.4.12 section review 88 3.5 symbolic constants 89 3.5.1 equal-sign directive 89 3.5.2 calculating the sizes of arrays and strings 90 3.5.3 equ directive 91 3.5.4 textequ directive 92 3.5.5 section review 93 3.6 real-address mode programming (optional) 93 3.6.1 basic changes 94 3.6.1.1 the addsub2 program 94 3.7 chapter summary 95 3.8 programming exercises 96 4 data transfers, addressing, and arithmetic 97 4.1 data transfer instructions 98 4.1.1 introduction 98 4.1.2 operandtypes 98 4.1.3 direct memory operands 99 4.1.4 mov instruction 100 4.1.5 zero/sign extension of integers 101 4.1.5.1 copying smaller values to larger ones 101 4.1.5.2 movzx instruction 102 4.1.5.3 movsx instruction 103 4.1.6 lahf and sai-if instructions 103 4.1.7 xchg instruction 104 4.1.8 direct-offset operants 104 4.1.9 example program (moves) 105 4.1.10 section review 106 4.2 addition and subtraction 107 4.2.1 inc and decinstmctions 107 4.2.2 add instruction 108 4.2.3 sub instruction 108 4.2.4 neg instruction 109 4.2.5 implementing arithmetic expressions 109 4.2.6 flags affected by arithmetic 110 4.2.6.1 zero and sign flags 110 4.2.6.2 carry flag (unsigned arithmetic) 110 4.2.6.3 overflow flag (signed arithmetic) 111 4.2.7 example program (addsub3) 113 4.2.8 section review 1 14 4.3 data-related operators and directives 115 4.3.1 offset operator 115 4.3.1.1 offset example 115 4.3.2 align directive 116 4.3.3 ptr operator 117 4.3.4 type operator 118 4.3.5 lengthof operator 118 4.3.6 sizeof operator 119 4.3.7 label directive 119 4.3.8 section review 120 4.4 indirect addressing 120 4.4.1 indirect operands 121 4.4.2 arrays 122 4.4.3 indexed operands 123 4.4.4 pointers 124 4.4.4.1 using the typdef operator 125 4.4.5 section review 126 4.5 jmpand loop instructions 127 4.5.1 jmp instruction 127 4.5.2 loop instruction 128 4.5.3 summing an integer array 129 4.5.4 copying a string 130 4.5.5 section review 131 4.6 chapter summary 132 4.7 programming exercises 133 5 procedures 137 5.1 introduction 137 5.2 linking to an external library 138 5.2.1 background information 138 5.2.2 section review 139 5.3 the book's link library 140 5.3.1 overview 140 5.3.2 individual procedure descriptions 141 5.3.2.1 the irvine32.inc include file 147 5.3.3 library test program 148 5.3.4 section review 152 5.4 stack operations 153 5.4.1 runtime stack 153 5.4.1.1 push operation 154 5.4.1.2 pop operation 155 5.4.1.3 stack applications 155 5.4.2 push and pop instructions 156 5.4.2.1 push instruction 156 5.4.2.2 pop instruction 1,56 5.4.2.3 pushfd and popfd instructions 156 5.4.2.4 pushad, pusha, popad, and popa 157 5.4.2.5 example: reversing a string 157 5.4.3 section review 158 5.5 defining and using procedures 159 5.5.1 proc directive 159 5.5.1.1 defining a procedure 159 5.5.1.2 example: sum of three integers 160 documenting procedures 160 5.5.2 call and ret instructions 161 5.5.2.1 call and return example 161 5.5.2.2 nested procedure calls 162 5.5.2.3 local labels and global labels 163 5.5.2.4 passing register arguments to procedures 164 5.5.3 example: summing an integer array 164 5.5.4 flowcharts 165 5.5.5 saving and restoring registers 166 5.5.5.1 uses operator 166 5.5.6 section review 168 5.6 program design using procedures 169 5.6.1 integer summation program (design) 170 5.6.1.1 integer summation implementation 172 5.6.2 section review 175 5.7 chapter summary 175 5.8 programming exercises 176 6 conditional processing 179 6.1 introduction 180 6.2 boolean and comparison instructions 180 6.2,1 the cpu flags 181 6.2.2 and instruction 181 6.2.2.1 converting characters to upper case 182 6.2.3 or instruction 183 6.2.4 xor instruction 184 6.2.5 not instruction 186 6.2.6 test instruction 186 6.2.7 cmp instruction 186 6.2.8 setting and clearing individual cpu flags 188 6.2.9 section review 188 6,3 conditional jumps 189 6.3.1 conditional structures 189 6.3.2 jcond instruction 190 6.3.3 types of conditional jump instructions 191 6.3.3.1 equality comparisons 192 6.3.3.2 unsigned comparisons 192 6.3.3.3 signed comparisons 192 6.3.4 conditional jump applications 193 6.3.4.1 testing status bits 193 6.3.4.2 application: scanning an array 194 6.3.4.3 application: string encryption 195 6.3.5 bit testing instructions (optional) 198 6.3.5.1 bt instruction 198 6.3.5.2 btc instruction 199 6.3.5.3 btr instruction 199 6.3.5.4 bts instruction 199 6.3.6 section review 200 6.4 conditional loop instructions 200 6.4.1 loopz and loope instructions 200 6.4.2 loopnz and loopne instructions 201 6.4.3 section review 202 6.5 conditional structures 202 6.5.1 block-structured if statements 202 6.5.2 compound expressions 204 6.5.2.1 logical and operator 204 6.5.2.2 logical or operator 205 6.5.3 while loops 205 6.5.3.1 example: if statement nested in a loop 206 6.5.4 table-drivenselection 208 6.5.5 section review 210 4.6 application: finite-state machines 211 6.6.1 validating an input string 212 6.6.2 validating a signed integer 213 6.6.3 section review 216 6.7 using the .if directive (optional) 217 6.7.1 signed and unsigned comparisons 219 6.7.2 compound expressions 220 6.7.2.1 setcursorposition example 220 6.7.2.2 college registration example 221 6.7.3 .repeat and .while directives 222 6.7.3.1 example: loop containing an if statement 222 6.8 chapter summary 223 6.9 programming exercises 224 7 integer arithmetic 227 7.1 introduction 228 7.2 shift and rotate instructions 228 7.2.1 logical shifts versus arithmetic shifts 229 7.2.2 si-il instruction 229 7.2.3 shr instruction 230 7.2.4 sal and sar instructions 231 7.2.5 rol instruction 231 7.2.6 rorinstruction 232 7.2.7 rcl and rcr instructions 232 7.2.8 shld/shrd instructions 233 7.2.9 section review 235 7.3 shift and rotate applications 236 7.3.1 shifting multiple doublewords 236 7.3.2 binary multiplication 237 7.3.3 displaying binary bits 237 7.3.4 isolating a bit string 238 7.3.5 section review 239 7.4 multiplication and division instructions 239 7.4.1 mul instruction 240 7.4.2 imulinstruction 241 7.4.3 div instruction 242 7.4.4 signed integer division 243 7.4.4.1 cbw, cwd, cdq instructions 243 7,4.4.2 the idiv instruction 243 7.4.4.3 divide overflow 244 7.4.5 implementing arithmetic expressions 245 7.4.6 section review 247 7.5 extended addition and subtraction 248 7.5.1 adc instruction 248 7.5.2 extended addition example 249 7.5.3 sbb instruction 250 7.5.4 section review 250 7.6 ascii and packed decimal arithmetic (optional) 251 7.6.1 aaa instruction 252 7.6.2 aas instruction 253 7.6.3 aam instruction 253 7.6.4 aad instruction 253 7.6.5 packed decimal integers 254 7.6.5.1 daa instruction 254 7.6,5.2 das instruction 254 7.7 chapter summary 255 7.8 programming exercises 256 8 advanced procedures 259 8.1 introduction 259 8.2 local variables 260 8.2.1 local directive 261 8.2.2 section review 263 8.3 stack parameters 263 8.3.1 invoke directive 264 8.3.1.1 ddroperator 265 8.3.2 proc directive 266 8.3.2.1 examples 267 8.3.3 proto directive 268 8.3.3.1 arraysum example 269 8.3.4 passing by value or by reference 269 8.3.5 parameter classifications 271 8.3.6 example: exchanging two integers 271 8.3.7 trouble-shootingtips 272 8.3.7.1 saving and restoring registers 272 8.3.7.2 wrong operand sizes 273 8.3,7.3 passing the wrong type of pointer 274 8.3.7.4 passing immediate values 274 8.3.8 section review 274 8.4 stack frames 275 8.4.1 memory models 276 8.4.2 language specifiers 277 8.4.2.1 stdcall specifier 277 8.4,2.2 c specifier 278 8.4.2.3 pascal specifier 278 8.4.3 explicit access to stack parameters 278 8.4.2.1 saving and restoring registers 280 8.4.4 passing arguments by reference 280 8.4.4.1 arrayfill example 281 8.4.4.2 lea instruction 282 8.4.5 creating local variables 282 8.4.6 enter and leave instructions (optional) 283 8.4.7 section review 285 8.5 recursion 285 8.5.1 recursively calculating a sum 286 8.5.2 calculating a factorial 288 8.5.3 section review 290 8.6 creating multimodule programs 290 8.6.1 example: arraysum program 291 8.6.1.1 include file: function prototypes 292 8.6.1.2 main module 292 8.6.1.3 promptforlntegers module 293 8,6.1.4 arraysum module 294 8,6.1.5 displaysum module 295 8.6.1.6 batch file for assembling and linking 295 8.6.2 section review 296 8.7 chapter summary 296 8.8 programming exercises 298 9 strings and arrays 301 9.1 introduction 301 9.2 string primitive instructions 302 9.2.1 movsb, movsw, and movsd 304 9.2.2 cmpsb, cmpsw, and cmpsd 304 9.2.2.1 example: comparing two strings 306 9.2.3 scasb, scasw, and scasd 307 9.2.4 stosb, stosw, and stosd 308 9.2.5 lodsb, lodsw, and lodsd 308 9.2.6 section review 309 9.3 selected string procedures 309 9.3.1 str_compare procedure 3 l0 9.3.2 str length procedure 311 9.3.3 str copy procedure 311 9.3.4 str_trim procedure 312 9.3.5 str_ucase procedure 314 9.3.6 section review 315 9.4 two-dimensional arrays 315 9.4.1 base-index operands 315 9.4.2 base-index displacement 317 9.4.3 section review 318 9.5 searching and sorting integer arrays 318 9.5.1 bubble sort 319 9.5.2 binary search 321 9.5.2.1 test program 324 9.5.3 section review 328 9.6 chapter summary 328 9.7 programming exercises 330 10 structures and macros 333 10.1 structures 334 10.1.1 defining structures 334 10.1.2 declaring structure variables 335 10.1.3 referencing structure variables 336 10.1.4 example: displaying the system time 338 10.1.5 nested structures 340 10.1.6 example: drunkard's walk 341 10.1.7 declaring and using unions 344 10.1.8 section review 346 10.2 macros 347 10.2.1 overview 347 10.2.2 defining macros 348 10.2.3 invoking macros 349 10.2.4 macro examples 350 10.2.4.1 mwritestr macro 351 10.2.4,2 mreadstr macro 352 10.2.4,3 mgotoxymacro 352 10,2.4.4 mdumpmem macro 353 10.2.4,5 macros containing code and data 354 10.2.5 nested macros 355 10.2.6 example program: wrappers 356 10.2.7 section review 357 10.3 conditional-assembly directives 358 10.3.1 checking for missing arguments 359 10.3.2 default argument initializers 360 10.3.3 boolean expressions 360 10.3.4 if, else, and endif directives 361 10.3.5 the ifidn and ifidni directives 362 10.3.6 special operators 363 10.3.6.1 substitution operator (&) 363 10.3.6.2 expansion operator (%) 364 10.3.6.3 literal-text operator ([]) 366 10.3.6.4 literal-character operator 0) 366 10.3.7 macro functions 367 10.3.8 section review 369 10.4 defining repeat blocks 370 10.4.1 while directive 370 10.4.2 repeat directive 371 10.4.3 for directive 371 10.4.4 forc directive 372 10.4.5 example: linked list 373 10.4.6 section review 375 10.5 chapter summary 375 10.6 programming exercises 376 11 32-bit windows programming 379 11.1 win32console programming 379 11.1.1 background information 381 11.1.1.1 windows data types 382 11.1.1.2 console handles 383 11.1.2 win32 console functions 384 11.1.3 console input 386 11.1.3.1 readconsole function 387 11.1.3.2 single-character input 388 11.1.4 console output 389 11.1.4.1 data structures 390 11.1.4.2 wdteconsole function 390 11.1.4.3 example program: console1 390 11.1.4.4 writeconsoleoutputcharacterfunction 391 11.1.5 reading and writing files 392 11.1.5.1 createfile function 392 11,1.5.2 closehandle function 395 11.1.5.3 readfile function 395 11.1.5.4 writefile function 395 11.1.5,5 example writefile program 396 11.1.5.6 moving the file pointer 397 11,1.5.7 example readfile program 397 11.1.6 console window manipulation 398 11.1.6.1 setconsoletiue 399 11.1.6.2 getconsolescreenbufferlnfo 399 11.1,6.3 setconsolewindowlnfo function 400 11.1.6.4 setconsolescreenbuffersize function 402 11.1.7 controlling the cursor 402 11.1.7.1 getconsolecursorlnfo function 402 11.1.7.2 setconsolecursorlnfo function 402 11.1.7.3 setconsolecursorposition 403 11.1.8 controlling the text color 403 11.1.8.1 setconsoletextattdbute function 403 11.1.8,2 wdteconsoleoutputattribute function 403 11.1.8.3 example writecolors program 403 11.1.9 time and date functions 405 11.1.9.1 getkocaltime and setlocaltime 406 11.1.9.2 gettickcount function 407 11.1.9.3 sleep function 407 11.1.9.4 getdatetime procedure 408 11.1.9,5 creating a stopwatch timer 409 11.1.10section review 410 11.2 writing a graphical windows application 411 11.2.1 necessary structures 412 11.2.2 the messagebox function 413 11.2.3 the winmain procedure 414 11.2.4 the winproc procedure 414 11.2.5 the errorhandler procedure 415 11.2.6 program listing 416 11.2.6,1 running the program 419 11.2.7 section review 420 11.3 ia-32 memory management 421 11.3.1 linear addresses 421 11.3.1.1 translating logical addresses to linear addresses 421 11.3.1.2 paging 423 11.3.1.3 descriptor tables 424 11.3.1.4 segment descriptor details 425 11.3.2 page translation 425 11.3.2.1 ms-windows virtual machine manager 426 11.3.3 section review 427 11.4 chapter summary 428 11.5 programming exercises 429 12 high-level language interface 431 12.1 introduction 431 12.1.1 general conventions 431 12.1.2 section review 433 12.2 lnline assembly code 433 12.2.1 asm directive in microsoft visual c++ 433 12.2.1.1 using the length, type, and size operators 435 12.2.2 file encryption example 436 12.2.2.1 procedure call overhead 437 12.2.3 section review 439 12.3 linking to c++ programs 439 12.3.1 linking to borland c++ 440 12.3.2 readsector example 441 12.3.2.1 main c++ program that calls readsector 442 12.3,2.2 assembly language module 444 12.3.3 example: large random integers 446 12.3.4 using assembly language to optimize c++ code 448 12.3.4.1 findarray code.generated by visual c++ 449 12.3.4.2 linking masm to visual c++ 450 12.3.5 section review 454 12.4 chapter summary 455 12.5 programming exercises 456 13 16-bit ms-dos programming 457 13.1 ms-dos and the ibm-pc 457 13.1.1 memory organization 458 13.1.2 redirecting input-output 460 13.1.3 software interrupts 461 13.1.4 int instmction 461 13.1.4.1 interrupt vectoring 461 13.1.4.2 common interrupts 462 13.1.5 section review 462 13.2 ms-dos function calls (int 21h) 463 13.2.1 selected output functions 464 13.2.2 hello world program example 467 13.2.3 selected input functions 467 13.2.3.1 example: string encryption program 469 13.2.3.2 int 21h function 3fh 470 13.2.4 date/time functions 472 13.2.4.1 example: displaying the time and date 474 13.2.5 section review 476 13.3 standard ms-dos file i/o services 476 13.3.0.1 create or open file (716ch) 478 13.3.1 close file handle (3eh) 479 13.3.2 move file pointer (42h) 480 13.3.2.1 get file creation date and time 481 13.3.3 selected library procedures 481 13.3.3.1 readstring 482 13.3.3.2 writestring 482 13.3.4 example: read and copy a text file 483 13.3.5 reading the ms-dos command tail 485 13.3.6 example: creating a binary file 487 13.3.7 section review 490 13a chapter summary 491 13.5 chapter exercises 492 14 disk fundamentals 495 14.1 disk storage systems 495 14.1.1 tracks, cylinders, and sectors 496 14.1.2 disk partitions (volumes) 498 14.1.3 section review 499 14.2 file systems 500 14.2.1 fat12 501 14.2.2 fat16 501 14.2.3 fat32 501 14.2.4 ntfs 502 14.2.5 primary disk areas 503 14.2.6 section review 504 14.3 disk directory 505 14.3.1 ms-dos directory structure 505 14.3.2 long filenames in ms-windows 508 14.3.3 file allocation table (fat) 510 14.3.4 section review 511 14.4 reading and writing disk sectors (7305h) 511 14.4.1 sector display program 513 14.4.2 section review 517 14.5 system-level file functions 517 14.5.1 get disk free space (7303h) 518 14.5.1.1 disk free space program 519 14.5.2 create subdirectory (39h) 521 14.5.3 remove subdirectory (3ah) 521 14.5.4 set current directory (3bh) 522 14.5.5 get current directory (47h) 522 14.5.6 section review 522 14.6 chapter summary 523 14.7 programming exercises 524 15 bios-level programming 527 15.1 introduction 527 15.1.1 bios dataarea 528 15.2 keyboard input with int 16h 529 15.2.1 how the keyboard works 530 15.2.2 int 16hfunctions 531 15.2.2.1 settypematic rate (03h) 531 15.2.2.2 push key into keyboard buffer (05h) 531 15.2.2.3 wait for key (1oh) 532 15.2.2.4 check keyboard buffer (11h) 533 15.2.2.5 get keyboard flags 534 15.2.2.6 clearing the keyboard buffer 535 15.2.3 section review 537 15.3 video programming with int 10h 537 15.3.1 basic background 537 15.3.1.1 three levels of access 537 15.3.1.2 running programsin full-screen mode 538 15.3.1.3 understanding video text 538 15.3.2 controlling the color 539 15.3.2.1 mixing primary colors 539 15.3.2.2 attribute byte 540 15.3.3 int 10h video functions 541 15.3.3.1 set video mode (00h) 542 15.3.3.2 15.3.3.set cursor lines (01h) 543 15.3.3.3 set cursor position (02h) 544 15.3.3.4 get cursor position and size (03h) 544 15.3.3.5 scroll window up (06h) 546 15.3.3.6 example: writing text to a window 547 15.3.3.7 scroll window down (07h) 548 15.3.3,8 read character and attribute (08h) 548 15.3.3.9 write character and attribute (09h) 548 15.3.3.10 write character (0ah) 549 15.3.3.11 toggle blinking and intensity modes 550 15.3.3.12 get video mode information (0fh) 550 15.3.3.13 write string in teletype mode (13h) 551 15.3.3.14 example: displaying a color string 552 15.3.4 library procedure examples 554 15.3.4.1 gotoxy procedure 554 15.3.4.2 clrscr procedure 554 15.3.5 section review 555 15.4 drawing graphics using int 10h 555 15.4.1 int 10h pixel-related functions 556 15.4.1.1 write graphics pixel (0ch) 556 15.4.1.2 read graphics pixel(0dh) 557 15.4.2 drawline program 557 15.4.3 cartesian coordinates program 559 15.4.4 converting cartesian coordinates to screen coordinates 562 15,4.5 section review 563 15.6 memory-mapped graphics 563 15.5.1 mode 13h: 320 x 200, 256 colors 563 15.5.2 memory-mapped graphics program 565 15.5.3 section review 568 15.6 mouse programming 568 15.6.1 mouse int 33h functions 568 15.6.1.1 reset mouse and get status 568 15.6.1.2 showing and hiding the mouse pointer 569 15.6.1,3 get mouse position and status 570 15.6.1.4 set mouse position 571 15.6.1.5 get button presses and releases 571 15.6.1.6 setting horizontal and vertical limits 573 15.6.1.7 miscellaneous mouse functions 573 15.6.2 mouse tracking program 574 15.6.3 section review 579 15.7 chapter summary 580 15.8 chapter exercises 580 16 expert ms-dos programming 583 16.1 introduction 583 16.2 defining segments 584 16.2.1 simplified segment directives 584 16.2.2 explicit segment definitions 586 16.2.2.1 align type 587 16.2.2.2 combine type 587 16.2.2.3 classtype 588 16.2.2.4 assume directive 588 16.2.2.5 example: multiple data segments 588 16.2.3 segment overrides 589 16.2.4 combining segments 590 16.2.5 section review 592 16.3 runtime program structure 592 16.3.1 com programs 593 16.3.2 exe programs 595 16.3.2.1 memory usage 595 16.3.2.2 exe header 596 16.3.3 section review 597 16.4 interrupt handling 597 16.4.1 hardware interrupts 599 16.4.2 interrupt control instructions 600 16.4.3 writing a custom interrupt handler 601 16.4.3.1 ctri-break handler example 602 16.4.4 terminate and stay resident programs 604 16.4.4.1 keyboard example 604 16.4.5 application: the no_reset program 605 16.4.6 section review 609 16.5 chapter summary 609 17 advanced topics chapter 17 is an additional chapter provided as a pdf file on the cd-rom accompanying this book. 17.1 hardware control using fo ports 17-1 17.1.1 input-output ports 17-1 17.1.1.1 pc sound program 17-2 17.2 intel instruction encoding 17-4 17.2.1 single-byte instructions 17-5 17.2.2 immediate operands 17-6 17.2.3 register-mode instructions 17-6 17.2.4 memory-mode instructions 17-7 17.2.4.1 mov instruction examples 17-9 17.2.5 section review 17-11 17.3 floating-point arithmetic 17-12 17.3.1 ieee binary floating-point representation 17-12 17.3.1.1 the sign 17-12 17.3.1.2 the mantissa 17-12 17.3.2 the exponent 17-13 17.3.3 normalizing the mantissa 17-14 17.3.4 creating the ieee bit representation 17-15 17.3.5 converting decimal fractions to binary reals 17-15 17.3.6 ia-32 floating point architecture 17-17 17.3.7 instruction formats 17-18 17.3.8 floating-point code examples 17-21 17.3.8,1 example 1: evaluating an expression 17-21 appendix a: installing and using the assembler 611 appendix b: the intel instruction set 617 appendix c: bios and ms-dos interrupts 649 appendix d: masm reference 661 |
商品评论(0条)