Linux Assembly Language Programming (Open Source Technology Series)

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

Master x86 assembly language from the Linux point of view! Assembly language lies at the boundary between hardware and software. While it can be described purely in terms of how it controls hardware, many of its features only make sense in the context of operating systems and programming languages. In Linux Assembly Language Programming, Bob Neveln explains all the key features of x86 assembly language in the context of the Linux operating system and the C language. The book's step-by-step, one-concept-at-a-time coverage is designed to help experienced hardware programmers move to Linux, and learn how to create Linux device drivers. As developers learn new x86 assembly language skills, they also gain "under the hood" insight into how Linux works -- and into the way processor and software design impact each other. For C programmers who want to understand more about the interactions between Linux and hardware; and for assembler programmers who want to apply their skills in the Linux environment.

Author(s): Bob Neveln
Series: Open Source Technology Series
Publisher: Prentice Hall
Year: 2000

Language: English
Pages: 278

LINUX ASSEMBLY LANGUAGE PROGRAMMING......Page 1
Title page......Page 5
Dedication......Page 7
CONTENTS......Page 9
PREFACE......Page 17
1.1 The Fetch-Execute Cycle......Page 21
1.3 The Gnu C Compiler......Page 22
1.4.1 Editing......Page 23
1.4.4 Dosemu......Page 24
1.6 Other Assemblers......Page 25
2.1 The Decimal and Pentimal Systems......Page 26
2.1.1 Purely Decimal Money......Page 27
2.1.2 Pentimal Money......Page 28
2.2 Pentimal Arithmetic......Page 29
2.2.1 Native Addition......Page 30
2.2.2 Native Subtraction......Page 31
2.3 Conversion to Pentimal......Page 32
2.4.1 Binary Addition......Page 33
2.4.2 Binary Subtraction......Page 34
2.4.3 Conversion to Binary......Page 35
2.5 Memory as a Rectangle of Bits......Page 36
2.6 The Hexadecimal System......Page 38
3.9 Memory Circuits......Page 39
2.6.2 Subtraction in Hex......Page 40
2.6.3 Conversion to Hex......Page 41
2.7 Base Distinguishing Notations......Page 42
2.8* Fractions in Other Bases......Page 43
2.9* Converting Fractions......Page 45
3.1 The NOT Gate......Page 47
3.1.1 Logic Gate Terminals......Page 48
3.1.3 Truth Table for the NOT Gate......Page 49
3.2 Boolean Operators......Page 50
3.2.1 The OR Operator......Page 51
3.2.3 Boolean Expressions......Page 52
3.3.1 The OR Gate......Page 53
3.3.2 The AND Gate......Page 54
3.3.3 Boolean Circuits......Page 55
3.4 Addition Circuits......Page 56
3.5 Sequential Circuits......Page 58
3.5.2 A Latch......Page 59
3.5.4 Bit Significance......Page 60
3.6.3 Odometer Arithmetic......Page 61
3.6.4 Register Arithmetic......Page 62
3.7.1 Two's Complementation......Page 64
3.8* Placeholding Two's Complement......Page 66
3.9.1 Tri-State Outputs......Page 68
3.10.1 8080 Registers......Page 72
3.11.1 MOV reg,imm......Page 74
3.11.2 MOV reg,reg......Page 77
3.12.2 ADD reg,reg......Page 78
3.13.1 The MUL Command......Page 79
3.13.2 The DIV Command......Page 80
3.13.3 Negative Numbers and Congruences......Page 81
4.1 The Four Field Format......Page 83
4.2 Computers from the CPU Standpoint......Page 84
4.2.1 Memory vs. I/O......Page 86
4.2.2 The IN Command......Page 87
4.3.1 Edlinas Ports......Page 88
4.4.1 The JMP Command......Page 89
4.4.2 Conditional Jumps and Flags......Page 90
4.4.3 The JZJSJNZ, and JNS Commands......Page 91
4.5 Assembler Programs with Loops......Page 92
4.6.2 The Overflow Flag......Page 93
4.6.4 More Jump Commands......Page 94
4.7 Unsigned Comparisons......Page 95
4.7.2 Out of Range Flag Summary......Page 96
4.8 Linux . s files......Page 97
4.8.1 The Pentium's Dual Pipeline......Page 100
5.1 Assembling Simple Programs......Page 101
5.1.1 Register Codes......Page 102
5.1.3 Relative Jumps......Page 103
5.2 Opcode Space......Page 104
5.3.1 rv,rmv Coding......Page 107
5.3.3 Nonregister R Bits......Page 108
5.4 386 Space (OF + ...)......Page 109
5.5 32-Bit vs. 16-Bit Code......Page 111
5.6 The 8-Bit Registers......Page 112
5.7 Linux . o Files......Page 113
6.1.1 Storage Protocols......Page 114
6.1.2 Little and Big Endian Architecture......Page 115
6.1.3 Alignment......Page 116
6.2.1 The [imm] Format......Page 117
7.4 Recursion......Page 119
6.2.3 The [reg+scale*reg+imm] Format......Page 121
6.2.5 CISC vs. RISC......Page 123
6.4 Labels......Page 124
6.4.2 Program Loading......Page 125
6.4.4 Arrays......Page 126
6.5.1 Byte Definition Assembler Directive......Page 127
6.5.3 Initializing Data......Page 129
7.1 Push and Pop Operations......Page 131
7.1.1 The PUSH Command......Page 132
7.1.2 The POP Command......Page 133
7.2.1 The CALL and RET Commands......Page 134
7.3 Parameter Passing......Page 136
7.3.2 Calling Assembler from C......Page 138
CHAPTER 8: LINUX USER PROGRAMS......Page 142
8.1 Multitasking......Page 143
8.2.1 Virtual Memory......Page 144
8.2.2 Paging vs. Swapping......Page 146
8.2.4 Kernel Pages......Page 147
8.2.5 Kernel Modules......Page 148
8.3.2 Address Parsing......Page 149
8.3.4 Page Table Entries......Page 150
8.3.6 The CR3 Register......Page 151
8.4 Program Segments......Page 152
8.4.2 Writeable Memory......Page 153
8.4.5 Section Definition Directives......Page 154
8.4.7 Calling C from Assembler......Page 155
8.5 Other Data Segments......Page 156
8.5.1 Initialized Data Space......Page 157
8.7 Executable Files in ELF Format......Page 158
8.7.1 The ELF Header......Page 159
8.7.3 ELF Segments......Page 160
8.8 Object Files in ELF Format......Page 161
8.8.2 Sections......Page 162
9.1.2 Status Ports......Page 165
9.2.1 x86 Interrupt Handling......Page 167
9.2.2 Interrupting an Interrupt......Page 170
9.3 ISA Architecture......Page 173
9.3.1 The 8259 Interrupt Controller......Page 174
9.4.1 Exceptions......Page 175
9.4.2 Software Interrupts......Page 176
9.4.3 Faults and Traps......Page 177
9.5 System Calls......Page 178
9.6.2 Privileged Instructions......Page 180
9.6.3 Stack Problems......Page 181
9.7.4 Jump to the ISR......Page 182
9.8 Scheduling......Page 183
10.1 The AND, OR, NOT, and XOR Commands......Page 184
10.1.1 Turning the Speaker On and Off......Page 186
10.1.3 Disallowing Non—maskable Interrupts......Page 187
10.2 Shift Instructions......Page 188
11.1.1 Floppy Drive Controller......Page 191
11.1.2 Bad Old Files......Page 193
11.1.3* Direct Memory Access......Page 194
11.2 Devices as Files......Page 195
11.3.1 The file_operations Structure......Page 196
11.3.3 The Timer Queue......Page 198
11.3.4 Device Memory......Page 201
11.3.5 Wait Queues......Page 203
11.3.6 Signals......Page 205
11.3.7 States of a Process......Page 206
11.3.9 Assembly Language Speaker Code......Page 207
11.3.10 C Language Driver Code......Page 209
11.3.11 Loose Ends......Page 216
11.4.1 Setting Up a New Interrupt Handler......Page 217
11.4.2 Scalex Interrupt Handler......Page 219
11.4.3 Scalex System Call Handlers......Page 222
CHAPTER 12: DOS PROGRAMS......Page 232
12.1 Real Mode Segmentation......Page 233
12.1.1 Segment Registers......Page 234
12.1.3 Default Segments......Page 235
12.2 Edlinas Environment Variables......Page 237
12.3.1 Video Buffer......Page 238
12.3.2 Keyboard Buffer......Page 239
12.4 Real Mode Interrupts......Page 240
12.4.1 DOS Interrupts......Page 241
12.4.2 BIOS Interrupts......Page 242
12.4.3 The Real Mode Interrupt Table......Page 243
12.5 Checking DOS Memory......Page 245
13.1 Changing to Protected Mode......Page 248
13.2 Protected Mode Segmentation......Page 249
13.2.1 Protected Mode Memory Segments......Page 250
13.2.2 Special Memory Segments, the GDT and the IDT......Page 252
13.2.3 Selectors......Page 253
13.2.4 Segment Operations......Page 254
13.2.5 Descriptor Encoding......Page 256
13.2.6 Task Isolation via Local Descriptor Tables......Page 257
13.3 Setting Up the Global Descriptor Table......Page 259
13.4 Closing......Page 260
INDEX......Page 261
ABOUT THE CD......Page 274