书籍详情
Intel汇编语言程序设计:英文版
作者:Kip R.Irvine著
出版社:清华大学出版社
出版时间:2005-08-01
ISBN:9787302112617
定价:¥45.00
购买这本书可以去
内容简介
本书全面细致地讲述了汇编语言程序设计的各个方面。从微处理器体系结构、工作机制到指令集;从最基本的编译器链接器的使用到高级过程、结构和宏的使用;从用纯汇编编写程序到用VC++、BC++等最新编译器与汇编的混合接口编程;从16位实模式下BIOS、DOS实模式文本及图形程序设计到32位保护模式的Windows程序设计;从磁盘基础知识到Intel指令编码、浮点运算等相关知识都做了深入而细致的讲解。本书内容广博,但又讲解得非常深入,是汇编语言课程的很好教材。本书源代码可以从WWW.tup.tsinghua.edu.cn下载。
作者简介
暂缺《Intel汇编语言程序设计:英文版》作者简介
目录
Prefacexxiii
1BasicConcepts1
1.1WelcometoAssemblyLanguage1
1.1.1SomeGoodQuestionstoAsk2
1.1.2AssemblyLanguageApplications7
1.1.3SectionReview8
1.2VirtualMachineConcept8
1.2.1TheHistoryofPCAssemblers1l
1.2.2SectionReview12
1.3DataRepresentation12
1.3.1BinaryNumbers13
1.3.1.1UnsignedBinarylntegers13
1.3.1.2TranslatingUnsignedBinaryIntegerstoDecimal14
1.3.1.3TranslatingUnsignedDecimalIntegerstoBinary14
1.3.2BinaryAddition15
1.3.3IntegerStorageSizes16
1.3.4HexadecimalIntegers16
1.3.4.1ConvertingUnsignedHexadecimaltoDecimal17
1.3.4.2ConvertingUnsignedDecimaltoHexadecimal18
1.3.5SignedIntegers18
1.3.5.1Two'sComplementNotation19
1.3.5.2MaximumandMinimumValues21
1.3.6CharacterStorage2i
1.3.7SectionReview23
1.4BooleanOperations25
1.4.1TruthTablesforBooleanFunctions27
1.4.2SectionReview29
1.5ChapterSummary29
2IA-32ProcessorArchitecture31
2.1GeneralConcepts31
2.1.1BasicMicrocomputerDesign32
2.1.2InstructionExecutionCycle33
2.1.2.1Multi-StagePipeline34
2.1.2.2SuperscalarAmhitecture36
2.1.3ReadingfromMemory37
2.1.4HowProgramsRun38
2.1.4.1LoadandExecuteProcess38
2.1,4,2Multitasking39
2.1.5SectionReview40
2.2IA-32ProcessorArchitecture41
2.2.1ModesofOperation41
2.2.2BasicExecutionEnvironment41
2.2.2.1AddressSpace41
2.2.2.1BasicProgramExecutionRegisters42
2.2.3Floating-PointUnit44
2.2.3.1OtherRegisters44
2.2.4IntelMicroprocessorHistory45
2.2.4.1IA-32ProcessorFamily46
2.2.4.2P6ProcessorFamily46
2,2.4.3CISCand'RISC46
2.2.5SectionReview47
2.3IA-32MemoryManagement48
2.3.1Real-addressMode48
2.3.1.120-bitLinearAddressCalculation49
2.3.2ProtectedMode50
2.3.2.1FlatSegmentationModel50
2.3.2.2Multi-SegmentModel51
2.3.2.3Paging52
2.3.3SectionReview53
2.4ComponentsofanIA-32Microcomputer53
2.4.1Motherboard53
2.4.1.1PCIBusArchitecture54
2.4.1.2MotherboardChipset54
2.4.2VideoOutput55
2.4.3Memory55
2.4.4Input-OutputPorts56
2.4.5SectionReview57
2.5Input-OutputSystem57
2.5.1HowitAllWorks57
2.5.2SectionReview60
2.6ChapterSummary60
3AssemblyLanguageFundamentals63
3.1BasicElementsofAssemblyLanguage64
3.1.1IntegerConstants64
3.1.2IntegerExpressions65
3.1.3RealNumberConstants66
3.1.4CharacterConstants67
3.1.5StringConstants67
3.1.6ReservedWords67
3.1.7Identifiers67
3.1.8Directives68
3.1.9Instructions68
3.1.9.1Label69
3.1.9.2InstructionMnemonic70
3.1.9.3Operands70
3.1.9.4Comments71
3.1.10SectionReview71
3.2Example:AddingThreeintegers72
3.2.1ProgramListing72
3.2.2ProgramOutput72
3.2.3ProgramDescription73
3.2.3.1AlternativeVersionofAddSub74
3.2.4ProgramTemplate76
3.2.5SectionReview76
3.3Assembling,Linking,andRunningPrograms77
3.3.1TheAssemble-Link-ExecuteCycle77
3.3.1.1listingFile78
3.3.1.2FilesCreatedorUpdatedbytheLinker79
3.3.2SectionReview80
3.4DefiningData80
3.4.1IntrinsicDataTypes80
3.4.2DataDefinitionStatement81
3.4.3DefiningBYTEandSBYTEData81
3.4.3.1MultipleInitializers82
3.4.3,2DefiningStrings83
3.4.3.3UsingtheDUPOperator83
3.4.4DefiningWORDandSWORDData84
3.4.5DefiningDWORDandSDWORDData84
3.4.6DefiningQWORDData85
3.4.7DefiningTBYTEData85
3.4.8DefiningRealNumberData85
3.4.9LittleEndianOrder86
3.4.10AddingVariablestotheAddSubProgram87
3.4.11DeclaringUninitializedData87
3.4.12SectionReview88
3.5SymbolicConstants89
3.5.1Equal-SignDirective89
3.5.2CalculatingtheSizesofArraysandStrings90
3.5.3EQUDirective91
3.5.4TEXTEQUDirective92
3.5.5SectionReview93
3.6Real-AddressModeProgramming(Optional)93
3.6.1BasicChanges94
3.6.1.1TheAddSub2Program94
3.7ChapterSummary95
3.8ProgrammingExercises96
4DataTransfers,Addressing,andArithmetic97
4.1DataTransferInstructions98
4.1.1Introduction98
4.1.2OperandTypes98
4.1.3DirectMemoryOperands99
4.1.4MOVInstruction100
4.1.5Zero/SignExtensionofIntegers101
4.1.5.1CopyingSmallerValuestoLargerOnes101
4.1.5.2MOVZXInstruction102
4.1.5.3MOVSXInstruction103
4.1.6LAHFandSAI-IFInstructions103
4.1.7XCHGInstruction104
4.1.8Direct-OffsetOperants104
4.1.9ExampleProgram(Moves)105
4.1.10SectionReview106
4.2AdditionandSubtraction107
4.2.1INCandDECInstmctions107
4.2.2ADDInstruction108
4.2.3SUBInstruction108
4.2.4NEGInstruction109
4.2.5ImplementingArithmeticExpressions109
4.2.6FlagsAffectedbyArithmetic110
4.2.6.1ZeroandSignFlags110
4.2.6.2CarryFlag(unsignedarithmetic)110
4.2.6.3OverflowFlag(signedarithmetic)111
4.2.7ExampleProgram(AddSub3)113
4.2.8SectionReview114
4.3Data-RelatedOperatorsandDirectives115
4.3.1OFFSETOperator115
4.3.1.1OFFSETExample115
4.3.2ALIGNDirective116
4.3.3PTROperator117
4.3.4TYPEOperator118
4.3.5LENGTHOFOperator118
4.3.6SIZEOFOperator119
4.3.7LABELDirective119
4.3.8SectionReview120
4.4IndirectAddressing120
4.4.1IndirectOperands121
4.4.2Arrays122
4.4.3Indexedoperands123
4.4.4Pointers124
4.4.4.1UsingtheTYPDEFOperator125
4.4.5SectionReview126
4.5JMPandLOOPInstructions127
4.5.1JMPInstruction127
4.5.2LOOPInstruction128
4.5.3SumminganIntegerArray129
4.5.4CopyingaString130
4.5.5SectionReview131
4.6ChapterSummary132
4.7ProgrammingExercises133
5Procedures137
5.1Introduction137
5.2LinkingtoanExternalLibrary138
5.2.1BackgroundInformation138
5.2.2SectionReview139
5.3TheBook'sLinkLibrary140
5.3.1Overview140
5.3.2IndividualProcedureDescriptions141
5.3.2.1TheIrvine32.incIncludeFile147
5.3.3LibraryTestProgram148
5.3.4SectionReview152
5.4StackOperations153
5.4.1RuntimeStack153
5.4.1.1PushOperation154
5.4.1.2PopOperation155
5.4.1.3StackApplications155
5.4.2PUSHandPOPInstructions156
5.4.2.1PUSHInstruction156
5.4.2.2POPInstruction1,56
5.4.2.3PUSHFDandPOPFDInstructions156
5.4.2.4PUSHAD,PUSHA,POPAD,andPOPA157
5.4.2.5Example:ReversingaString157
5.4.3SectionReview158
5.5DefiningandUsingProcedures159
5.5.1PROCDirective159
5.5.1.1DefiningaProcedure159
5.5.1.2Example:SumofThreeIntegers160
DocumentingProcedures160
5.5.2CALLandRETInstructions161
5.5.2.1CallandReturnExample161
5.5.2.2NestedProcedureCalls162
5.5.2.3LocalLabelsandGlobalLabels163
5.5.2.4PassingRegisterArgumentstoProcedures164
5.5.3Example:SumminganIntegerArray164
5.5.4Flowcharts165
5.5.5SavingandRestoringRegisters166
5.5.5.1USESOperator166
5.5.6SectionReview168
5.6ProgramDesignUsingProcedures169
5.6.1IntegerSummationProgram(Design)170
5.6.1.1IntegerSummationImplementation172
5.6.2SectionReview175
5.7ChapterSummary175
5.8ProgrammingExercises176
6ConditionalProcessing179
6.1Introduction180
6.2BooleanandComparisonInstructions180
6.2,1TheCPUFlags181
6.2.2ANDInstruction181
6.2.2.1ConvertingCharacterstoUpperCase182
6.2.3ORInstruction183
6.2.4XORInstruction184
6.2.5NOTInstruction186
6.2.6TESTInstruction186
6.2.7CMPInstruction186
6.2.8SettingandClearingIndividualCPUFlags188
6.2.9SectionReview188
6,3ConditionalJumps189
6.3.1ConditionalStructures189
6.3.2JcondInstruction190
6.3.3TypesofConditionalJumpInstructions191
6.3.3.1EqualityComparisons192
6.3.3.2UnsignedComparisons192
6.3.3.3SignedComparisons192
6.3.4ConditionalJumpApplications193
6.3.4.1TestingStatusBits193
6.3.4.2Application:ScanninganArray194
6.3.4.3Application:StringEncryption195
6.3.5BitTestingInstructions(Optional)198
6.3.5.1BTInstruction198
6.3.5.2BTCInstruction199
6.3.5.3BTRInstruction199
6.3.5.4BTSInstruction199
6.3.6SectionReview200
6.4ConditionalLoopInstructions200
6.4.1LOOPZandLOOPEInstructions200
6.4.2LOOPNZandLOOPNEInstructions201
6.4.3SectionReview202
6.5ConditionalStructures202
6.5.1Block-StructuredIFStatements202
6.5.2CompoundExpressions204
6.5.2.1LogicalANDOperator204
6.5.2.2LogicalOROperator205
6.5.3WHILELoops205
6.5.3.1Example:IFstatementNestedinaLoop206
6.5.4Table-DrivenSelection208
6.5.5SectionReview210
4.6Application:Finite-StateMachines211
6.6.1ValidatinganInputString212
6.6.2ValidatingaSignedInteger213
6.6.3SectionReview216
6.7Usingthe.IFDirective(Optional)217
6.7.1SignedandUnsignedComparisons219
6.7.2CompoundExpressions220
6.7.2.1SetCursorPositionExample220
6.7.2.2CollegeRegistrationExample221
6.7.3.REPEATand.WHILEDirectives222
6.7.3.1Example:LoopContaininganIFStatement222
6.8ChapterSummary223
6.9ProgrammingExercises224
7IntegerArithmetic227
7.1Introduction228
7.2ShiftandRotateInstructions228
7.2.1LogicalShiftsversusArithmeticShifts229
7.2.2SI-ILInstruction229
7.2.3SHRInstruction230
7.2.4SALandSARInstructions231
7.2.5ROLInstruction231
7.2.6RORInstruction232
7.2.7RCLandRCRInstructions232
7.2.8SHLD/SHRDInstructions233
7.2.9SectionReview235
7.3ShiftandRotateApplications236
7.3.1ShiftingMultipleDoublewords236
7.3.2BinaryMultiplication237
7.3.3DisplayingBinaryBits237
7.3.4IsolatingaBitString238
7.3.5SectionReview239
7.4MultiplicationandDivisionInstructions239
7.4.1MULInstruction240
7.4.2IMULInstruction241
7.4.3DIVInstruction242
7.4.4SignedIntegerDivision243
7.4.4.1CBW,CWD,CDQInstructions243
7,4.4.2TheIDIVInstruction243
7.4.4.3DivideOverflow244
7.4.5ImplementingArithmeticExpressions245
7.4.6SectionReview247
7.5ExtendedAdditionandSubtraction248
7.5.1ADCInstruction248
7.5.2ExtendedAdditionExample249
7.5.3SBBInstruction250
7.5.4SectionReview250
7.6ASCIIandPackedDecimalArithmetic(Optional)251
7.6.1AAAInstruction252
7.6.2AASInstruction253
7.6.3AAMInstruction253
7.6.4AADInstruction253
7.6.5PackedDecimalIntegers254
7.6.5.1DAAInstruction254
7.6,5.2DASInstruction254
7.7ChapterSummary255
7.8ProgrammingExercises256
8AdvancedProcedures259
8.1Introduction259
8.2LocalVariables260
8.2.1LOCALDirective261
8.2.2SectionReview263
8.3StackParameters263
8.3.1INVOKEDirective264
8.3.1.1DDROperator265
8.3.2PROCDirective266
8.3.2.1Examples267
8.3.3PROTODirective268
8.3.3.1ArraySumExample269
8.3.4PassingbyValueorbyReference269
8.3.5ParameterClassifications271
8.3.6Example:ExchangingTwoIntegers271
8.3.7Trouble-ShootingTips272
8.3.7.1SavingandRestoringRegisters272
8.3.7.2WrongOperandSizes273
8.3,7.3PassingtheWrongTypeofPointer274
8.3.7.4PassingImmediateValues274
8.3.8SectionReview274
8.4StackFrames275
8.4.1MemoryModels276
8.4.2LanguageSpecifiers277
8.4.2.1STDCALLSpecifier277
8.4,2.2CSpecifier278
8.4.2.3PASCALSpecifier278
8.4.3ExplicitAccesstoStackParameters278
8.4.2.1SavingandRestoringRegisters280
8.4.4PassingArgumentsbyReference280
8.4.4.1ArrayFillExample281
8.4.4.2LEAInstruction282
8.4.5CreatingLocalVariables282
8.4.6ENTERandLEAVEInstructions(Optional)283
8.4.7SectionReview285
8.5Recursion285
8.5.1RecursivelyCalculatingaSum286
8.5.2CalculatingaFactorial288
8.5.3SectionReview290
8.6CreatingMultimodulePrograms290
8.6.1Example:ArraySumProgram291
8.6.1.1IncludeFile:FunctionPrototypes292
8.6.1.2MainModule292
8.6.1.3PromptForlntegersModule293
8,6.1.4ArraySumModule294
8,6.1.5DisplaySumModule295
8.6.1.6BatchFileforAssemblingandLinking295
8.6.2SectionReview296
8.7ChapterSummary296
8.8ProgrammingExercises298
9StringsandArrays301
9.1Introduction301
9.2StringPrimitiveInstructions302
9.2.1MOVSB,MOVSW,andMOVSD304
9.2.2CMPSB,CMPSW,andCMPSD304
9.2.2.1Example:ComparingTwoStrings306
9.2.3SCASB,SCASW,andSCASD307
9.2.4STOSB,STOSW,andSTOSD308
9.2.5LODSB,LODSW,andLODSD308
9.2.6SectionReview309
9.3SelectedStringProcedures309
9.3.1Str_compareProcedure3l0
9.3.2StrlengthProcedure311
9.3.3StrcopyProcedure311
9.3.4Str_trimProcedure312
9.3.5Str_ucaseProcedure314
9.3.6SectionReview315
9.4Two-DimensionalArrays315
9.4.1Base-IndexOperands315
9.4.2Base-IndexDisplacement317
9.4.3SectionReview318
9.5SearchingandSortingIntegerArrays318
9.5.1BubbleSort319
9.5.2BinarySearch321
9.5.2.1TestProgram324
9.5.3SectionReview328
9.6ChapterSummary328
9.7ProgrammingExercises330
10StructuresandMacros333
10.1Structures334
10.1.1DefiningStructures334
10.1.2DeclaringStructureVariables335
10.1.3ReferencingStructureVariables336
10.1.4Example:DisplayingtheSystemTime338
10.1.5NestedStructures340
10.1.6Example:Drunkard'sWalk341
10.1.7DeclaringandUsingUnions344
10.1.8SectionReview346
10.2Macros347
10.2.1Overview347
10.2.2DefiningMacros348
10.2.3InvokingMacros349
10.2.4MacroExamples350
10.2.4.1mWriteStrMacro351
10.2.4,2mReadStrMacro352
10.2.4,3mGotoxyMacro352
10,2.4.4mDumpMemMacro353
10.2.4,5MacrosContainingCodeandData354
10.2.5NestedMacros355
10.2.6ExampleProgram:Wrappers356
10.2.7SectionReview357
10.3Conditional-AssemblyDirectives358
10.3.1CheckingforMissingArguments359
10.3.2DefaultArgumentInitializers360
10.3.3BooleanExpressions360
10.3.4IF,ELSE,andENDIFDirectives361
10.3.5TheIFIDNandIFIDNIDirectives362
10.3.6SpecialOperators363
10.3.6.1SubstitutionOperator(&)363
10.3.6.2ExpansionOperator(%)364
10.3.6.3Literal-TextOperator(<>)366
10.3.6.4Literal-CharacterOperator0)366
10.3.7MacroFunctions367
10.3.8SectionReview369
10.4DefiningRepeatBlocks370
10.4.1WHILEDirective370
10.4.2REPEATDirective371
10.4.3FORDirective371
10.4.4FORCDirective372
10.4.5Example:LinkedList373
10.4.6SectionReview375
10.5ChapterSummary375
10.6ProgrammingExercises376
1132-BitWindowsProgramming379
11.1Win32ConsoleProgramming379
11.1.1BackgroundInformation381
11.1.1.1WindowsDataTypes382
11.1.1.2ConsoleHandles383
11.1.2Win32ConsoleFunctions384
11.1.3ConsoleInput386
11.1.3.1ReadConsoleFunction387
11.1.3.2Single-CharacterInput388
11.1.4ConsoleOutput389
11.1.4.1DataStructures390
11.1.4.2WdteConsoleFunction390
11.1.4.3ExampleProgram:Console1390
11.1.4.4WriteConsoleOutputCharacterFunction391
11.1.5ReadingandWritingFiles392
11.1.5.1CreateFileFunction392
11,1.5.2CloseHandleFunction395
11.1.5.3ReadFileFunction395
11.1.5.4WriteFileFunction395
11.1.5,5ExampleWriteFileProgram396
11.1.5.6MovingtheFilePointer397
11,1.5.7ExampleReadFileProgram397
11.1.6ConsoleWindowManipulation398
11.1.6.1SetConsoleTiUe399
11.1.6.2GetConsoleScreenBufferlnfo399
11.1,6.3SetConsoleWindowlnfoFunction400
11.1.6.4SetConsoleScreenBufferSizeFunction402
11.1.7ControllingtheCursor402
11.1.7.1GetConsoleCursorlnfoFunction402
11.1.7.2SetConsoleCursorlnfoFunction402
11.1.7.3SetConsoleCursorPosition403
11.1.8ControllingtheTextColor403
11.1.8.1SetConsoleTextAttdbuteFunction403
11.1.8,2WdteConsoleOutputAttributeFunction403
11.1.8.3ExampleWriteColorsProgram403
11.1.9TimeandDateFunctions405
11.1.9.1GetkocalTimeandSetLocalTime406
11.1.9.2GetTickCountFunction407
11.1.9.3SleepFunction407
11.1.9.4GetDateTimeProcedure408
11.1.9,5CreatingaStopwatchTimer409
11.1.10SectionReview410
11.2WritingaGraphicalWindowsApplication411
11.2.1NecessaryStructures412
11.2.2TheMessageBoxFunction413
11.2.3TheWinMainProcedure414
11.2.4TheWinProcProcedure414
11.2.5TheErrorHandlerProcedure415
11.2.6ProgramListing416
11.2.6,1RunningtheProgram419
11.2.7SectionReview420
11.3IA-32MemoryManagement421
11.3.1LinearAddresses421
11.3.1.1TranslatingLogicalAddressestoLinearAddresses421
11.3.1.2Paging423
11.3.1.3DescriptorTables424
11.3.1.4SegmentDescriptorDetails425
11.3.2PageTranslation425
11.3.2.1MS-WindowsVirtualMachineManager426
11.3.3SectionReview427
11.4ChapterSummary428
11.5ProgrammingExercises429
12High-LevelLanguageInterface431
12.1Introduction431
12.1.1GeneralConventions431
12.1.2SectionReview433
12.2lnlineAssemblyCode433
12.2.1asmDirectiveinMicrosoftVisualC++433
12.2.1.1UsingtheLENGTH,TYPE,andSIZEOperators435
12.2.2FileEncryptionExample436
12.2.2.1ProcedureCallOverhead437
12.2.3SectionReview439
12.3LinkingtoC++Programs439
12.3.1LinkingtoBorlandC++440
12.3.2ReadSectorExample441
12.3.2.1MainC++ProgramThatCallsReadSector442
12.3,2.2AssemblyLanguageModule444
12.3.3Example:LargeRandomIntegers446
12.3.4UsingAssemblyLanguagetoOptimizeC++Code448
12.3.4.1FindArrayCode.GeneratedbyVisualC++449
12.3.4.2LinkingMASMtoVisualC++450
12.3.5SectionReview454
12.4ChapterSummary455
12.5ProgrammingExercises456
1316-BitMS-DOSProgramming457
13.1MS-DOSandtheIBM-PC457
13.1.1MemoryOrganization458
13.1.2RedirectingInput-Output460
13.1.3SoftwareInterrupts461
13.1.4INTInstmction461
13.1.4.1InterruptVectoring461
13.1.4.2CommonInterrupts462
13.1.5SectionReview462
13.2MS-DOSFunctionCalls(INT21h)463
13.2.1SelectedOutputFunctions464
13.2.2HelloWorldProgramExample467
13.2.3SelectedInputFunctions467
13.2.3.1Example:StringEncryptionProgram469
13.2.3.2Int21hFunction3Fh470
13.2.4Date/TimeFunctions472
13.2.4.1Example:DisplayingtheTimeandDate474
13.2.5SectionReview476
13.3StandardMS-DOSFileI/OServices476
13.3.0.1CreateorOpenFile(716Ch)478
13.3.1CloseFileHandle(3Eh)479
13.3.2MoveFilePointer(42h)480
13.3.2.1GetFileCreationDateandTime481
13.3.3SelectedLibraryProcedures481
13.3.3.1ReadString482
13.3.3.2WriteString482
13.3.4Example:ReadandCopyaTextFile483
13.3.5ReadingtheMS-DOSCommandTail485
13.3.6Example:CreatingaBinaryFile487
13.3.7SectionReview490
13AChapterSummary491
13.5ChapterExercises492
14DiskFundamentals495
14.1DiskStorageSystems495
14.1.1Tracks,Cylinders,andSectors496
14.1.2DiskPartitions(Volumes)498
14.1.3SectionReview499
14.2FileSystems500
14.2.1FAT12501
14.2.2FAT16501
14.2.3FAT32501
14.2.4NTFS502
14.2.5PrimaryDiskAreas503
14.2.6SectionReview504
14.3DiskDirectory505
14.3.1MS-DOSDirectoryStructure505
14.3.2LongFilenamesinMS-Windows508
14.3.3FileAllocationTable(FAT)510
14.3.4SectionReview511
14.4ReadingandWritingDiskSectors(7305h)511
14.4.1SectorDisplayProgram513
14.4.2SectionReview517
14.5System-LevelFileFunctions517
14.5.1GetDiskFreeSpace(7303h)518
14.5.1.1DiskFreeSpaceProgram519
14.5.2CreateSubdirectory(39h)521
14.5.3RemoveSubdirectory(3Ah)521
14.5.4SetCurrentDirectory(3Bh)522
14.5.5GetCurrentDirectory(47h)522
14.5.6SectionReview522
14.6ChapterSummary523
14.7ProgrammingExercises524
15BIOS-LevelProgramming527
15.1Introduction527
15.1.1BIOSDataArea528
15.2KeyboardInputwithINT16h529
15.2.1HowtheKeyboardWorks530
15.2.2INT16hFunctions531
15.2.2.1SetTypematicRate(03h)531
15.2.2.2PushKeyintoKeyboardBuffer(05h)531
15.2.2.3WaitforKey(1Oh)532
15.2.2.4CheckKeyboardBuffer(11h)533
15.2.2.5GetKeyboardFlags534
15.2.2.6ClearingtheKeyboardBuffer535
15.2.3SectionReview537
15.3VIDEOProgrammingwithINT10h537
15.3.1BasicBackground537
15.3.1.1ThreeLevelsofAccess537
15.3.1.2RunningProgramsinFull-ScreenMode538
15.3.1.3UnderstandingVideoText538
15.3.2ControllingtheColor539
15.3.2.1MixingPrimaryColors539
15.3.2.2AttributeByte540
15.3.3INT10hVideoFunctions541
15.3.3.1SetVideoMode(00h)542
15.3.3.215.3.3.SetCursorLines(01h)543
15.3.3.3SetCursorPosition(02h)544
15.3.3.4GetCursorPositionandSize(03h)544
15.3.3.5ScrollWindowUp(06h)546
15.3.3.6Example:WritingTexttoaWindow547
15.3.3.7ScrollWindowDown(07h)548
15.3.3,8ReadCharacterandAttribute(08h)548
15.3.3.9WriteCharacterandAttribute(09h)548
15.3.3.10WriteCharacter(0Ah)549
15.3.3.11ToggleBlinkingandIntensityModes550
15.3.3.12GetVideoModeInformation(0Fh)550
15.3.3.13WriteStringinTeletypeMode(13h)551
15.3.3.14Example:DisplayingaColorString552
15.3.4LibraryProcedureExamples554
15.3.4.1GotoxyProcedure554
15.3.4.2ClrscrProcedure554
15.3.5SectionReview555
15.4DrawingGraphicsUsingINT10h555
15.4.1INT10hPixel-RelatedFunctions556
15.4.1.1WriteGraphicsPixel(0Ch)556
15.4.1.2ReadGraphicsPixel(0Dh)557
15.4.2DrawLineProgram557
15.4.3CartesianCoordinatesProgram559
15.4.4ConvertingCartesianCoordinatestoScreenCoordinates562
15,4.5SectionReview563
15.6Memory-MappedGraphics563
15.5.1Mode13h:320X200,256Colors563
15.5.2Memory-MappedGraphicsProgram565
15.5.3SectionReview568
15.6MouseProgramming568
15.6.1MouseINT33hFunctions568
15.6.1.1ResetMouseandGetStatus568
15.6.1.2ShowingandHidingtheMousePointer569
15.6.1,3GetMousePositionandStatus570
15.6.1.4SetMousePosition571
15.6.1.5GetButtonPressesandReleases571
15.6.1.6SettingHorizontalandVerticalLimits573
15.6.1.7MiscellaneousMouseFunctions573
15.6.2MouseTrackingProgram574
15.6.3SectionReview579
15.7ChapterSummary580
15.8ChapterExercises580
16ExpertMS-DOSProgramming583
16.1Introduction583
16.2DefiningSegments584
16.2.1SimplifiedSegmentDirectives584
16.2.2ExplicitSegmentDefinitions586
16.2.2.1AlignType587
16.2.2.2CombineType587
16.2.2.3ClassType588
16.2.2.4ASSUMEDirective588
16.2.2.5Example:MultipleDataSegments588
16.2.3SegmentOverrides589
16.2.4CombiningSegments590
16.2.5SectionReview592
16.3RuntimeProgramStructure592
16.3.1COMPrograms593
16.3.2EXEPrograms595
16.3.2.1MemoryUsage595
16.3.2.2EXEHeader596
16.3.3SectionReview597
16.4InterruptHandling597
16.4.1HardwareInterrupts599
16.4.2InterruptControlInstructions600
16.4.3WritingaCustomInterruptHandler601
16.4.3.1CtrI-BreakHandlerExample602
16.4.4TerminateandStayResidentPrograms604
16.4.4.1KeyboardExample604
16.4.5Application:TheNo_ResetProgram605
16.4.6SectionReview609
16.5ChapterSummary609
17AdvancedTopics
Chapter17isanadditionalchapterprovidedasaPDFfileontheCD-ROM
accompanyingthisbook.
17.1HardwareControlUsingFOPorts17-1
17.1.1Input-OutputPorts17-1
17.1.1.1PCSoundProgram17-2
17.2IntelInstructionEncoding17-4
17.2.1Single-ByteInstructions17-5
17.2.2ImmediateOperands17-6
17.2.3Register-ModeInstructions17-6
17.2.4Memory-ModeInstructions17-7
17.2.4.1MOVInstructionExamples17-9
17.2.5SectionReview17-11
17.3Floating-PointArithmetic17-12
17.3.1IEEEBinaryFloating-PointRepresentation17-12
17.3.1.1TheSign17-12
17.3.1.2TheMantissa17-12
17.3.2TheExponent17-13
17.3.3NormalizingtheMantissa17-14
17.3.4CreatingtheIEEEBitRepresentation17-15
17.3.5ConvertingDecimalFractionstoBinaryReals17-15
17.3.6IA-32FloatingPointArchitecture17-17
17.3.7InstructionFormats17-18
17.3.8Floating-PointCodeExamples17-21
17.3.8,1Example1:EvaluatinganExpression17-21
AppendixA:InstallingandUsingthe
Assembler611
AppendixB:TheIntelInstructionSet617
AppendixC:BIOSandMS-DOSInterrupts649
AppendixD:MASMReference661
1BasicConcepts1
1.1WelcometoAssemblyLanguage1
1.1.1SomeGoodQuestionstoAsk2
1.1.2AssemblyLanguageApplications7
1.1.3SectionReview8
1.2VirtualMachineConcept8
1.2.1TheHistoryofPCAssemblers1l
1.2.2SectionReview12
1.3DataRepresentation12
1.3.1BinaryNumbers13
1.3.1.1UnsignedBinarylntegers13
1.3.1.2TranslatingUnsignedBinaryIntegerstoDecimal14
1.3.1.3TranslatingUnsignedDecimalIntegerstoBinary14
1.3.2BinaryAddition15
1.3.3IntegerStorageSizes16
1.3.4HexadecimalIntegers16
1.3.4.1ConvertingUnsignedHexadecimaltoDecimal17
1.3.4.2ConvertingUnsignedDecimaltoHexadecimal18
1.3.5SignedIntegers18
1.3.5.1Two'sComplementNotation19
1.3.5.2MaximumandMinimumValues21
1.3.6CharacterStorage2i
1.3.7SectionReview23
1.4BooleanOperations25
1.4.1TruthTablesforBooleanFunctions27
1.4.2SectionReview29
1.5ChapterSummary29
2IA-32ProcessorArchitecture31
2.1GeneralConcepts31
2.1.1BasicMicrocomputerDesign32
2.1.2InstructionExecutionCycle33
2.1.2.1Multi-StagePipeline34
2.1.2.2SuperscalarAmhitecture36
2.1.3ReadingfromMemory37
2.1.4HowProgramsRun38
2.1.4.1LoadandExecuteProcess38
2.1,4,2Multitasking39
2.1.5SectionReview40
2.2IA-32ProcessorArchitecture41
2.2.1ModesofOperation41
2.2.2BasicExecutionEnvironment41
2.2.2.1AddressSpace41
2.2.2.1BasicProgramExecutionRegisters42
2.2.3Floating-PointUnit44
2.2.3.1OtherRegisters44
2.2.4IntelMicroprocessorHistory45
2.2.4.1IA-32ProcessorFamily46
2.2.4.2P6ProcessorFamily46
2,2.4.3CISCand'RISC46
2.2.5SectionReview47
2.3IA-32MemoryManagement48
2.3.1Real-addressMode48
2.3.1.120-bitLinearAddressCalculation49
2.3.2ProtectedMode50
2.3.2.1FlatSegmentationModel50
2.3.2.2Multi-SegmentModel51
2.3.2.3Paging52
2.3.3SectionReview53
2.4ComponentsofanIA-32Microcomputer53
2.4.1Motherboard53
2.4.1.1PCIBusArchitecture54
2.4.1.2MotherboardChipset54
2.4.2VideoOutput55
2.4.3Memory55
2.4.4Input-OutputPorts56
2.4.5SectionReview57
2.5Input-OutputSystem57
2.5.1HowitAllWorks57
2.5.2SectionReview60
2.6ChapterSummary60
3AssemblyLanguageFundamentals63
3.1BasicElementsofAssemblyLanguage64
3.1.1IntegerConstants64
3.1.2IntegerExpressions65
3.1.3RealNumberConstants66
3.1.4CharacterConstants67
3.1.5StringConstants67
3.1.6ReservedWords67
3.1.7Identifiers67
3.1.8Directives68
3.1.9Instructions68
3.1.9.1Label69
3.1.9.2InstructionMnemonic70
3.1.9.3Operands70
3.1.9.4Comments71
3.1.10SectionReview71
3.2Example:AddingThreeintegers72
3.2.1ProgramListing72
3.2.2ProgramOutput72
3.2.3ProgramDescription73
3.2.3.1AlternativeVersionofAddSub74
3.2.4ProgramTemplate76
3.2.5SectionReview76
3.3Assembling,Linking,andRunningPrograms77
3.3.1TheAssemble-Link-ExecuteCycle77
3.3.1.1listingFile78
3.3.1.2FilesCreatedorUpdatedbytheLinker79
3.3.2SectionReview80
3.4DefiningData80
3.4.1IntrinsicDataTypes80
3.4.2DataDefinitionStatement81
3.4.3DefiningBYTEandSBYTEData81
3.4.3.1MultipleInitializers82
3.4.3,2DefiningStrings83
3.4.3.3UsingtheDUPOperator83
3.4.4DefiningWORDandSWORDData84
3.4.5DefiningDWORDandSDWORDData84
3.4.6DefiningQWORDData85
3.4.7DefiningTBYTEData85
3.4.8DefiningRealNumberData85
3.4.9LittleEndianOrder86
3.4.10AddingVariablestotheAddSubProgram87
3.4.11DeclaringUninitializedData87
3.4.12SectionReview88
3.5SymbolicConstants89
3.5.1Equal-SignDirective89
3.5.2CalculatingtheSizesofArraysandStrings90
3.5.3EQUDirective91
3.5.4TEXTEQUDirective92
3.5.5SectionReview93
3.6Real-AddressModeProgramming(Optional)93
3.6.1BasicChanges94
3.6.1.1TheAddSub2Program94
3.7ChapterSummary95
3.8ProgrammingExercises96
4DataTransfers,Addressing,andArithmetic97
4.1DataTransferInstructions98
4.1.1Introduction98
4.1.2OperandTypes98
4.1.3DirectMemoryOperands99
4.1.4MOVInstruction100
4.1.5Zero/SignExtensionofIntegers101
4.1.5.1CopyingSmallerValuestoLargerOnes101
4.1.5.2MOVZXInstruction102
4.1.5.3MOVSXInstruction103
4.1.6LAHFandSAI-IFInstructions103
4.1.7XCHGInstruction104
4.1.8Direct-OffsetOperants104
4.1.9ExampleProgram(Moves)105
4.1.10SectionReview106
4.2AdditionandSubtraction107
4.2.1INCandDECInstmctions107
4.2.2ADDInstruction108
4.2.3SUBInstruction108
4.2.4NEGInstruction109
4.2.5ImplementingArithmeticExpressions109
4.2.6FlagsAffectedbyArithmetic110
4.2.6.1ZeroandSignFlags110
4.2.6.2CarryFlag(unsignedarithmetic)110
4.2.6.3OverflowFlag(signedarithmetic)111
4.2.7ExampleProgram(AddSub3)113
4.2.8SectionReview114
4.3Data-RelatedOperatorsandDirectives115
4.3.1OFFSETOperator115
4.3.1.1OFFSETExample115
4.3.2ALIGNDirective116
4.3.3PTROperator117
4.3.4TYPEOperator118
4.3.5LENGTHOFOperator118
4.3.6SIZEOFOperator119
4.3.7LABELDirective119
4.3.8SectionReview120
4.4IndirectAddressing120
4.4.1IndirectOperands121
4.4.2Arrays122
4.4.3Indexedoperands123
4.4.4Pointers124
4.4.4.1UsingtheTYPDEFOperator125
4.4.5SectionReview126
4.5JMPandLOOPInstructions127
4.5.1JMPInstruction127
4.5.2LOOPInstruction128
4.5.3SumminganIntegerArray129
4.5.4CopyingaString130
4.5.5SectionReview131
4.6ChapterSummary132
4.7ProgrammingExercises133
5Procedures137
5.1Introduction137
5.2LinkingtoanExternalLibrary138
5.2.1BackgroundInformation138
5.2.2SectionReview139
5.3TheBook'sLinkLibrary140
5.3.1Overview140
5.3.2IndividualProcedureDescriptions141
5.3.2.1TheIrvine32.incIncludeFile147
5.3.3LibraryTestProgram148
5.3.4SectionReview152
5.4StackOperations153
5.4.1RuntimeStack153
5.4.1.1PushOperation154
5.4.1.2PopOperation155
5.4.1.3StackApplications155
5.4.2PUSHandPOPInstructions156
5.4.2.1PUSHInstruction156
5.4.2.2POPInstruction1,56
5.4.2.3PUSHFDandPOPFDInstructions156
5.4.2.4PUSHAD,PUSHA,POPAD,andPOPA157
5.4.2.5Example:ReversingaString157
5.4.3SectionReview158
5.5DefiningandUsingProcedures159
5.5.1PROCDirective159
5.5.1.1DefiningaProcedure159
5.5.1.2Example:SumofThreeIntegers160
DocumentingProcedures160
5.5.2CALLandRETInstructions161
5.5.2.1CallandReturnExample161
5.5.2.2NestedProcedureCalls162
5.5.2.3LocalLabelsandGlobalLabels163
5.5.2.4PassingRegisterArgumentstoProcedures164
5.5.3Example:SumminganIntegerArray164
5.5.4Flowcharts165
5.5.5SavingandRestoringRegisters166
5.5.5.1USESOperator166
5.5.6SectionReview168
5.6ProgramDesignUsingProcedures169
5.6.1IntegerSummationProgram(Design)170
5.6.1.1IntegerSummationImplementation172
5.6.2SectionReview175
5.7ChapterSummary175
5.8ProgrammingExercises176
6ConditionalProcessing179
6.1Introduction180
6.2BooleanandComparisonInstructions180
6.2,1TheCPUFlags181
6.2.2ANDInstruction181
6.2.2.1ConvertingCharacterstoUpperCase182
6.2.3ORInstruction183
6.2.4XORInstruction184
6.2.5NOTInstruction186
6.2.6TESTInstruction186
6.2.7CMPInstruction186
6.2.8SettingandClearingIndividualCPUFlags188
6.2.9SectionReview188
6,3ConditionalJumps189
6.3.1ConditionalStructures189
6.3.2JcondInstruction190
6.3.3TypesofConditionalJumpInstructions191
6.3.3.1EqualityComparisons192
6.3.3.2UnsignedComparisons192
6.3.3.3SignedComparisons192
6.3.4ConditionalJumpApplications193
6.3.4.1TestingStatusBits193
6.3.4.2Application:ScanninganArray194
6.3.4.3Application:StringEncryption195
6.3.5BitTestingInstructions(Optional)198
6.3.5.1BTInstruction198
6.3.5.2BTCInstruction199
6.3.5.3BTRInstruction199
6.3.5.4BTSInstruction199
6.3.6SectionReview200
6.4ConditionalLoopInstructions200
6.4.1LOOPZandLOOPEInstructions200
6.4.2LOOPNZandLOOPNEInstructions201
6.4.3SectionReview202
6.5ConditionalStructures202
6.5.1Block-StructuredIFStatements202
6.5.2CompoundExpressions204
6.5.2.1LogicalANDOperator204
6.5.2.2LogicalOROperator205
6.5.3WHILELoops205
6.5.3.1Example:IFstatementNestedinaLoop206
6.5.4Table-DrivenSelection208
6.5.5SectionReview210
4.6Application:Finite-StateMachines211
6.6.1ValidatinganInputString212
6.6.2ValidatingaSignedInteger213
6.6.3SectionReview216
6.7Usingthe.IFDirective(Optional)217
6.7.1SignedandUnsignedComparisons219
6.7.2CompoundExpressions220
6.7.2.1SetCursorPositionExample220
6.7.2.2CollegeRegistrationExample221
6.7.3.REPEATand.WHILEDirectives222
6.7.3.1Example:LoopContaininganIFStatement222
6.8ChapterSummary223
6.9ProgrammingExercises224
7IntegerArithmetic227
7.1Introduction228
7.2ShiftandRotateInstructions228
7.2.1LogicalShiftsversusArithmeticShifts229
7.2.2SI-ILInstruction229
7.2.3SHRInstruction230
7.2.4SALandSARInstructions231
7.2.5ROLInstruction231
7.2.6RORInstruction232
7.2.7RCLandRCRInstructions232
7.2.8SHLD/SHRDInstructions233
7.2.9SectionReview235
7.3ShiftandRotateApplications236
7.3.1ShiftingMultipleDoublewords236
7.3.2BinaryMultiplication237
7.3.3DisplayingBinaryBits237
7.3.4IsolatingaBitString238
7.3.5SectionReview239
7.4MultiplicationandDivisionInstructions239
7.4.1MULInstruction240
7.4.2IMULInstruction241
7.4.3DIVInstruction242
7.4.4SignedIntegerDivision243
7.4.4.1CBW,CWD,CDQInstructions243
7,4.4.2TheIDIVInstruction243
7.4.4.3DivideOverflow244
7.4.5ImplementingArithmeticExpressions245
7.4.6SectionReview247
7.5ExtendedAdditionandSubtraction248
7.5.1ADCInstruction248
7.5.2ExtendedAdditionExample249
7.5.3SBBInstruction250
7.5.4SectionReview250
7.6ASCIIandPackedDecimalArithmetic(Optional)251
7.6.1AAAInstruction252
7.6.2AASInstruction253
7.6.3AAMInstruction253
7.6.4AADInstruction253
7.6.5PackedDecimalIntegers254
7.6.5.1DAAInstruction254
7.6,5.2DASInstruction254
7.7ChapterSummary255
7.8ProgrammingExercises256
8AdvancedProcedures259
8.1Introduction259
8.2LocalVariables260
8.2.1LOCALDirective261
8.2.2SectionReview263
8.3StackParameters263
8.3.1INVOKEDirective264
8.3.1.1DDROperator265
8.3.2PROCDirective266
8.3.2.1Examples267
8.3.3PROTODirective268
8.3.3.1ArraySumExample269
8.3.4PassingbyValueorbyReference269
8.3.5ParameterClassifications271
8.3.6Example:ExchangingTwoIntegers271
8.3.7Trouble-ShootingTips272
8.3.7.1SavingandRestoringRegisters272
8.3.7.2WrongOperandSizes273
8.3,7.3PassingtheWrongTypeofPointer274
8.3.7.4PassingImmediateValues274
8.3.8SectionReview274
8.4StackFrames275
8.4.1MemoryModels276
8.4.2LanguageSpecifiers277
8.4.2.1STDCALLSpecifier277
8.4,2.2CSpecifier278
8.4.2.3PASCALSpecifier278
8.4.3ExplicitAccesstoStackParameters278
8.4.2.1SavingandRestoringRegisters280
8.4.4PassingArgumentsbyReference280
8.4.4.1ArrayFillExample281
8.4.4.2LEAInstruction282
8.4.5CreatingLocalVariables282
8.4.6ENTERandLEAVEInstructions(Optional)283
8.4.7SectionReview285
8.5Recursion285
8.5.1RecursivelyCalculatingaSum286
8.5.2CalculatingaFactorial288
8.5.3SectionReview290
8.6CreatingMultimodulePrograms290
8.6.1Example:ArraySumProgram291
8.6.1.1IncludeFile:FunctionPrototypes292
8.6.1.2MainModule292
8.6.1.3PromptForlntegersModule293
8,6.1.4ArraySumModule294
8,6.1.5DisplaySumModule295
8.6.1.6BatchFileforAssemblingandLinking295
8.6.2SectionReview296
8.7ChapterSummary296
8.8ProgrammingExercises298
9StringsandArrays301
9.1Introduction301
9.2StringPrimitiveInstructions302
9.2.1MOVSB,MOVSW,andMOVSD304
9.2.2CMPSB,CMPSW,andCMPSD304
9.2.2.1Example:ComparingTwoStrings306
9.2.3SCASB,SCASW,andSCASD307
9.2.4STOSB,STOSW,andSTOSD308
9.2.5LODSB,LODSW,andLODSD308
9.2.6SectionReview309
9.3SelectedStringProcedures309
9.3.1Str_compareProcedure3l0
9.3.2StrlengthProcedure311
9.3.3StrcopyProcedure311
9.3.4Str_trimProcedure312
9.3.5Str_ucaseProcedure314
9.3.6SectionReview315
9.4Two-DimensionalArrays315
9.4.1Base-IndexOperands315
9.4.2Base-IndexDisplacement317
9.4.3SectionReview318
9.5SearchingandSortingIntegerArrays318
9.5.1BubbleSort319
9.5.2BinarySearch321
9.5.2.1TestProgram324
9.5.3SectionReview328
9.6ChapterSummary328
9.7ProgrammingExercises330
10StructuresandMacros333
10.1Structures334
10.1.1DefiningStructures334
10.1.2DeclaringStructureVariables335
10.1.3ReferencingStructureVariables336
10.1.4Example:DisplayingtheSystemTime338
10.1.5NestedStructures340
10.1.6Example:Drunkard'sWalk341
10.1.7DeclaringandUsingUnions344
10.1.8SectionReview346
10.2Macros347
10.2.1Overview347
10.2.2DefiningMacros348
10.2.3InvokingMacros349
10.2.4MacroExamples350
10.2.4.1mWriteStrMacro351
10.2.4,2mReadStrMacro352
10.2.4,3mGotoxyMacro352
10,2.4.4mDumpMemMacro353
10.2.4,5MacrosContainingCodeandData354
10.2.5NestedMacros355
10.2.6ExampleProgram:Wrappers356
10.2.7SectionReview357
10.3Conditional-AssemblyDirectives358
10.3.1CheckingforMissingArguments359
10.3.2DefaultArgumentInitializers360
10.3.3BooleanExpressions360
10.3.4IF,ELSE,andENDIFDirectives361
10.3.5TheIFIDNandIFIDNIDirectives362
10.3.6SpecialOperators363
10.3.6.1SubstitutionOperator(&)363
10.3.6.2ExpansionOperator(%)364
10.3.6.3Literal-TextOperator(<>)366
10.3.6.4Literal-CharacterOperator0)366
10.3.7MacroFunctions367
10.3.8SectionReview369
10.4DefiningRepeatBlocks370
10.4.1WHILEDirective370
10.4.2REPEATDirective371
10.4.3FORDirective371
10.4.4FORCDirective372
10.4.5Example:LinkedList373
10.4.6SectionReview375
10.5ChapterSummary375
10.6ProgrammingExercises376
1132-BitWindowsProgramming379
11.1Win32ConsoleProgramming379
11.1.1BackgroundInformation381
11.1.1.1WindowsDataTypes382
11.1.1.2ConsoleHandles383
11.1.2Win32ConsoleFunctions384
11.1.3ConsoleInput386
11.1.3.1ReadConsoleFunction387
11.1.3.2Single-CharacterInput388
11.1.4ConsoleOutput389
11.1.4.1DataStructures390
11.1.4.2WdteConsoleFunction390
11.1.4.3ExampleProgram:Console1390
11.1.4.4WriteConsoleOutputCharacterFunction391
11.1.5ReadingandWritingFiles392
11.1.5.1CreateFileFunction392
11,1.5.2CloseHandleFunction395
11.1.5.3ReadFileFunction395
11.1.5.4WriteFileFunction395
11.1.5,5ExampleWriteFileProgram396
11.1.5.6MovingtheFilePointer397
11,1.5.7ExampleReadFileProgram397
11.1.6ConsoleWindowManipulation398
11.1.6.1SetConsoleTiUe399
11.1.6.2GetConsoleScreenBufferlnfo399
11.1,6.3SetConsoleWindowlnfoFunction400
11.1.6.4SetConsoleScreenBufferSizeFunction402
11.1.7ControllingtheCursor402
11.1.7.1GetConsoleCursorlnfoFunction402
11.1.7.2SetConsoleCursorlnfoFunction402
11.1.7.3SetConsoleCursorPosition403
11.1.8ControllingtheTextColor403
11.1.8.1SetConsoleTextAttdbuteFunction403
11.1.8,2WdteConsoleOutputAttributeFunction403
11.1.8.3ExampleWriteColorsProgram403
11.1.9TimeandDateFunctions405
11.1.9.1GetkocalTimeandSetLocalTime406
11.1.9.2GetTickCountFunction407
11.1.9.3SleepFunction407
11.1.9.4GetDateTimeProcedure408
11.1.9,5CreatingaStopwatchTimer409
11.1.10SectionReview410
11.2WritingaGraphicalWindowsApplication411
11.2.1NecessaryStructures412
11.2.2TheMessageBoxFunction413
11.2.3TheWinMainProcedure414
11.2.4TheWinProcProcedure414
11.2.5TheErrorHandlerProcedure415
11.2.6ProgramListing416
11.2.6,1RunningtheProgram419
11.2.7SectionReview420
11.3IA-32MemoryManagement421
11.3.1LinearAddresses421
11.3.1.1TranslatingLogicalAddressestoLinearAddresses421
11.3.1.2Paging423
11.3.1.3DescriptorTables424
11.3.1.4SegmentDescriptorDetails425
11.3.2PageTranslation425
11.3.2.1MS-WindowsVirtualMachineManager426
11.3.3SectionReview427
11.4ChapterSummary428
11.5ProgrammingExercises429
12High-LevelLanguageInterface431
12.1Introduction431
12.1.1GeneralConventions431
12.1.2SectionReview433
12.2lnlineAssemblyCode433
12.2.1asmDirectiveinMicrosoftVisualC++433
12.2.1.1UsingtheLENGTH,TYPE,andSIZEOperators435
12.2.2FileEncryptionExample436
12.2.2.1ProcedureCallOverhead437
12.2.3SectionReview439
12.3LinkingtoC++Programs439
12.3.1LinkingtoBorlandC++440
12.3.2ReadSectorExample441
12.3.2.1MainC++ProgramThatCallsReadSector442
12.3,2.2AssemblyLanguageModule444
12.3.3Example:LargeRandomIntegers446
12.3.4UsingAssemblyLanguagetoOptimizeC++Code448
12.3.4.1FindArrayCode.GeneratedbyVisualC++449
12.3.4.2LinkingMASMtoVisualC++450
12.3.5SectionReview454
12.4ChapterSummary455
12.5ProgrammingExercises456
1316-BitMS-DOSProgramming457
13.1MS-DOSandtheIBM-PC457
13.1.1MemoryOrganization458
13.1.2RedirectingInput-Output460
13.1.3SoftwareInterrupts461
13.1.4INTInstmction461
13.1.4.1InterruptVectoring461
13.1.4.2CommonInterrupts462
13.1.5SectionReview462
13.2MS-DOSFunctionCalls(INT21h)463
13.2.1SelectedOutputFunctions464
13.2.2HelloWorldProgramExample467
13.2.3SelectedInputFunctions467
13.2.3.1Example:StringEncryptionProgram469
13.2.3.2Int21hFunction3Fh470
13.2.4Date/TimeFunctions472
13.2.4.1Example:DisplayingtheTimeandDate474
13.2.5SectionReview476
13.3StandardMS-DOSFileI/OServices476
13.3.0.1CreateorOpenFile(716Ch)478
13.3.1CloseFileHandle(3Eh)479
13.3.2MoveFilePointer(42h)480
13.3.2.1GetFileCreationDateandTime481
13.3.3SelectedLibraryProcedures481
13.3.3.1ReadString482
13.3.3.2WriteString482
13.3.4Example:ReadandCopyaTextFile483
13.3.5ReadingtheMS-DOSCommandTail485
13.3.6Example:CreatingaBinaryFile487
13.3.7SectionReview490
13AChapterSummary491
13.5ChapterExercises492
14DiskFundamentals495
14.1DiskStorageSystems495
14.1.1Tracks,Cylinders,andSectors496
14.1.2DiskPartitions(Volumes)498
14.1.3SectionReview499
14.2FileSystems500
14.2.1FAT12501
14.2.2FAT16501
14.2.3FAT32501
14.2.4NTFS502
14.2.5PrimaryDiskAreas503
14.2.6SectionReview504
14.3DiskDirectory505
14.3.1MS-DOSDirectoryStructure505
14.3.2LongFilenamesinMS-Windows508
14.3.3FileAllocationTable(FAT)510
14.3.4SectionReview511
14.4ReadingandWritingDiskSectors(7305h)511
14.4.1SectorDisplayProgram513
14.4.2SectionReview517
14.5System-LevelFileFunctions517
14.5.1GetDiskFreeSpace(7303h)518
14.5.1.1DiskFreeSpaceProgram519
14.5.2CreateSubdirectory(39h)521
14.5.3RemoveSubdirectory(3Ah)521
14.5.4SetCurrentDirectory(3Bh)522
14.5.5GetCurrentDirectory(47h)522
14.5.6SectionReview522
14.6ChapterSummary523
14.7ProgrammingExercises524
15BIOS-LevelProgramming527
15.1Introduction527
15.1.1BIOSDataArea528
15.2KeyboardInputwithINT16h529
15.2.1HowtheKeyboardWorks530
15.2.2INT16hFunctions531
15.2.2.1SetTypematicRate(03h)531
15.2.2.2PushKeyintoKeyboardBuffer(05h)531
15.2.2.3WaitforKey(1Oh)532
15.2.2.4CheckKeyboardBuffer(11h)533
15.2.2.5GetKeyboardFlags534
15.2.2.6ClearingtheKeyboardBuffer535
15.2.3SectionReview537
15.3VIDEOProgrammingwithINT10h537
15.3.1BasicBackground537
15.3.1.1ThreeLevelsofAccess537
15.3.1.2RunningProgramsinFull-ScreenMode538
15.3.1.3UnderstandingVideoText538
15.3.2ControllingtheColor539
15.3.2.1MixingPrimaryColors539
15.3.2.2AttributeByte540
15.3.3INT10hVideoFunctions541
15.3.3.1SetVideoMode(00h)542
15.3.3.215.3.3.SetCursorLines(01h)543
15.3.3.3SetCursorPosition(02h)544
15.3.3.4GetCursorPositionandSize(03h)544
15.3.3.5ScrollWindowUp(06h)546
15.3.3.6Example:WritingTexttoaWindow547
15.3.3.7ScrollWindowDown(07h)548
15.3.3,8ReadCharacterandAttribute(08h)548
15.3.3.9WriteCharacterandAttribute(09h)548
15.3.3.10WriteCharacter(0Ah)549
15.3.3.11ToggleBlinkingandIntensityModes550
15.3.3.12GetVideoModeInformation(0Fh)550
15.3.3.13WriteStringinTeletypeMode(13h)551
15.3.3.14Example:DisplayingaColorString552
15.3.4LibraryProcedureExamples554
15.3.4.1GotoxyProcedure554
15.3.4.2ClrscrProcedure554
15.3.5SectionReview555
15.4DrawingGraphicsUsingINT10h555
15.4.1INT10hPixel-RelatedFunctions556
15.4.1.1WriteGraphicsPixel(0Ch)556
15.4.1.2ReadGraphicsPixel(0Dh)557
15.4.2DrawLineProgram557
15.4.3CartesianCoordinatesProgram559
15.4.4ConvertingCartesianCoordinatestoScreenCoordinates562
15,4.5SectionReview563
15.6Memory-MappedGraphics563
15.5.1Mode13h:320X200,256Colors563
15.5.2Memory-MappedGraphicsProgram565
15.5.3SectionReview568
15.6MouseProgramming568
15.6.1MouseINT33hFunctions568
15.6.1.1ResetMouseandGetStatus568
15.6.1.2ShowingandHidingtheMousePointer569
15.6.1,3GetMousePositionandStatus570
15.6.1.4SetMousePosition571
15.6.1.5GetButtonPressesandReleases571
15.6.1.6SettingHorizontalandVerticalLimits573
15.6.1.7MiscellaneousMouseFunctions573
15.6.2MouseTrackingProgram574
15.6.3SectionReview579
15.7ChapterSummary580
15.8ChapterExercises580
16ExpertMS-DOSProgramming583
16.1Introduction583
16.2DefiningSegments584
16.2.1SimplifiedSegmentDirectives584
16.2.2ExplicitSegmentDefinitions586
16.2.2.1AlignType587
16.2.2.2CombineType587
16.2.2.3ClassType588
16.2.2.4ASSUMEDirective588
16.2.2.5Example:MultipleDataSegments588
16.2.3SegmentOverrides589
16.2.4CombiningSegments590
16.2.5SectionReview592
16.3RuntimeProgramStructure592
16.3.1COMPrograms593
16.3.2EXEPrograms595
16.3.2.1MemoryUsage595
16.3.2.2EXEHeader596
16.3.3SectionReview597
16.4InterruptHandling597
16.4.1HardwareInterrupts599
16.4.2InterruptControlInstructions600
16.4.3WritingaCustomInterruptHandler601
16.4.3.1CtrI-BreakHandlerExample602
16.4.4TerminateandStayResidentPrograms604
16.4.4.1KeyboardExample604
16.4.5Application:TheNo_ResetProgram605
16.4.6SectionReview609
16.5ChapterSummary609
17AdvancedTopics
Chapter17isanadditionalchapterprovidedasaPDFfileontheCD-ROM
accompanyingthisbook.
17.1HardwareControlUsingFOPorts17-1
17.1.1Input-OutputPorts17-1
17.1.1.1PCSoundProgram17-2
17.2IntelInstructionEncoding17-4
17.2.1Single-ByteInstructions17-5
17.2.2ImmediateOperands17-6
17.2.3Register-ModeInstructions17-6
17.2.4Memory-ModeInstructions17-7
17.2.4.1MOVInstructionExamples17-9
17.2.5SectionReview17-11
17.3Floating-PointArithmetic17-12
17.3.1IEEEBinaryFloating-PointRepresentation17-12
17.3.1.1TheSign17-12
17.3.1.2TheMantissa17-12
17.3.2TheExponent17-13
17.3.3NormalizingtheMantissa17-14
17.3.4CreatingtheIEEEBitRepresentation17-15
17.3.5ConvertingDecimalFractionstoBinaryReals17-15
17.3.6IA-32FloatingPointArchitecture17-17
17.3.7InstructionFormats17-18
17.3.8Floating-PointCodeExamples17-21
17.3.8,1Example1:EvaluatinganExpression17-21
AppendixA:InstallingandUsingthe
Assembler611
AppendixB:TheIntelInstructionSet617
AppendixC:BIOSandMS-DOSInterrupts649
AppendixD:MASMReference661
猜您喜欢