WindowsAssemblyLanguage_SystemProgramming.pdf

(13032 KB) Pobierz
4561046 UNPDF
WINDOWS ASSEMBLY
LANGUAGE & SYSTEMS
PROGRAMMING
16- and 32-bit low-level programming
for the PC and Windows
2nd edition
bY
Barry Kauler
Lecturer, Edith Cowan University
M.Sc.(EE), C.Eng.
R&D Books
Lawrence, Kansas 66046
4561046.041.png 4561046.042.png 4561046.043.png 4561046.044.png 4561046.001.png 4561046.002.png
0 Copyright 1997, Barry Kauler
All rights reserved. No part of this publication may be reproduced, stored in a retrieval
system, or transmitted in any form or by any means, electronic, mechanical,
photocopying, recording, or otherwise, without prior written permission of the Publisher.
In this book, many of the designations used by manufacturers and sellers to distinguish
their products may be claimed as trademarks. Due acknowledgement is hereby made of
all legal protection. Windows TM is a trademark of Microsoft Corporation.
Disclaimer. Whilst due care has been taken in the preparation of this book,
no
responsibility is accepted for any inaccuracy, loss or damage to data, or consequential
loss or damage. The content of the Companion Disk is not guaranteed to be exactly as
described.
This edition published by R&D Books
/ Miller Freeman
ISBN: 087930474X
DISTRIBUTION:
USA
Canada
Publishers Group West
P.O. Box 8843
Emeryville, CA 94662
Tel: (800) 788-3123
Fax: (510) 658-1834
Publishers Group West Canada
543 Richmond Street West
Suite 223
Toronto, Ontario M5V lY6
Canada
Tel: (416) 504-3900
Fax: (4 16) 504-3902
UK and Europe
McGraw-Hill Publishing Co.
Shopper&angers
Asia
Road
Longman Singapore
25 First Lok Yang Road
Singapore 2262
Tel: 65 268 2666
Fax: 65 268 7023
Maidenhead
Berkshire SL6 2QL
United Kingdom
Tel: 0800 810800 or 01628 502500
Fax: 01628 770224
e-mail: queries@mcgraw-hill.co.uk
Latin America
ID International
126 Old Ridgefield Road
Wilton, CT 06897 USA
Tel: (203) 834-2272
Fax: (203) 762-9725
Editorial & Marketing Oftice
R&D Books
1601 West 23rd Street, Suite 200
Lawrence, KS 66046
Tel: (913) 841-1631
Fax: (913) 841-2624
e-mail: orders@mfi.com
Web: http://www.rdbooks.com
4561046.003.png 4561046.004.png 4561046.005.png 4561046.006.png 4561046.007.png 4561046.008.png 4561046.009.png 4561046.010.png 4561046.011.png 4561046.012.png 4561046.013.png 4561046.014.png 4561046.015.png
Contents
Ch.
Pag xi
Preface
1
CPU Architecture 1
Preamble ..................................................
1
Power-up the PC
2
The System Files .......................................
...........................................
3
Number Systems
...........................................
6
Registers and Memory
.....................................
9
12
The CPU & Support Chips .......................... 12
Conventional and Extended Memory .................... 14
Segments ............................................
MemoryMapofthePC
..............................
14
Real Mode ...........................................
17
DOS Real Mode Programming
...................... 18
DOS Protected Mode Programming
.................. 18
20
Inside the 286/386l486/etc. ...............................
Coding Restraints
....................................
2 1
22
Instructions ..........................................
.......................................
23
Real and Protected Modes
........................... 25
Memory Management
....................................
25
Segmentation Only
...................................
25
26
Descriptors ..........................................
....................................
28
386 Paging ...........................................
28
Virtual-86 ...........................................
29
Contention Issues
3 1
Privileges.. ..........................................
........................................
31
I/O Privilege .........................................
3 1
32
Interrupts ................................................
Task Switching
......................................
3 3
33
Protected Mode Interrupts ........................... 34
Postamble ...............................................
Real Mode Interrupts
.................................
36
..I
111
CPU Registers
Shadow Registers
4561046.016.png 4561046.017.png 4561046.018.png 4561046.019.png 4561046.020.png 4561046.021.png
iv
Ch.
Page
Basic Assembly Language 37
Preamble ................................................
2
3 7
Stack Instructions ........................................
38
Transfer of Control .......................................
39
Conditional Jump
....................................
43
Addressing Modes
.......................................
44
46
String Instructions .......................................
...................................
47
50
Logical Instructions ......................................
...................................
54
Code and Data Labels
....................................
56
56
Data Labels ..........................................
.........................................
58
5 8
Pointers ..............................................
......................................
59
LES, LDS, and LEA Instructions .................... 60
Local Data ...........................................
62
63
Structures ................................................
...........................................
65
Label Equates ........................................
66
Postamble
...............................................
67
Opening Windows 69
Preamble ................................................
3
69
DOS versus Windows Programming .................... 70
Internal Differences ..................................
7 1
Building a Windows Application
........................ 72
72
The Mechanics of Assembling and Linking ........... 73
The Link Step ........................................
....................................
74
Two Steps for Resources ............................ 74
Windows Programming Mechanics ...................... 75
Objects ..............................................
75
Handles ..............................................
76
Messages ............................................
77
C Syntax .............................................
78
Message Loop
.......................................
78
Callback Functions
...................................
79
Data Types
..............................................
82
Segment Registers
Arithmetic Instructions
Code Labels
Accessing Data
Type Override
Library Functions
76
Instances .............................................
4561046.022.png 4561046.023.png 4561046.024.png 4561046.025.png 4561046.026.png 4561046.027.png 4561046.028.png 4561046.029.png
V
Ch.
Page
4
The Bare Bones 85
Preamble ................................................
85
Getting Started ...........................................
86
86
Source Files .........................................
......................................
89
Resource and Definition Files
........................
90
Make File ............................................
.....................................
91
Development Cycle
..................................
92
94
Preliminary Code ....................................
....................................
94
Startup Code .........................................
96
WINMAIN{)
.........................................
98
Callback Function
...................................
102
5
High-Level Assembly 109
Preamble ...............................................
109
Include Files ............................................
109
Microsoft versus Borland
.......................... 110
111
.MODEL Directive ......................................
.......................................
119
120
MASM versus TASM Scope ....................... 121
TASM’s @@ .......................................
.................................
121
Life of Automatic Data
..............................
Assembling and Linking
................................
123
MASM6 versus TASM
..................................
125
126
Prototypes ..........................................
...............................
127
Callback Design
....................................
129
Other Incompatibilities
..............................
MASM Assembling and Linking
................... 13 l
MASM6 Program Listing
...............................
132
Program Design 137
Preamble ...............................................
6
137
Object Addressing
......................................
138
138
Early Binding .......................................
..................................
14 1
Late Binding ........................................
142
C++ Binding ........................................
142
Tools Required
89
Message Format
Application Structure
Skeleton Analysis
Private and Global Data
122
WINDOWS Qualifier
130
Calling a Function
4561046.030.png 4561046.031.png 4561046.032.png 4561046.033.png 4561046.034.png 4561046.035.png 4561046.036.png 4561046.037.png 4561046.038.png 4561046.039.png 4561046.040.png
Zgłoś jeśli naruszono regulamin