100% found this document useful (2 votes)
17 views

Introduction to 64 Bit Windows Assembly Programming Fourth Edition Ray Seyfarth pdf download

The document is a guide to 'Introduction to 64 Bit Windows Assembly Programming' by Ray Seyfarth, detailing the evolution of Intel CPU architecture and the simplifications in assembly programming with the x86-64 architecture. It emphasizes hands-on learning and provides resources for both Windows and Linux/OS X environments, including a new integrated development environment called 'ebe'. The book targets beginners and covers essential topics in assembly language programming, with a focus on practical applications and high-performance programming techniques.

Uploaded by

rhoderkahe
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
17 views

Introduction to 64 Bit Windows Assembly Programming Fourth Edition Ray Seyfarth pdf download

The document is a guide to 'Introduction to 64 Bit Windows Assembly Programming' by Ray Seyfarth, detailing the evolution of Intel CPU architecture and the simplifications in assembly programming with the x86-64 architecture. It emphasizes hands-on learning and provides resources for both Windows and Linux/OS X environments, including a new integrated development environment called 'ebe'. The book targets beginners and covers essential topics in assembly language programming, with a focus on practical applications and high-performance programming techniques.

Uploaded by

rhoderkahe
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 51

Introduction to 64 Bit Windows Assembly

Programming Fourth Edition Ray Seyfarth pdf


download

https://ebookfinal.com/download/introduction-to-64-bit-windows-
assembly-programming-fourth-edition-ray-seyfarth/

Explore and download more ebooks or textbooks


at ebookfinal.com
We have selected some products that you may be interested in
Click the link to download now or visit ebookfinal.com
for more options!.

Building Regulations in Brief Fourth Edition Ray Tricker

https://ebookfinal.com/download/building-regulations-in-brief-fourth-
edition-ray-tricker/

Windows Kernel Programming Second Edition Pavel Yosifovich

https://ebookfinal.com/download/windows-kernel-programming-second-
edition-pavel-yosifovich/

An Introduction to Stochastic Modeling Fourth Edition


Pinsky

https://ebookfinal.com/download/an-introduction-to-stochastic-
modeling-fourth-edition-pinsky/

Introduction to Biotechnology An Agricultural Revolution


2nd Edition Ray V Herren

https://ebookfinal.com/download/introduction-to-biotechnology-an-
agricultural-revolution-2nd-edition-ray-v-herren/
Introduction to Pharmaceutical Calculations Fourth Edition
Judith A Rees

https://ebookfinal.com/download/introduction-to-pharmaceutical-
calculations-fourth-edition-judith-a-rees/

Simply Java An Introduction to Java Programming


Programming Series 1st Edition James Levenick

https://ebookfinal.com/download/simply-java-an-introduction-to-java-
programming-programming-series-1st-edition-james-levenick/

Cytoskeleton methods and protocols Fourth Edition Ray H.


Gavin (Editor)

https://ebookfinal.com/download/cytoskeleton-methods-and-protocols-
fourth-edition-ray-h-gavin-editor/

Microsoft Silverlight Edition Programming Windows Phone 7


Charles Petzold

https://ebookfinal.com/download/microsoft-silverlight-edition-
programming-windows-phone-7-charles-petzold/

Introduction to Java Programming Comprehensive Version 6th


Edition Liang

https://ebookfinal.com/download/introduction-to-java-programming-
comprehensive-version-6th-edition-liang/
Introduction to 64 Bit Windows Assembly Programming
Fourth Edition Ray Seyfarth Digital Instant Download
Author(s): Ray Seyfarth
ISBN(s): 9781543138849, 1543138845
Edition: 4
File Details: PDF, 7.46 MB
Year: 2017
Language: english
Introduction to 64 Bit
Windows Assembly
Programming

Ray Seyfarth
Ray Seyfarth
Hattiesburg, MS
USA

Seyfarth, Ray
Introduction to 64 Bit Windows Assembly Programming
Includes index
ISBN-13: 978-1543138849
ISBN-10: 1543138845

© 2017 Ray Seyfarth All rights reserved.

This work may not be translated or copied in whole or in part without


the written permission of the copyright holder, except for brief excerpts
in connection with reviews or scholarly analyses.

ii
Preface
The Intel CPU architecture has evolved over 3 decades from a 16 bit CPU
with no memory protection, through a period with 32 bit processors with
sophisticated architectures into the current series of processors which
support all the old modes of operation in addition to a greatly expanded
64 bit mode of operation. Assembly textbooks tend to focus on the history
and generally conclude with a discussion of the 32 bit mode. Students are
introduced to the concepts of 16 bit CPUs with segment registers allowing
access to 1 megabyte of internal memory. This is an unnecessary focus on
the past.
With the x86-64 architecture there is almost a complete departure
from the past. Segment registers are essentially obsolete and more
register usage is completely general purpose, with the glaring exception
of the repeat-string loops which use specific registers and have no
operands. Both these changes contribute to simpler assembly language
programming.
There are now 16 general purpose integer registers with a few
specialized instructions. The archaic register stack of the 8087 has been
superseded by a well-organized model providing 16 floating point
registers with floating point instructions along with the SSE and AVX
extensions. In fact the AVX extensions even allow a three operand syntax
which can simplify coding even more.
Overall the x86-64 assembly language programming is simpler than
its predecessors. Today most personal computers ship with 64 bit
operating systems. In fact the latest versions of the Apple OS X operating
system are only available in 64 bits, though Linux and Microsoft Windows
still have 32 and 64 bit versions. The era of 32 bit CPUs and operating
systems is nearly over. Together these trends indicate that it is time to
teach 64 bit assembly language.
The focus in this textbook is on early hands-on use of 64 bit assembly
programming. There is no 16 or 32 bit programming and the discussion of
the history is focused on explaining the origin of the old register names
and the few non-orthogonal features of the instruction set.

iii
The first version of this book discussed using the yasm assembler and
the gdb debugger directly. Now the author provides a free integrated
development environment named “ebe”, which automates the process of
using nasm1. The ebe environment is a GUI program written in C++ using
the Qt system and supports C and C++ in addition to assembly language,
though its purpose is to support assembly programming. There was a
previous version of ebe written in Python, but the newer version offers
many more features. The Qt version of ebe is available at
http://qtebe.sourceforge.net.
This version of the book discusses assembly programming for the
Windows operating system. There is a companion book discussing
assembly programming for Linux and OS X which use a different function
call interface. There is a discussion of the function call protocol differences
for Linux, OS X and Windows, so having one of the two books should be
sufficient for someone interested in programming on multiple operating
systems.
The Linux/OS X book contains examples using gdb for debugging. Alas
this seems to be impractical under Windows and, in fact, under OS X. The
nasm assembler does not generate sufficient information under Windows
or OS X to determine source code line numbers from memory addresses.
Ebe uses the nasm listing file along with the addresses of global symbols
like main to build translations internally while using memory addresses
for breakpoints and to determine line numbers with gdb. The ebe user
perceives a simple interface, but using gdb manually would require the
user to compute addresses for break points and observe source code in a
separate window. For this reason this book has abandoned the use of
debugging with gdb,
Another issue with Windows is the prevalence of assembly code
examples built around structured exception handling (SEH). The idea
there is to augment the code with data which describes the stack frame
and register usage in such a manner that SEH can “unwind” the stack to
determine which exception handler is the first to be found to handle a
particular exception. Exception handling is arguably a critical feature in
C++, but it is possibly too cumbersome for beginning assembly
programmers. The model used in the book is compatible with C and far
simpler than the code one finds which addresses SEH. Most likely any
assembly code used in C++ will be used for high efficiency and will not
generate any exceptions, so I feel the decision to write simpler assembly
code is useful in practice in addition to being far easier to understand.

1A switch was made in 2017 from yasm to nasm due to a .bss memory
reservation problem with yasm.
iv
Due to costs this book is printed in black and white. The pictures
captured from ebe would have been prettier and perhaps more useful in
color, but the cost of the book would have been roughly double the cost of
a black and white version. The added utility of color is certainly not worth
the extra cost. Generally the highlighted text in ebe is shown with a
colored background while the printed version presents this text with a
light gray background.
Most of the sample code execution in the first edition was illustrated
using gdb. This function has been superseded with screen captures from
ebe.
There are assignments using the computer from the very first chapter.
Not every statement will be fully understood at the start, but the
assignments are still possible.
The primary target for this book is beginning assembly language
programmers and for a gentle introduction to assembly programming,
students should study chapters 1, 2, 3, 5, 6, 7, 8, 9, 10 and 11. Chapter 4
on memory mapping is not critical to the rest of the book and can be
skipped if desired.
Chapters 12 through 15 are significantly more in depth. Chapter 15
is about data structures in assembly and is an excellent adjunct to
studying data structures in C/C++. The subject will be much clearer after
exposure to assembly language.
The final four chapters focus on high performance programming,
including discussion of SSE and AVX programming.
The author provides slides for classroom instruction along with
sample code and errata at http://rayseyfarth.com/asm.
If you find errors in the book or have suggestions for improvement,
please email the author as ray.seyfarth@gmail.com. Your
suggestions will help improve the book and are greatly appreciated.
You may also email me with questions or suggestions about ebe. Your
email will assist me with providing better on-line support and will help
improve the quality of the software.
Thank you for buying the book and I hope you find something
interesting and worthwhile inside.

v
Acknowledgements
No book is created in isolation. This book is certainly no exception. I am
indebted to numerous sources for information and assistance with this
book.
Dr. Paul Carter’s PC assembly language book was used by this author
to study 32 bit assembly language programming. His book is a free PDF
file downloadable from his web site. This is a 195 page book which covers
the basics of assembly language and is a great start at 32 bit assembly
language.
While working on this book, I discovered a treatise by Drs. Bryant and
O’Hallaron of Carnegie Mellon about how gcc takes advantage of the
features of the x86-64 architecture to produce efficient code. Some of their
observations have helped me understand the CPU better which assists
with writing better assembly code. Programmers interested in efficiency
should study their work.
I found the Intel manuals to be an invaluable resource. They provide
details on all the instructions of the CPU. Unfortunately the documents
cover 32 bit and 64 bit instructions together which, along with the huge
number of instructions, makes it difficult to learn assembly programming
from these manuals. I hope that reading this book will make a good
starting point, but a short book cannot cover many instructions. I have
selected what I consider the most important instructions for general use,
but an assembly programmer will need to study the Intel manuals (or
equivalent manuals from AMD).
I thank my friends Maggie and Tim Hampton for their editing
contributions to the book.
I am indebted to my CSC 203 - Assembly Language class at the
University of Southern Mississippi for their contributions to this book.
Teaching 64 bit assembly language has uncovered a few mistakes and
errors in the original Create Space book from July 2011. In particular I
wish to thank Isaac Askew, Evan Stuart, Brandon Wolfe and Zachary
Dillon for locating errors in the book.
Thanks to Ken O’Brien for helping locate mistakes in the book.
Thanks go to Christian Korn and Markus Bohm of Germany who have
vi
assisted with “debugging” this book. Thanks also to Francisco Perdomo of
the Canary Islands for assistance. Carsten Hansen of Denmark has also
assisted with debugging the book. David Langer has contributed some
code comment repairs.
Thanks to Quentin Gouchet for locating several typos which had
persisted for several years.
Thanks for Keiji Omori for pointing out that the stack size limits for
Linux processes are now quite generous. At some point there was a hard
kernel limit which could be changed by recompiling the kernel. Now it
can be changed in /etc/security/limits.conf.
Thanks to Wendell Xe for offering suggestions for improving the book
and also suggestions for ebe.
Last I thank my wife, Phyllis, and my sons, David and Adam, for their
encouragement and assistance. Phyllis and Adam are responsible for the
cover design for both this and the Create Space book.

vii
Contents
Preface .................................................................................................... iii
Acknowledgements ................................................................................ vi
Chapter 1 Introduction ........................................................................... 1
1.1 Why study assembly language?................................................... 2
So what is good about assembly language? ................................... 2
1.2 What is a computer? ..................................................................... 3
Bytes ................................................................................................. 4
Program execution ........................................................................... 4
1.3 Machine language ........................................................................ 5
1.4 Assembly language ....................................................................... 6
1.5 Assembling and linking ............................................................... 8
1.6 Using ebe to run the program ..................................................... 8
Chapter 2 Numbers .............................................................................. 12
2.1 Binary numbers .......................................................................... 12
2.2 Hexadecimal numbers ............................................................... 14
2.3 Integers ....................................................................................... 16
Binary addition .............................................................................. 18
Binary multiplication .................................................................... 19
2.4 Floating point numbers ............................................................. 19
Converting decimal numbers to floats ......................................... 22
Converting floats to decimal ......................................................... 23
Floating point addition .................................................................. 23
Floating point multiplication ........................................................ 24
2.5 Exploring with the bit bucket .................................................... 25
Chapter 3 Computer memory .............................................................. 28
3.1 Memory mapping ....................................................................... 28
3.2 Process memory model in Windows .......................................... 29
3.3 Memory example ........................................................................ 30
3.4 Examining memory with ebe ..................................................... 32
Setting a breakpoint ...................................................................... 33
Running a program and viewing a variable ................................. 33
Chapter 4 Memory mapping in 64 bit mode ........................................ 38
4.1 The memory mapping register ................................................... 38
4.2 Page Map Level 4 ........................................................................ 39
4.3 Page Directory Pointer Table ..................................................... 40
4.4 Page Directory Table .................................................................. 40
4.5 Page Table ................................................................................... 41
4.6 Large pages ................................................................................. 41
4.7 CPU Support for Fast Lookups .................................................. 41
Chapter 5 Registers ............................................................................... 44
5.1 Observing registers in ebe.......................................................... 46
5.2 Moving a constant into a register .............................................. 47
5.3 Moving values from memory to registers .................................. 49
5.4 Moving values from a register to memory ................................ 51
5.5 Moving data from one register to another ................................ 52
Chapter 6 A little bit of math ............................................................... 55
6.1 Negation ...................................................................................... 55
6.2 Addition ....................................................................................... 56
6.3 Subtraction .................................................................................. 58
6.4 Multiplication .............................................................................. 60
One operand imul .......................................................................... 60
Two and three operand imul ........................................................ 62
Testing for a Pythagorean triple ................................................... 62
6.5 Division ........................................................................................ 65
6.6 Conditional move instructions ................................................... 67
6.7 Why move to a register? ............................................................. 67
Chapter 7 Bit operations ....................................................................... 70
7.1 Not operation .............................................................................. 70
7.2 And operation .............................................................................. 71
7.3 Or operation ................................................................................ 72
7.4 Exclusive or operation ................................................................ 73
7.5 Shift operations ........................................................................... 74
7.6 Bit testing and setting ............................................................... 80
7.7 Extracting and filling a bit field ................................................ 84
Chapter 8 Branching and looping ........................................................ 88
8.1 Unconditional jump .................................................................... 88
8.2 Conditional jump ........................................................................ 90
Simple if statement ....................................................................... 91
If/else statement ............................................................................ 91
If/else-if/else statement ................................................................. 92
8.3 Looping with conditional jumps ................................................ 93
While loops ..................................................................................... 93
Counting 1 bits in a memory quad-word ...................................... 94
Do-while loops ................................................................................ 96
Counting loops ............................................................................... 98
8.4 Loop instructions ........................................................................ 99
8.5 Repeat string (array) instructions ............................................ 99
String instructions ....................................................................... 100
Chapter 9 Functions ........................................................................... 105
9.1 The stack ................................................................................... 105
9.2 Call instruction ......................................................................... 106
9.3 Linux Function calls ................................................................. 110
9.4 Return instruction .................................................................... 110
9.5 Function parameters and return value .................................. 112
9.6 Stack frames ............................................................................. 115
Function to print the maximum of 2 integers ............................ 119
9.7 Recursion .................................................................................. 122
Chapter 10 Arrays .............................................................................. 126
10.1 Array address computation ................................................... 126
10.2 General pattern for memory references................................ 127
10.3 Allocating arrays .................................................................... 130
10.4 Processing arrays ................................................................... 131
Creating the array ....................................................................... 132
Filling the array with random numbers .................................... 132
Printing the array ........................................................................ 133
Finding the minimum value ........................................................ 134
Main program for the array minimum ....................................... 134
10.5 Command line parameter array ............................................ 136
Chapter 11 Floating point instructions ............................................. 141
11.1 Floating point registers .......................................................... 141
11.2 Moving floating point data ..................................................... 143
Moving scalars .............................................................................. 143
Moving packed data ..................................................................... 143
11.3 Addition ................................................................................... 144
11.4 Subtraction .............................................................................. 144
11.5 Multiplication and division .................................................... 145
11.6 Conversion ............................................................................... 146
Converting to a different length floating point .......................... 146
Converting floating point to/from integer ................................... 147
11.7 Floating point comparison ..................................................... 147
11.8 Mathematical functions.......................................................... 148
Minimum and maximum ............................................................. 149
Rounding ....................................................................................... 149
Square roots .................................................................................. 150
11.9 Sample code............................................................................. 150
Distance in 3D .............................................................................. 150
Dot product of 3D vectors ............................................................ 150
Polynomial evaluation ................................................................. 151
Chapter 12 Accessing Files ................................................................. 155
12.1 File access with the Windows API ......................................... 156
Creating a file ............................................................................... 156
Writing to a file ............................................................................ 157
Complete program to create a file ............................................... 158
Reading from a file ....................................................................... 160
Program to copy a file .................................................................. 160
12.2 Portable C file access functions ............................................. 164
open .............................................................................................. 165
read and write .............................................................................. 167
lseek .............................................................................................. 167
close .............................................................................................. 168
Chapter 13 Structs .............................................................................. 170
13.1 Symbolic names for offsets .................................................... 171
13.2 Allocating and using an array of structs .............................. 174
Chapter 14 Using the C stream I/O functions .................................. 177
14.1 Opening a file ......................................................................... 178
14.2 fscanf and fprintf .................................................................... 179
14.3 fgetc and fputc ........................................................................ 179
14.4 fgets and fputs ........................................................................ 180
14.5 fread ........................................................................................ 181
14.5 fseek and ftell ......................................................................... 182
14.6 fclose ........................................................................................ 183
Chapter 15 Data structures ............................................................... 185
15.1 Linked lists ............................................................................. 185
List node structure ...................................................................... 186
Creating an empty list................................................................. 186
Inserting a number into a list ..................................................... 186
Traversing the list ....................................................................... 187
15.2 Doubly-linked lists ................................................................. 189
Doubly-linked list node structure ............................................... 190
Creating a new list ...................................................................... 190
Inserting at the front of the list .................................................. 190
List traversal................................................................................ 191
15.3 Hash tables ............................................................................. 192
A good hash function for integers ............................................... 193
A good hash function for strings ................................................. 194
Hash table node structure and array ......................................... 194
Function to find a value in the hash table ................................. 194
Insertion code ............................................................................... 195
Printing the hash table ................................................................ 196
Testing the hash table ................................................................. 198
15.4 Binary trees............................................................................. 199
Binary tree node and tree structures .......................................... 199
Creating an empty tree ................................................................ 200
Finding a key in a tree ................................................................. 200
Inserting a key into the tree ........................................................ 201
Printing the keys in order ........................................................... 202
Chapter 16 High performance assembly............................................ 205
16.1 Efficient use of cache .............................................................. 205
16.2 Common subexpression elimination ...................................... 207
16.3 Strength reduction .................................................................. 207
16.4 Use registers efficiently .......................................................... 207
16.5 Use fewer branches ................................................................. 207
16.6 Convert loops to branch at the bottom .................................. 208
16.7 Unroll loops ............................................................................. 208
16.8 Merge loops ............................................................................. 210
16.9 Split loops ................................................................................ 210
16.10 Interchange loops .................................................................. 210
16.11 Move loop invariant code outside loops ............................... 211
16.12 Remove recursion.................................................................. 211
16.13 Eliminate stack frames ........................................................ 212
16.14 Inline functions ..................................................................... 212
16.15 Reduce dependencies to allow super-scalar execution ...... 212
16.16 Use specialized instructions ................................................. 212
Chapter 17 Counting bits in an array ................................................ 215
17.1 C function ................................................................................ 215
17.2 Counting 1 bits in assembly ................................................... 216
17.3 Precomputing the number of bits in each byte .................... 218
17.4 Using the popcnt instruction ................................................. 219
Chapter 18 Sobel filter ........................................................................ 222
18.1 Sobel in C ................................................................................ 222
18.2 Sobel computed using SSE instructions ............................... 223
Chapter 19 Computing Correlation ................................................... 230
19.1 C implementation ................................................................... 230
19.2 Implementation using SSE instructions .............................. 231
19.3 Implementation using AVX instructions .............................. 233
Appendix A Installing ebe .................................................................. 238
Installing from binary packages ..................................................... 238
Installing from source on Windows ................................................ 238
Installing Cygwin ........................................................................ 239
Installing Qt ................................................................................. 239
Downloading the source code.......................................................... 239
Compiling ebe and installing .......................................................... 240
Appendix B Using ebe ........................................................................ 241
Major features ................................................................................. 241
Tooltips ......................................................................................... 241
Help .............................................................................................. 241
Menu ............................................................................................. 242
Movable toolbars .......................................................................... 242
Movable subwindows ................................................................... 242
Editing ............................................................................................. 244
Navigation .................................................................................... 245
Cut, copy and paste ..................................................................... 245
Undo/redo ..................................................................................... 246
Find and replace .......................................................................... 246
Deleting text................................................................................. 246
Using tabs .................................................................................... 246
Auto-indent .................................................................................. 246
Prettify ......................................................................................... 247
Indent/unindent ........................................................................... 247
Comment/uncomment ................................................................. 247
Word/number completion ............................................................ 247
Editing multiple files ................................................................... 247
Debugging ........................................................................................ 248
Breakpoints .................................................................................. 248
Running a program ...................................................................... 248
Terminal window ......................................................................... 249
Next and step ............................................................................... 250
Continue ....................................................................................... 250
Assembly Data window ................................................................ 250
Register window ........................................................................... 250
Floating point register window ................................................... 251
Projects ............................................................................................. 251
Viewing the project window ........................................................ 252
Creating a new project ................................................................. 252
Opening a project ......................................................................... 253
Adding files to a project ............................................................... 253
Closing a project ........................................................................... 253
Toy box.............................................................................................. 253
Bit bucket ......................................................................................... 254
Backtrace window ............................................................................ 255
Console ............................................................................................. 255
Ebe settings ...................................................................................... 256
Ebe Register Alias Macros .............................................................. 256
alias ............................................................................................... 257
fpalias ............................................................................................ 257
Appendix C Using scanf and printf .................................................... 258
scanf .................................................................................................. 258
printf ................................................................................................. 259
Appendix D Using macros in nasm .................................................... 261
Single line macros ............................................................................ 261
Multi-line macros ............................................................................. 262
Preprocessor variables ..................................................................... 263
Appendix E Sources for more information ......................................... 264
nasm user manual ........................................................................... 264
Stephen Morse’s 8086/8088 primer ................................................ 264
Dr. Paul Carter’s free assembly book ............................................. 264
64 bit machine level programming ................................................. 264
GDB manual .................................................................................... 265
Intel documentation ........................................................................ 265
Index .................................................................................................... 266
Chapter 1
Introduction
This book is an introduction to assembly language programming for the
x86-64 architecture of CPUs like the Intel Core processors and the AMD
Athlon, Zen and Opteron processors. While assembly language is no
longer widely used in general purpose programming, it is still used to
produce maximum efficiency in core functions in scientific computing and
in other applications where maximum efficiency is needed. It is also used
to perform some functions which cannot be handled in a high-level
language.
The goal of this book is to teach general principles of assembly
language programming. It targets people with some experience in
programming in a high level language (ideally C or C++), but with no prior
exposure to assembly language.
Assembly language is inherently non-portable and this text focuses on
writing code for the Windows operating system, taking advantage of the
free availability of excellent compilers, assemblers and debuggers. There
is a companion book for Linux and OS X which both use the same function
call ABI (application binary interface) which differs substantially from the
Windows function call ABI. Differences between assembly programming
for Linux and OS X systems will be detailed as the work unfolds
The primary goal of this text is to learn how to write functions callable
from C or C++ programs. This focus should give the reader an increased
understanding of how a compiler implements a high level language. This
understanding will be of lasting benefit in using high level languages.
A secondary goal of this text is to introduce the reader to using SSE
and AVX instructions. The coming trend is for the size of SIMD (Single
Instruction Multiple Data) registers to increase and it generally requires
assembly language to take maximum advantage of the SIMD capabilities.

1
1.1 Why study assembly language?
In a time when the latest fads in programming tend to be object-oriented
high-level languages implemented using byte-code interpreters, the trend
is clearly to learn to write portable programs with high reliability in
record time. It seems that worrying about memory usage and CPU cycles
is a relic from a by-gone era. So why would anyone want to learn assembly
language programming?
Assembly language programming has some of the worst “features”
known in computing. First, assembly language is the poster child for non-
portable code. Certainly every CPU has its own assembly language and
many of them have more than one. The most common example is the Intel
CPU family along with the quite similar AMD CPU collection. The latest
versions of these chips can operate in 16 bit, 32 bit and 64 bit modes. In
each of these modes there are differences in the assembly language. In
addition the operating system imposes additional differences. Further the
function call interface (ABI – application binary interface) employed in
x86-64 Linux and OS X systems differs from that used in Microsoft
Windows systems. Portability is difficult if not impossible in assembly
language.
An even worse issue with assembly language programming is
reliability. In modern languages like Java the programmer is protected
from many possible problems like pointer errors. Pointers exist in Java,
but the programmer can be blissfully unaware of them. Contrast this to
assembly language where every variable access is essentially a pointer
access. Furthermore high level language syntax resembles mathematical
syntax, while assembly language is a sequence of individual machine
instructions which bears no syntactic resemblance to the problem being
solved.
Assembly language is generally accepted to be much slower to write
than higher level languages. While experience can increase one’s speed, it
is probably twice as slow even for experts. This makes it more expensive
to write assembly code and adds to the cost of maintenance.

So what is good about assembly language?


The typical claim is that assembly language is more efficient than high
level languages. A skilled assembly language coder can write code which
uses less CPU time and less memory than that produced by a compiler.
However modern C and C++ compilers do excellent optimization and
beginning assembly programmers are no match for a good compiler. The
compiler writers understand the CPU architecture quite well. On the

2
other hand an assembly programmer with similar skills can achieve
remarkable results. A good example is the Atlas (Automatically Tuned
Linear Algebra Software) library which can achieve over 95% of the
possible CPU performance. The Atlas matrix multiplication function is
probably at least 4 times as efficient as similar code written well in C. So,
while it is true that assembly language can offer performance benefits, it
is unlikely to outperform C/C++ for most general purpose tasks.
Furthermore it takes intimate knowledge of the CPU to achieve these
gains. In this book we will point out some general strategies for writing
efficient assembly programs.
One advantage of assembly language is that it can do things not
possible in high level languages. Examples of this include handling
hardware interrupts and managing memory mapping features of a CPU.
These features are essential in an operating system, though not required
for application programming.
So far we have seen that assembly language is much more difficult to
use than higher level languages and only offers benefits in special cases
to well-trained programmers. What benefit is there for most people?
The primary reason to study assembly language is to learn how a CPU
works. This helps when programming in high level languages.
Understanding how the compiler implements the features of a high level
language can aid in selecting features for efficiency. More importantly
understanding the translation from high level language to machine
language is fundamental in understanding why bugs behave the way they
do. Without studying assembly language, a programming language is
primarily a mathematical concept obeying mathematical laws.
Underneath this mathematical exterior the computer executes machine
instructions which have limits and can have unexpected behavior.
Assembly language skills can help in understanding this unexpected
behavior and improve one’s debugging skills.

1.2 What is a computer?


A computer is a machine for processing bits. A bit is an individual unit of
computer storage which can take on either of 2 values: 0 and 1. We use
computers to process information, but all the information is represented
as bits. Collections of bits can represent characters, numbers, or any other
information. Humans interpret these bits as information, while
computers simply manipulate the bits.
The memory of a computer (ignoring cache) consists mainly of a
relatively large amount of “main memory” which holds programs and data
while programs are executing. There is also a relatively small collection
3
of memory within the CPU chip called the “register set” of the computer.
The registers primarily function as a place to store intermediate values
during calculations based on values from main memory.

Bytes
Modern computers access memory in 8 bit chunks. Each 8 bit quantity is
called a “byte”. The main memory of a computer is effectively an array of
bytes with each byte having a separate memory address. The first byte
address is 0 and the last address depends on the hardware and software
in use.
A byte can be interpreted as a binary number. The binary number
01010101 equals the decimal number 85 (64+16+4+1). If this number is
interpreted as a machine instruction the computer will push the value of
the rbp register onto the run-time stack. The number 85 can also be
interpreted as the upper case letter “U”. The number 85 could be part of a
larger number in the computer. The letter “U” could be part of a string in
memory. It’s all a matter of interpretation.

Program execution
A program in execution occupies a range of addresses for the instructions
of the program. The following 18 bytes constitute a very simple program
which simply exits (with status 5):

4
Discovering Diverse Content Through
Random Scribd Documents
CHAPTER III
CHRISTMAS was approaching, and so far, Miss Glyn’s acquaintance
was confined to the village of Thornby. Now and then her aunt and
uncle went from home for a dine and a shoot, and on these
occasions, Mrs. Hesketh took charge of the young lady, who was
delighted to be her guest. At Oldcourt the atmosphere was
reposeful, the surroundings subdued and luxurious, and life was
leisured. Here it was seemingly ‘always afternoon.’ Letty was not
sure that she would enjoy it as a permanence; perhaps there was
too much of the hothouse in the air, but it was an agreeable change
from The Holt, where it was figuratively a perpetual Monday, with a
large washing on hand!
Cousin Maudie, an accomplished musician, encouraged her guest to
practise, played her accompaniments, and delighted in her voice.
Now Mrs. Fenchurch hated ‘squalling,’ had no ear, and was actually
proud of the fact, that she only knew “God Save the King” by seeing
people rise to their feet! Mrs. Hesketh also loved books, and the
tables at Oldcourt were loaded with the newest and best
publications, whether in magazine, pamphlet, or book form. Letty
laid greedy hands on these, but her hostess prudently withdrew a
certain amount—sociological and theological works—which were not
suitable reading for Sweet Seventeen.
Letty admired—and loved—her beautiful (if rather faded) hostess,
and the love and admiration were mutual. The new-comer had also
made friends with the Vicar and his wife. Mr. Denton, a hale, active
man of fifty, much praised by his own flock, and respected by
others. Mrs. Denton, though she had lost the use of her limbs
through sleeping in a damp bed, was her husband’s helper in the
parish, and it was surprising what an amount of work,
correspondence, and interviews centred round her sofa. She was a
frail, delicate Irishwoman, with a sense of humour, a cheerful
disposition, and a warm heart. Both she and her husband had taken
a fancy to the ‘little girl at The Holt,’ as they called her. She reminded
them of their own little girl, who had married and gone to India; to
see Letty flitting about the drawing-room, or seated in Mabel’s chair,
was a sight that gave them sincere pleasure. And the child was so
simple and unaffected, she looked into one’s face with such sweet
candid eyes, and was ever ready and glad to carry a message, sing,
play, or read, to the invalid, keenly interested in little village events,
and the weekly Madras letter—all she asked for in return, was to be
liked!
In a surprisingly short time, this attractive stranger had entirely
wound herself into the affections of the Dentons; her visits were not
frequent, but on hunting days, after she had exercised the dogs, she
would turn into the Rectory drawing-room, and pour out tea.
Immediately before Christmas, Mrs. Fenchurch, who was absorbed in
her correspondence, sent Letty down to the Rectory with a note.
When she arrived there it was still teatime, and she was surprised to
find that Mrs. Denton had a guest, a good-looking young man, who
appeared to find himself completely at home, since he was sitting on
the end of the sofa, nursing the Rectory cat.
“Oh, Letty, so there you are!” said Mrs. Denton. “Let me introduce
my nephew, Lancelot Lumley. He has come to spend Christmas with
us. Lancelot, this is Miss Glyn—you have heard of her?”
“We have met before,” he said eagerly; “a couple of months ago, I
think, in that railway shake-up?”
“Yes,” she assented, for here was the very travelling companion, who
had worn the buffer coat, “in the train.”
“It might have been a bad business,” he continued, and described
the incident to his aunt.
“I suppose it happened when you were on your way home?”
“Yes, I took first leave this year, and I’m sorry to say I have nearly
come to the end of it.”
“And give us only two days, Lance—you ought to be ashamed of
yourself!”
“The fact is, Frances wouldn’t let me off, and Colonel Kingsnorth lent
me a hunter; we have had some ripping good runs.”
“Ah!” said his aunt, “I think it was the hunter that wouldn’t let you
off.” Then, turning to Letty, she explained, “My brother-in-law,
Lancelot’s father, has a living twenty miles from here, at a place
called Sharsley; but he might as well be in London, for it’s so
dreadfully out of the way. We don’t see one another half a dozen
times in the year. This note,” holding it up to Letty, “is from your
aunt; she says she is so desperately busy, that she can’t help with
the church decorations. You know she has always undertaken the
pulpit, she sends you as her deputy, and will supply the usual pots of
palms and chrysanthemums. Lancelot,” looking over at her nephew,
“I intend to make use of you—you and Miss Glyn must do the pulpit
between you.”
“All right,” he answered, “I am agreeable, if Miss Glyn is; but let me
warn you that I have no more idea of decorating than I have of
making a watch.”
“I am afraid I am not much good either,” supplemented the girl; “I’ve
had no practice.”
“Miss Glyn left school two months ago,” explained Mrs. Denton.
“Were you sorry?” enquired the young man, looking over at her.
“Yes,” then with a burst of artless honesty—“I have been to school
nearly all my life.”
“She is coming out at the Hunt Ball early in January,” announced
Mrs. Denton.
“Yes, and I won’t know a single creature at it!”
“Oh, your aunt will find you plenty of partners. You could not be in
better hands. I feel sure she will make a most capable chaperon. It
is miraculous how she manages to get rid of the most hopeless
articles at bazaars. No one can resist her!”
“And you think she will get me off!” Letty laughed, and her laugh
was joyous.
“Not a doubt of it! Sooner than see you sitting out, she’d dance with
you herself. And about her note—so it is all settled, Letty. You will be
down here at eleven o’clock to-morrow; bring a large ball of twine,
and a pair of scissors, and Miss Hoare, the schoolmistress, will start
you. Remember I shall expect you and Lancelot to turn out the most
beautiful pulpit that has ever been seen in Thornby.”
“I can only say that I will do my best,” said Letty, rising.
“What! you are not going yet?”
“I am afraid I must. Aunt Dorothy has quantities of things she wants
me to do this evening—there’s the ticketing for the Christmas Tree.”
“Oh, poor child, I don’t envy you,” said Mrs. Denton with upraised
hands. “Well, in that case, I won’t detain you—Lancelot will escort
you home,” and subsequently he and the young lady left the room
together; she protesting, he assuring her that if she didn’t mind, he
would be glad to make the stroll an excuse for a pipe. Strange to
record, until that evening, Letty had never realised how short was
the distance between the Rectory and The Holt! Here in the
entrance hall she encountered her aunt; Mrs. Fen, who was
overwhelmed with affairs, wore a frowning brow, and carried half a
dozen parcels and a Directory.
“Who was that I heard speaking just now?” she enquired sharply; “it
sounded like a man’s voice?”
“It was only Mr. Lumley, Mrs. Denton’s nephew; he walked home
with me.”
“Oh, so he is here, is he?” she remarked over her shoulder, as she
swept into the smoking-room.
“Is that Lancelot Lumley you are talking of?” enquired Colonel
Fenchurch, who was reading. “I suppose he bicycled over to spend
Christmas—they find it hatefully dull without Mabel. You’d better ask
him up to lunch, or something.”
“I think at this time of the year, when one has so much to do,” and
Mrs. Fenchurch shot a glance at her husband, and then at Letty,
“people don’t expect to be entertained.”
“Of course not,” agreed the Colonel; “I expect Lumley to entertain
me—you forget that he is in my old regiment. I want to hear how
the old corps is getting along. To think that a boy who joined a few
years before I left, is commanding them now!”
“Oh, very well, Tom, then do as you like—ask him up to lunch or
dinner.”
“He is an awfully good sort,” Colonel Fenchurch explained to Letty;
“one of my favourites—none of your ‘haw-haw’ chaps. His father is a
poor parson, and this boy has worked himself on—getting
scholarships; he passed first out of Sandhurst. I believe he scarcely
cost old Lumley a ten-pound note—he’s the hope of the family—such
a good——”
“There—there, Tom,” interrupted his wife, “that’s quite enough about
young Lumley! He doesn’t interest Letty, or me. Now, Letty, I can’t
have you standing idle, run away, take off your things, and go out
into the laundry and help Fletcher to ticket the things for the
Christmas Tree.”

It is extraordinary the amount of intimacy that can result from a


mutual undertaking, in which two young people are engaged. After
Mr. Lumley and Miss Glyn had finished the pulpit—which to do them
justice was a work of great labour crowned with success—they felt
as if they had been acquainted, not for hours, but for weeks. This
impression, was further strengthened when they met at dinner.
Letty, wearing her plain white school frock, the young man looking
handsome and well groomed in the regulation swallow tail. It
transpired, that they had been engaged in decorating the church,
and Mrs. Fenchurch and her husband might have been a little
surprised at finding they already knew one another so well, had not
the Colonel been absorbed in regimental stories, and Mrs. Fenchurch
mentally composing an important letter, that was to go by that
night’s post.
After dinner, when Colonel Fenchurch and his guest had each
smoked an excellent cigar, the former said:
“Now you must come into the drawing-room and hear my niece
sing,” and in spite of her aunt’s protestations that Letty had too
much to do, and she could not possibly spare her, she was led to the
piano and enchanted her listeners with two or three of Schumann’s
songs, and Gounod’s “Ave Maria,” and the extraordinary impression
that this beautiful girl had made upon a susceptible young man, was
now complete.
Lancelot Lumley looked and listened in silence, and surrendered his
heart without a further struggle. Although he knew, that it was
absolute madness for him to think of Miss Glyn as anything but a
star that dwelt apart! He had his way to make—she was penniless—
her face, her lovely face, was her fortune.
On Christmas morning as he sat alone in the Rectory pew, his eyes
often wandered across the aisle, in search of Miss Glyn. How her
sweet voice appeared to rise and swell above all others; and to the
infatuated lover it seemed, that the beautiful fair-haired girl, with the
rapt, devotional expression, was the embodiment of a Herald angel!
When the service was over, Lumley met his angel in the porch; here
they exchanged seasonable greetings and received congratulations
on their joint embellishment of the pulpit. Then, very late on
Christmas night, Lumley ran up to The Holt to bid them all good-bye.
He was hurrying home early the next morning, as his leave had
nearly expired; but brief as this visit was, he found an opportunity to
say to Letty:
“I hear you are coming out at the Hunt Ball the end of January?
Perhaps I can get leave for it. I generally try to put in an appearance
—you know it’s in my part of the world, and I see all my friends
there.”
The real gist of these explanations and excuses was summed up at
the end of the sentence:
“I say, Miss Glyn, if I do manage to turn up—will you keep a couple
of waltzes for me?”
At which request the young lady coloured, and replied:
“Yes, with pleasure.”

By and by the little seed planted by Mrs. Hesketh began to peep


above ground, and Letty Glyn’s will came to life. It made its first
appearance on the arrival of certain patterns from London, and the
question of a selection from among these, for a best afternoon, and
two evening dresses. Mrs. Fenchurch was not disposed to allow her
niece any choice in the matter. After looking at them critically, and
fingering the textures, she said:
“The dark green will make you a nice afternoon frock; and you will
want a smart black evening dress, and a ball-gown. Fletcher can
make them all with a little assistance from Mrs. Cope in the village.
For the ball dress, I fancy this white brocade trimmed with apple-
green satin. How do you think that will look?”
“I don’t think I should care about it,” replied Letty.
“What!” exclaimed her aunt, staring at her in glassy amazement, “it
would be charming. I remember I had a ball dress something like it
years ago.”
“But fashions have changed since then,” objected the girl; “don’t you
think a dress for a débutante should be soft, and all white, with
perhaps a little silver?”
“Now, my dear, what can you possibly know about it?”
“Not much, I admit; we were very plainly dressed at school, and our
clothes, I must confess, were dowdy, yet now and then, one had a
chance of seeing what was worn—for instance, at the opera.”
“Do you mean on the stage?”
“Oh no, I mean the lovely elegant Court ladies that were in the
boxes.”
“Then what is your own idea?” her aunt enquired sarcastically.
“I should like a soft white crêpe over white satin—with some silver
embroidery on the body.”
“Yes, I daresay you would!” sneered Mrs. Fenchurch; “why the
materials alone of such a dress would cost at least ten pounds.”
“I have ten pounds,” was the unexpected reply; then, colouring a
little in answer to her aunt’s sharp interrogative glance, “uncle gave
it to me for a Christmas box.”
For a moment Mrs. Fenchurch was speechless; she had never heard
a word of this present, and to tell the truth, Uncle Tom when he
placed the ten-pound note in the girl’s hand had said:
“This is just a little secret between you and me.” Now it was a secret
no longer!
Mrs. Fenchurch’s feelings were altogether too much for her. She
hastily collected her patterns, rose, and without a word flounced out
of the room.
It seemed to Mrs. Fenchurch, that this simple schoolgirl was
obtaining an extraordinary and disastrous ascendancy not only in the
village, but in the household. The servants—little country chits,
whom she had herself trained since they went out of pinafores—
would do anything for Miss Glyn. Sam the pug (Mrs. Fenchurch’s
own private dog) had handed over his heart to the girl, and attached
himself to her exclusively—and as for Tom, he was her slave! It was
Letty, Letty, Letty, all day; and when this girl began to make her
appearance in a wider circle, would she, Mrs. Fenchurch—influential
Mrs. Fenchurch—have to take a back seat?
It was also evident to Mrs. Fenchurch, that of late this interloper had
developed in many ways, and was inclined to enter into
conversation, and even to offer opinions! This sort of thing must be
nipped without delay. Once she began to take an inch, it would soon
become an ell—the inch, would be the selection of her ball-gown. It
was too ridiculous that a girl of seventeen who had never been to a
dance in her life, should dare to set up her taste in opposition to her
own.
With a stern resolve implanted in her mind, Mrs. Fenchurch sat down
and wrote off to London, ordering materials, which included the
white brocade, and green satin trimming.
In two or three days the order had arrived, and after breakfast, she
summoned Letty into her bedroom—a delightful chamber with large
bow windows and bright chintzes, facing full south, and overlooking
the lawns.
“You want to see me, aunt?” she asked as she entered (inwardly
quaking) and awaited instructions.
In the long glass which faced them from floor to ceiling, Mrs.
Fenchurch beheld the full-length reflections of her niece and herself;
she, in a rough tweed gown, spare, weather-beaten, long-nosed,
elderly; the girl, in a cheap blue serge, slim, erect, beautiful as the
morning—and with all her best days to come! A sharp spasm of
anger and jealousy darted through her mind. Alas! alas! Her own
best days had gone by. She, Dorothy Fenchurch, was entering on
the season of the sere and yellow leaf—and was conscious of an
agonising self-pity.
“Oh yes, it’s about your ball dress. Here,” tearing open her parcel,
“are the materials—they came to-day.”
It was undeniably a heavy and matronly brocade that she unfolded,
and as for the green satin ribbon, whatever it might look at night, it
was hideous by day!
“Oh!” exclaimed the girl, “so you got the brocade after all—and I
have sent for the white crêpe.”
“You have sent for the white crêpe—without consulting me!”
repeated Mrs. Fenchurch, speaking as it were in capital letters.
“Well, you see uncle gave me the money to spend as I pleased. The
crêpe has come too, and is really lovely. May I show it to you?”
“No, I don’t want to see it! I am amazed at your daring to do such a
thing as order a dress without my permission. One thing I can
promise you, and that is, that it won’t be made up! You go to the
ball—if you go at all—in a gown of my selection.”
“Then, I think,” and the girl became very red, “that I will stay at
home. Yes—I should look too ridiculous.”
“You will look exactly as I choose!” declared Mrs. Fenchurch,
suddenly losing her self-control; the smouldering resentment which
had been gathering for weeks now bursting into flames; a strange,
wild fury, all the long-pent-up grievances, annoyances, jealousies,
finding outlet at last. It must be confessed that just at the moment,
she was suffering torture from neuralgia in her face—the result of
long rides in piercing cold, or damp evenings, when the day’s sport
was over.
“May I ask if you understand your position here? Do you realise that
but for me, you would be now out earning your bread as a nursery
governess—are you aware, that ever since you were born, your
father’s people have never given you a single penny, and that all the
burden of your maintenance has fallen on us—or rather, I should
say, on me? And here, instead of being grateful for a happy home,
and for every luxury and indulgence, you are setting yourself up,
and saying what you will wear, and defying me to my face. Go to
your room—I hate the sight of you!”
Letty had listened to this bitter indictment with rapidly changing
colour; she knew that her aunt had never cared for her; but that she
absolutely hated her, and felt her to be a burden and an interloper,
came as a revelation. She left the room in silence, and Mrs.
Fenchurch, who was trembling with passion, snatched up the
brocade, carried it into the maid’s working-room, and commanded
her to lose no time about making it up for Miss Glyn. But afterwards,
when she had cooled, Mrs. Fen began to realise that she had gone
too far; for once in her life she acknowledged to herself, that she
had said too much.
Colonel Fenchurch was surprised and concerned when he saw his
niece at lunch with a very white face, and very red eyes. She ate
scarcely a morsel, and seemed to find considerable difficulty in
swallowing or speaking. On his wife’s brow there sat a heavy cloud,
and he noticed the servants glancing significantly at one another—
something had happened—there had been a blow up! But he, being
a cautious and somewhat nervous little gentleman, talked about the
weather and a lame horse, and withdrew as soon as possible into
the shelter of his smoking-room; where he consoled himself with a
recent copy of the Field, and a good cigar.
During the afternoon, Mrs. Fenchurch, having fortified herself with a
large glass of port and quinine, climbed up to the top of the house,
to make the amende to her niece.
“Well, Letty,” she began as she entered, “I am sorry we have had a
difference of opinion; but I suppose you will allow that you are little
more than a child, and that I am a woman of experience, and should
know what should be done, and worn, better than yourself?”
Letty stood up, her lips twitched, and her eyes filled with tears as
she answered:
“I am sorry, aunt, that you are displeased with me, and I—I—
suppose I was impertinent. I meant no harm in sending for the
crêpe dress, and indeed I thought it would save you buying my ball-
gown.”
This was precisely the attitude of which Mrs. Fenchurch most warmly
approved, and as the girl looked completely cowed, she said:
“I am sorry that I lost my temper—so let us make it up; and as you
have bought the white crêpe, you shall wear it. The other will come
in later,” and having offered, what she considered, a most
remarkable concession, Mrs. Fen kissed her niece sharply, and
walked downstairs. After she had departed, Letty stood listening to
her descending footsteps; somehow her aunt’s footsteps, coming or
going, invariably made her heart flutter like that of some terrified
animal. When the last sound had died away, she flung herself down
upon her bed. She didn’t care about the ball, or the crêpe dress—or
anything! She was an interloper; no one wanted her. How bitter it
was, to eat bread that was begrudged. In what shape or form could
she ever find release?
It was agonising to reflect, that she might go on living month after
month, and year after year, under the roof of a woman who had
called her a pauper, and a burden.
CHAPTER IV
THE great day dawned at last; the day of the Hunt Ball, which took
place annually in the Town Hall of Ridgefield, and was attended by
everybody who was anyone—and many nobodies.
Letty’s white crêpe, completed with her assistance, was charming;
soft, girlish, and yet distinguished—for her mental eye had copied it
from one of the trousseau gowns of a young and royal princess.
Mrs. Fenchurch, who was not remarkable for her taste in dress, wore
a ginger-coloured velvet, with opal ornaments; but she carried
herself with dignity and looked a Claremont, and a personage!
Colonel Fenchurch, in his pink coat, black satin breeches, and neat
silk stockings, squeezed himself into the brougham, with many
compliments for his two companions.
The town of Ridgefield was eight miles away, and as the family
bowled along the road at a steady pace, the Colonel dozed, his wife
meditated with closed eyes; but their niece all the time stared out on
the brown hedges and bare ditches, which were illuminated by the
flashing carriage lamps. Of what was she thinking? Was it possible
that she was wondering if Lancelot Lumley would be at the ball?
The Holt party were somewhat late arrivals, and when the carriage
drew up under an awning in front of the Town Hall, the first to step
out and run the gauntlet of many spectators was Colonel Fenchurch.
He had a remarkably well-turned leg, and looked particularly spruce.
His wife followed with impressive deliberation, and last of all came
the young lady in white. Her appearance was greeted with a loud
murmur, as she floated up the steps in the wake of her relations.
As they left the cloak-room, Mrs. Fenchurch, who had received many
greetings, was confronted with a lady in a superb sable cloak; a
handsome woman with flashing black eyes, and wearing in her hair
a magnificent diamond ornament.
“Oh, Mrs. Fen,” she exclaimed, “how are you? Going strong, eh?”
Then her eyes suddenly alighted on Mrs. Fen’s companion, and she
gave her a hard, critical stare.
“Ah, I suppose this little girl is the niece? going to take her
preliminary canter?” and with a patronising nod, she passed on to
the dressing-room.
Letty encountered her aunt’s eye, who, seizing her arm to lead her
forward, said:
“That is Mrs. Flashman, a wonderful rider, but an odious, detestable
creature, who slams gates, jostles you at fences, and swears at her
horses, and her servants.”
Two minutes later, Miss Glyn found herself with a programme in her
hand, standing in the ball-room. This was beautifully decorated, a
military band was established in the gallery, and the sides of the
room and a sort of platform at the upper end were densely crowded
with guests. Others were promenading up and down impatiently
awaiting the next waltz. Many neighbours had brought large house-
parties, whose smart gowns and splendid jewels, gave an air of
London society to the Brakesley Hunt Ball.
Mrs. Fenchurch paced slowly towards the dais. On her way, she
encountered several acquaintances, and introduced her niece to Lord
Seafield—a thin young man with a very prominent nose and no chin
—to Sir Edgar Broome, the M.F.H., and to the Dowager Duchess of
Campshire.
Before ascending the platform, she was accosted by Lancelot
Lumley, who came forward eagerly, programme in hand, and said:
“I hope Miss Glyn can spare me a couple of waltzes?”
Miss Glyn promptly produced her programme, and he scribbled his
initials before three. The next, which was just beginning, the one
before supper, and number twelve.
Mrs. Fenchurch looked on with glum disapproval. Three dances to an
impecunious subaltern! But she could not offer any audible
objection, and as the band struck up he said:
“Shall we make a start now before the room gets crammed?” and
light as a feather the young lady was whirled away, and the elder
was compelled to mount to the platform alone. But from this and
other coigns of vantage, the extraordinary beauty of Miss Glyn was
soon remarked. Indeed, her own chaperon, as she surveyed her
through her best gold glasses, assured herself, that she had never
until now realised the girl’s astonishing good looks! Of course dress
went a long way, so did youth—and candle-light; but Letty’s profile
was perfect, her complexion, the shape of her face, the setting on of
her head, were beyond criticism—and then her grace!
As Dorothy Fenchurch watched the white form revolving round and
round, she began to experience an intoxicating sensation; the
stimulating conviction was borne in upon her, that she had a
valuable prize to offer in the marriage market!
Seen just at home, running about in her school frocks and garden
apron, Letty was merely a pretty girl, with lots of hair, and a good
complexion; here, in the midst of the magnates of the land, she was
the beauty of the evening! People—her neighbours—gathered about
Mrs. Fenchurch and began to talk, discussing local news, the recent
weather, the various notable magnates who had honoured the ball.
“I say, Mrs. Fen, have you noticed the lovely nymph in white and
silver?” enquired the Secretary of the Hunt. “I haven’t seen anything
so exquisite for years; do let me show her to you?”
“There is no occasion, thank you, she is my niece, Miss Glyn,”
proclaimed the uplifted aunt.
“What—your niece?” echoed a matron. “Why, my dear lady, where
have you kept her all this time?”
“She has only been with us about two months.”
“And you have defrauded us of two months,” burst in a young man.
“Mrs. Fen, how dared you?”
“No, no,” protested Mrs. Flashman of the bold eyes and a
scandalously décolleté dress. “Mrs. Fenchurch is a clever woman.
She understands the art of an effective surprise!”
By this time the music had ceased, and Miss Glyn, a little breathless
and looking radiantly happy, was brought back to her aunt—now
encompassed by a number of men clamouring for introductions. In
the midst of this triumphant scene, a square-shouldered individual,
perfectly groomed, with the blue of his strong beard showing
through his heavy, clean-shaven face, stepped up on the platform. It
was the psychological moment! Here was the girl he had noticed at
the gate, surrounded by competitive partners, and he said to
himself, “No wonder!” This dazzling vision in white and silver,
eclipsed every woman in the room! He accosted Mrs. Fenchurch with
unusual empressement, and then glanced interrogatively at her
companion.
“Oh, let me present you to my niece—Mr. Blagdon—Miss Glyn,” she
murmured with effusive haste.
“Got any dances to spare?” he asked with an off-hand air.
“Yes,” she answered; “I have two or three left—but——”
“Are you engaged for the next?” he interrupted brusquely.
As this happened to be a set of Lancers, she breathed a reluctant
“No.”
“Oh, then I may have it?” he declared, confronting her with a bold
and confident eye. As she yielded her card, he wrote himself down
for this, as well as two others (which Letty had secretly been
keeping for Lancelot Lumley). “H. Blagdon” was also marked before
an extra; but a man with many thousands a year is granted a liberal
margin. Mrs. Fenchurch was looking on; her eyes glittered, a real
colour came into her thin cheeks. Supposing that he had taken a
fancy to Letty? It would be too wonderful to think of! The most
promising suitor she had allowed herself to expect, was some officer
from a neighbouring depôt; but then, until that evening she had
never fully understood the value of the treasure she had hidden at
The Holt. Now, her ambition, determination, and energy, were
stirred, and she was resolved that Letty should make a great match.
Everyone knew that Hugo Blagdon ‘barred girls’: he never noticed
them, never danced with them—indeed, he rarely danced at all—
generally he sat in a remote corner with some notorious married
woman—yet here he was, filling up the programme of her niece, and
devouring her shy beauty with his hard, bold eyes.
Undoubtedly most people liked to look at Letty. Was there ever such
a perfect little nose, such a short upper lip, delicately cut mouth, or
sweeping black lashes?
Presently the Lancers struck up, and Blagdon, offering his arm,
conducted his partner down the room, as it were in triumph;
undoubtedly she was the star of the evening! As he passed along,
he noticed that the eyes of everyone were fixed upon his
companion. This was just the sort of girl that would suit him for a
wife! a girl so remarkable, so absolutely perfect in appearance, that
all the jealous world would stare at her open-mouthed.
Having invited an aristocratic vis-à-vis, they took their places in a set
and danced. Blagdon found Miss Glyn shy—she had not much to say
for herself. With difficulty he gathered that she didn’t hunt, had only
lately left school, and was seventeen last birthday; but it was
sufficiently agreeable for him to feel that she was the cynosure of all
eyes, and that he was the envy of every man in the room!
Mrs. Flashman, who was in the same set, swam hither and thither in
her gorgeous French gown, and now and then darted glances of
sarcastic amusement at her friend Hugo and the little baby; and
whispered en passant in the Grand Chain:
“Where is the bread and butter?”
The remainder of that evening was, from her aunt’s point of view, an
uninterrupted triumph for Letty: a number of influential people had
begged to make her acquaintance; envious and rancorous rivals—
mothers of large families, had uttered spiteful things about Hugo
Blagdon. He had taken her niece to supper, had only danced with
her that night, and when not dancing, had posted himself where he
could keep her in view—all of which signs and tokens even the most
comatose chaperon could not fail to note! Oh, it was undoubtedly a
case.
Had Letty enjoyed her first ball? She was not sure. She enjoyed
dancing with Mr. Lumley and with various other young men; she
enjoyed the band, and the ices, and loved dancing for dancing’s
sake, but somehow there seemed to be between Mr. Lumley and Mr.
Blagdon a sharp but secret conflict for her company. When she was
swinging round in the arms of Mr. Lumley, she was aware that the
other was watching them closely; and when it was Blagdon’s dance
he stalked up and claimed her with an air of appropriation, that she
found both disagreeable and disconcerting.
However she danced the last waltz that evening with the soldier—
who informed her that he had come all the way from Aldershot on
purpose to claim her promise! He was so good-looking, he had a
charming voice and such nice eyes; little Letty’s heart beat quickly,
and the colour came into her cheeks.
“Give my love to Aunt Harriet,” he said; “and tell her that I will run
over and see her before very long, and stay three or four days.”
For a moment the girl felt ecstatically happy, inspired by an
unreasoning joy and strangely moved and uplifted; but it was Mr.
Blagdon who escorted her to have a cup of soup at the buffet before
she departed, who stared at her with an expression that frightened
her, and who conducted her down to the entrance hall through a
long line of spectators. And never had Letty known her aunt to be so
gracious, so affectionate, or in such talkative good-humour; she had
actually called her ‘darling!’
“I hope you are well wrapped up,” she urged; “take care of your
dress, darling.”
“And mind you take great care of her,” supplemented Blagdon at the
carriage window. He held out his hand to Letty, kept hers an
unnecessary length of time, and squeezed it painfully ere he closed
the door of the brougham and they drove off. The last object she
beheld, thrown into sharp relief by the glaring lamps and red carpet,
was his hard, staring brown eyes, his stolid, complacent face, and
she sank into her corner with a sigh of relief. Thank goodness she
would never see him again!
She was to hear of him, however! On the way home her aunt loudly
sang the praises of Hugo Blagdon, the richest man in the county. He
had the most lovely place, and was so popular; he had travelled a
great deal, and owned a yacht and a coach, indeed everything—just
like a prince in a fairy tale. During all these eulogiums and dazzling
descriptions Colonel Fenchurch maintained an unusual silence.
“What do you think of him, Letty?” he enquired at last.
“He dances well,” she answered carelessly, “though he soon gets out
of breath, and has rather an old-fashioned step.”
“Well, there is not a woman in this part of the world that isn’t
delighted to have him for a partner,” said her aunt, with an air of
finality; then, changing the subject, she proceeded to discuss the
ball in detail, from the decorations to the soup. Her remarks about
the guests—especially girls—were not altogether generous; now that
she had, so to speak, her own goods to offer, Mrs. Fenchurch was a
merciless critic of the wares of others.
“Did you notice Lady Vera, Tom? She’s supposed to be a beauty, a
tall, scraggy, spotty creature, with a wreath over her nose?” A
pause. “And how can Mrs. Reed allow her daughters to be seen in
such filthy frocks!—anything good enough for the country. Those
poor Bradfields hardly left their seats—so humiliating for a chaperon
to have her charges on hand all the time—what do you say, Tom?”
But Tom’s sole reply was a gentle snore.
Then, turning to Letty and stroking her arm, her aunt said:
“My dear child, you were perfectly right about the white crêpe, you
looked charming—charming! I was proud of you!” and as she
pinched her wrist, playfully, the girl, with the quick insight of youth,
divined that here was an entirely different relative to the one who
had told her she was a ‘pauper, and a burden.’ She now addressed
her, as if she were an equal—and indeed there was actually a tinge
of deference in her remarks. What did it mean?
The Belle of the Hunt Ball toiled up to bed tired and footsore at five
o’clock in the morning. She had enjoyed the evening immensely, and
yet she had not enjoyed it! On the one hand, there was the dancing,
the good partners, the charming things people had said to her, and
the agreeable inward conviction of having been whispered about,
and admired; on the other, there was the rich man, with his staring
eyes and brusque, imperious manner—and the inexplicable rise in
the temperature of her aunt’s affection. What did it mean?
And still wondering, Letty tumbled into bed, and presently entered
the land of dreams.
CHAPTER V
THE morning after the ball, Letty was aroused from the profound
sleep of youth and exhaustion by a stealthy, grating sound, and
opening her eyes, to her amazement she beheld Jones, the under-
housemaid, kneeling on the hearth-rug, intent on kindling a
particularly sulky fire.
As she raised herself on her elbow, blinking and bewildered, the
maid sat up on her heels and proceeded to explain the situation with
glib volubility.
“Oh, miss, I’m sorry; the mistress gave orders you were not to be
disturbed, and I was to light your fire; but there ain’t been one in
the grate this forty year, and it’s a sore job. Hawkins is bringing up
your breakfast.”
As she spoke, the door-handle turned and Hawkins entered, bearing
with unusual pomp and circumstance a heavily laden tray. Letty
rubbed her eyes. Was she still dreaming? Why were the two maids
in waiting upon her? She was well aware that her aunt considered
bedroom fires unnecessary, and breakfast in bed a slothful
indulgence. She, however, dissembled her surprise, and accepted
these unexpected favours with commendable composure.
Having nibbled at some buttered toast and swallowed a cup of tea,
she sprang out of bed to search for her programme, and survey
herself in the glass. In the glass she beheld an oval face, a pair of
drowsy blue eyes, a pair of soft pink cheeks, and a mass of tumbled
brown hair. Was she beautiful? she wondered. Mr. Blagdon had
implied as much—indeed, more than implied. What bad manners to
make blunt personal remarks! Well, his opinion was of no
consequence; but did other people think her pretty? (Other people
naturally included Lancelot Lumley. She confessed to herself that she
would like him to admire her.)
Oh, how cold it was! She curled up her delicate little toes, and,
programme in hand, plunged once more into her comfortable nest.
Here she prepared to study at leisure the exciting contents of her
precious card—no easy task. The card was covered with scribbled
names, sketches, initials, stars, hieroglyphics, corrections—and yet,
on the whole, it made agreeable reading.
In the midst of this interesting occupation the door opened very
gently—the programme disappeared as if in the hands of a conjurer
—and Mrs. Fenchurch advanced into the room showing all her upper
teeth, a sure signal of unusual amiability.
“Well, my dear girl,” she began, “how are you to-day? Dead?”
“Oh no,” sitting erect; “I’m all right, thank you, Aunt Dorothy.”
“I thought you’d better have a good sleep after your first ball. My!”
as her glance fell upon a tattered garment, “look at your poor frock!”
Yes, indeed, there was a large obtrusive rent in the skirt, and a
streamer of ragged crêpe made no attempt at concealment. Yet
instead of the expected sharp scolding, Mrs. Fenchurch merely
remarked:
“How you danced! You could have filled your card ten times over. By
the way, may I look at your programme? I see the blue tassel
sticking out under your pillow.”
With much reluctance, and deep and guilty blushes, Letty produced
the desired treasure and yielded it to her visitor, who was now
staring at her so fixedly, that one would almost suppose that she
beheld her for the first time! In her mind’s eye, Mrs. Fenchurch really
was contemplating an absolutely strange niece! So this simple, timid,
obedient, little schoolgirl, unconsciously possessed the fatal
endowment, the wonderful, invincible power, that has moved armies
and fleets. Unquestionably, Letty had the gift; and her relative was
determined to turn it to the utmost advantage.
With the record of her niece’s partners in her hand, Mrs. Fenchurch
seated herself, squarely, comfortably, and sociably on the bed, and
proceeded to discuss the ball, and its incidents, with all the zest and
vivacity of one of the girl’s own contemporaries.
“How well I remember my first ball,” she said meditatively; “I was so
frightened my teeth actually chattered as we drove to it, and, after
all, I enjoyed myself enormously. I wore white, of course, looped up
with water lilies, and I remember a spiteful cousin asking me if they
were not spinach and eggs! Girls are so jealous! Now let me see
who you danced with—um—um—um——” nodding her head as her
eyes travelled over the card. “Lord Deloraine twice—but, of course,
he is married—and what about the Duke?” looking up quickly.
“I had not a dance left.”
“Who is V. K.? Oh yes, I know—the Austrian Attaché staying with the
Beauvoirs. H. B., H. B., H. B. Oh, Letty! How often did you dance
with Hugo Blagdon?”
“Two or three times,” she answered stiffly, having made up her mind
to give her aunt no satisfaction with respect to this overbearing
odious partner.
“He took you in to supper, dear, too,” continued Mrs. Fenchurch;
“and, oh yes,” nodding her head and trying to look arch, “I saw you
sitting together in the long corridor. Tell me, what did you talk
about?” and she gazed into the girl’s face with a pair of penetrating
asking eyes.
How Letty wished she would not stare at her in this fashion, and
breathe through her nose. Positively her aunt filled her with sheer
physical terror—yes, and repulsion.
“I really can’t remember, Aunt Dorothy. I think he said the supper
was bad.”
“But surely he paid you some pretty compliment?” persisted her
tormentor. “Come now?” she urged coaxingly.
“I daresay he did—I—I forget.”
“Did he say anything about coming over here to call?” and her tone
was anxious.
“I—I’m not sure,” murmured the girl, who mentally writhed under
this inquisition. Never in her life had she felt so mortally shamefaced
and shrinking. She longed to pull the bedclothes over her head and
hide herself away, from that inflexibly soliciting countenance.
Her reluctant replies were so vague and unsatisfactory, that at last
her chaperon realised she could not get much out of Letty as yet—all
in good time! Again she gazed at her niece long and thoughtfully, as
though seeing in her a multitude of new possibilities; then, rising,
she said in her brisk, every-day manner:
“I’ll tell Jones to bring up your bath water—it is nearly twelve
o’clock,” and Mrs. Fen took her departure, leaving the girl with a
grateful sense of pressure removed, and a happy consciousness of
relief.
When, an hour later, the beauty of the Hunt Ball descended to the
morning-room, she found herself still surrounded by an atmosphere
of indulgence and affection. Her aunt handed her a novel to read; as
a rule light literature was tabooed till nightfall—and at lunch Mrs.
Fen helped her poor relation to the liver wing, and commanded
Hawkins to give Miss Glyn a glass of claret.
When Hawkins had withdrawn, after serving the coffee, Mrs.
Fenchurch cleared her throat and said:
“The Bonhams are having a young people’s dance this day week,
and Lady Bonham has asked me to go over and take you, Letty, and
stay all night. How would you like that?”
“It would be delightful—another dance!” and her eyes sparkled.
“I’ve been talking to Fletcher this morning, and she thinks that if I
have Mrs. Cope up from the village she may be able to make the
white brocade and the green cloth. I daresay you won’t mind giving
a little assistance yourself?”
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebookfinal.com

You might also like