0% found this document useful (0 votes)
5 views

Introduction To 64 Bit Intel Assembly Language Programming For Linux Ray Seyfarth download

The document is an introduction to 64-bit Intel assembly language programming for Linux, authored by Ray Seyfarth. It emphasizes the evolution of Intel CPU architecture and the simplification of assembly programming with the x86-64 architecture, focusing on hands-on learning from the outset. The book targets beginners and covers various topics, including registers, functions, arrays, and floating-point instructions, with practical assignments and resources for further study.

Uploaded by

hqvjznia841
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
0% found this document useful (0 votes)
5 views

Introduction To 64 Bit Intel Assembly Language Programming For Linux Ray Seyfarth download

The document is an introduction to 64-bit Intel assembly language programming for Linux, authored by Ray Seyfarth. It emphasizes the evolution of Intel CPU architecture and the simplification of assembly programming with the x86-64 architecture, focusing on hands-on learning from the outset. The book targets beginners and covers various topics, including registers, functions, arrays, and floating-point instructions, with practical assignments and resources for further study.

Uploaded by

hqvjznia841
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/ 91

Introduction To 64 Bit Intel Assembly Language

Programming For Linux Ray Seyfarth download

https://ebookbell.com/product/introduction-to-64-bit-intel-
assembly-language-programming-for-linux-ray-seyfarth-4768836

Explore and download more ebooks at ebookbell.com


Here are some recommended products that we believe you will be
interested in. You can click the link to download.

Introduction To 64 Bit Windows Assembly Programming Fourth Edition 4th


Edition Ray Seyfarth

https://ebookbell.com/product/introduction-to-64-bit-windows-assembly-
programming-fourth-edition-4th-edition-ray-seyfarth-7142452

Introduction To 64 Bit Windows Assembly Programming Ray Seyfarth

https://ebookbell.com/product/introduction-to-64-bit-windows-assembly-
programming-ray-seyfarth-10314084

Introduction To Computer Organization An Under The Hood Look At


Hardware And X8664 Assembly Robert G Plantz

https://ebookbell.com/product/introduction-to-computer-organization-
an-under-the-hood-look-at-hardware-and-x8664-assembly-robert-g-
plantz-38184498

Introduction To Modern Analysis 2nd Edition 2nd Kantorovitz

https://ebookbell.com/product/introduction-to-modern-analysis-2nd-
edition-2nd-kantorovitz-44870612
Introduction To The Speechmaking Process 15th Edition Diana K Leonard
Raymond S Ross

https://ebookbell.com/product/introduction-to-the-speechmaking-
process-15th-edition-diana-k-leonard-raymond-s-ross-44874488

Introduction To Construction Management 2nd Edition 2nd Fred Sherratt

https://ebookbell.com/product/introduction-to-construction-
management-2nd-edition-2nd-fred-sherratt-44899008

Introduction To Analysis With Complex Numbers Irena Swanson

https://ebookbell.com/product/introduction-to-analysis-with-complex-
numbers-irena-swanson-44912170

Introduction To Quantitative Methods In Business With Applications


Using Microsoft Office Excel 1st Edition Bharat Kolluri

https://ebookbell.com/product/introduction-to-quantitative-methods-in-
business-with-applications-using-microsoft-office-excel-1st-edition-
bharat-kolluri-44915766

Introduction To Biostatistical Applications In Health Research With


Microsoft Office Excel And R 2nd Edition Robert P Hirsch

https://ebookbell.com/product/introduction-to-biostatistical-
applications-in-health-research-with-microsoft-office-excel-and-r-2nd-
edition-robert-p-hirsch-44915830
Introduction to 64
Bit Intel Assembly
Language Programming
for Linux
Introduction to 64 Bit Intel Assembly Language
Programming for Linux

Ray Seyfarth

October 27, 2011


Ray Seyfarth
School of Computing
University of Southern Mississippi
Hattiesburg, MS 39406
USA

Seyfarth, Ray
Introduction to 64 Bit Intel Assembly Language Programming
Includes index.
ISBN-13: 978-1466470033
ISBN-10 : 1466470038

@20 1 1 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.
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 on 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 reg­
ister 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 program­
mmg.
There are now 16 general purpose integer registers with a few spe­
cialized instructions. The archaic register stack of the 8087 has been
superseded by a well-organized model providing 16 floating point regis­
ters with the floating point instructions for 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. The dominant mode of operation will be 64 bits within
a few short years. 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
prograrnmmg. There is no 16 or 32 bit programming and the discussion

Ill
IV PREFACE

of the history is focused on explaining the origin of the old register names
and the few non-orthogonal features of the instruction set.
The intention is to get students involved with using the yasm assembler
and the gdb debugger from the start. There are assignments using the
computer from the very first chapter. Not every statement will be fully
understood at this time, but the assignments are still possible.
The primary target for this book is beginning assembly language pro­
grammers and for a gentle introduction to assembly programming, stu­
dents should study chapters 1 , 2, 3, 5, 6, 7, 8, 9, 10 and 1 1 . Chapter 4
on memory mapping is not critical to the rest of the book and can be
skipped if desired.
Chapters 12 through 1 5 are significantly more in depth. Chapter
1 5 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 in assembly language.
The final four chapters focus on high performance programming, in­
cluding discussion of SSE and AVX programming.
The author provides PDF 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.
Thank you for buying the book and I hope you find something inter­
esting and worthwhile inside.
Acknow ledgernents

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 gee 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 con­
tributions 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.

v
Vl ACKNOWLEDGEMENTS

Teaching 64 bit assembly language has uncovered a few mistakes and


errors in the original Create Space book from July 201 1 . In particular I
wish to thank Chris Greene, Evan Stuart and Brandon Wolfe for locating
errors in the book.
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.
Contents

Preface iii

Acknowledgements v

1 Introduction 1
1.1 Why study assembly language? 2
1 .2 What is a computer? . . . 4
1 .2 . 1 Bytes . . . . . . . 4
1 .2.2 Program execution 4
1 .3 Machine language . . . . 5
1 .4 Assembly language . . . 6
1.5 Assembling and linking 8

2 Numbers 11
2.1 Binary numbers . 11
2.2 Hexadecimal numbers 13
2.3 Integers . . . . . . . . 16
2.3.1 Binary addition . 18
2.3.2 Binary multiplication 19
2.4 Floating point numbers . . . 20
2.4.1 Converting decimal numbers to floats 23
2.4.2 Converting floats to decimal . 24
2.4.3 Floating point addition . .
. 24
2.4.4 Floating point multiplication 25

3 Computer memory 27
3.1 Memory mapping . 27

Vll
Vlll CONTENTS

3.2 Process memory model in Linux 28


3.3 Memory example . . . . . . . 30
3.4 Examining memory with gdb 32
3.4.1 Printing with gdb 32
3.4.2 Examining memory 34

4 Memory mapping in 64 bit mode 37


4.1 The memory mapping register . 37
4.2 Page Map Level 4 . . . . . . . 38
4.3 Page Directory Pointer Table 39
4.4 Page Directory Table . 39
4.5 Page Table . . . . . . . . . . 39
4.6 Large pages . . . . . . . . . . 40
4. 7 CPU Support for Fast Lookups 40

5 Registers 43
5.1 Moving a constant into a register . . . . . . 45
5.2 Moving values from memory into registers . 46
5.3 Moving values from a register into memory 49
5.4 Moving data from one register to another 49

6 A little bit of math 51


6.1 Negation . . 51
6.2 Addition . .
. . 52
6.3 Subtraction . . 54
6.4 Multiplication . 55
6.5 Division . . . . 57
6.6 Conditional move instructions . 57
6.7 Why move to a register? . . . . 58

7 Bit operations 61
7.1 Not operation . 61
7.2 And operation 62
7.3 Or operation 63
7.4 Exclusive or operation 64
7.5 Shift operations . . . . 65
7.6 Bit testing and setting 67
7. 7 Extracting and filling a bit field . 68
CONTENTS IX

8 Branching and looping 71


8.1 Unconditional jump . . . . 71
8.2 Conditional jump . . . . . . 73
8.2. 1 Simple if statement . 74
8.2.2 If/else statement . . 75
8.2.3 If/else-if/else statement 75
8.3 Looping with conditional jumps . 76
8.3.1 While loops . . 76
8.3.2 Do-while loops 80
8.3.3 Counting loops 82
8.4 Loop instructions . . . 82
8.5 Repeat string (array) instructions . 83
8.5. 1 String instructions . . . . . 83

9 Functions 89
9.1 The stack 89
9.2 Call instruction . . 90
9.3 Return instruction 91
9.4 Function parameters and return value 91
9.5 Stack frames 92
9.6 Recursion 94

10 Arrays 99
10.1 Array address computation . . . . . . 99
10.2 General pattern for memory references 101
10.3 Allocating arrays . . . . . 103
10.4 Processing arrays . . . . . . . . . . . . 104
10.4. 1 Creating the array . . . . . . . 104
10.4.2 Filling the array with random numbers 105
10.4.3 Printing the array . . . . . . . . . . . 106
10.4.4 Finding the minimum value . . . . . . 107
10.4.5 Main program for the array minimum 107
10.5 Command line parameter array . . . . . . . . 109

1 1 Floating point instructions 115


1 1 . 1 Floating point registers . . . . . . . . . . . . 115
1 1 .2 Moving data to/from floating point registers . 116
X CONTENTS

1 1 .2.1 Moving scalars . . . 116


1 1 .2.2 Moving packed data 1 17
11.3 Addition . . . . . . . . . . . 1 17
1 1 .4 Subtraction . . . . . . . . . 1 18
1 1 .5 Multiplication and division 119
1 1 .6 Conversion . . . . . . . . . 1 19
1 1 .6.1 Converting to a different length floating point . 119
1 1 .6.2 Converting floating point to/from integer 120
1 1 .7 Floating point comparison . . . . 120
1 1 .8 Mathematical functions . . . . . 121
1 1 .8 . 1 Minimum and maximum . 122
1 1.8.2 Rounding . . 122
1 1 .8.3 Square roots . 123
1 1 .9 Sample code . . . . . . 123
1 1 .9.1 Distance in 3D 123
1 1 .9.2 Dot product of 3D vectors . 124
1 1 .9.3 Polynomial evaluation 124

12 System calls 129


12. 1 32 bit system calls 130
12.2 64 bit system calls 130
12.3 C wrapper functions 131
12.3.1 open system call 132
12.3.2 read and write system calls 133
1 2.3.3 lseek system call 134
1 2.3.4 close system call . . . . . . 135

13 Structs 137
13.1 Symbolic names for offsets . . . . . . . . 138
1 3.2 Allocating and using an array of structs 140

14 Using the C stream 1/0 functions 143


14.1 Opening a file . . 1 44
14.2 fscanf and fprintf 145
14.3 fgetc and fputc . 1 45
14.4 fgets and fputs . 146
14.5 fread and fwrite . 147
CONTENTS XI

14.6 £seek and ftell . 148


1 4.7 £close . . . . . 149

15 Data structures 151


1 5 . 1 Linked lists . . . . . . . . . . 151
15.1.1 List node structure . . 152
15.1.2 Creating an empty list 152
15.1.3 Inserting a number into a list 153
1 5 . 1 .4 Traversing the list . . . . . . 153
1 5.2 Doubly-linked lists . . . . . . . . . . 156
15.2.1 Doubly-linked list node structure 157
15.2.2 Creating a new list . . . . . . . 157
15.2.3 Inserting at the front of the list 1 58
1 5.2.4 List traversal . . . . . . . . . . 159
15.3 Hash tables . . . . . . . . . . . . . . . 160
15.3.1 A good hash function for integers . 161
15.3.2 A good hash function for strings . 161
15.3.3 Hash table node structure and array 162
15.3.4 Function to find a value in the hash table 162
15.3.5 Insertion code . . . . . . 163
15.3.6 Printing the hash table 164
15.3.7 Testing the hash table . 165
1 5.4 Binary trees . . . . . . . . . . . 166
1 5.4.1 Binary tree node and tree structures 167
15 .4.2 Creating an empty tree . . . 167
15.4.3 Finding a key in a tree . . . . 168
15.4.4 Inserting a key into the tree . 169
15.4.5 Printing the keys in order . . 170

16 High performance assembly programming 175


16.1 General optimization strategies 175
16.2 Use a better algorithm 176
16.3 Use C or C++ . . . . . . . . . 177
16.4 Efficient use of cache . . . . . . 177
16.5 Common subexpression elimination . 179
16.6 Strength reduction . . . 179
16.7 Use registers efficiently . . . . . . . . 180
Xll CONTENTS

16.8 Use fewer branches . . . . . . . . . . . 180


16.9 Convert loops to branch at the bottom . 180
16.10Unroll loops . 181
16. 1 1 Merge loops . . . . 183
1 6 . 12Split loops . . . . . 183
16.13Interchange loops . 183
1 6 . 14Move loop invariant code outside loops . 184
16.15Remove recursion . . . . 184
16.16Eliminate stack frames . . . . . . . . . . 185
16.17Inline functions . . . . . . . . . . . . . . 185
16.1 8Reduce dependencies to allow super-scalar execution 185
16.19Use specialized instructions . . . . . . . . . . . . . . 186

17 Counting bits in an array 189


17.1 C function . . . . . . . . . . . . . . . . . . . . . 189
17.2 Counting 1 bits in assembly . . . . . . . . . . . 190
17.3 Precomputing the number of bits in each byte . 193
17.4 Using the popcnt instruction . . . . . . . . . . 194

18 Sobel filter 197


18.1 Sobel in C . 198
1 8.2 Sobel computed using SSE instructions . 199

19 Computing Correlation 207


19.1 C implementation . . . . . . . . . . . . . 207
1 9.2 Implementation using SSE instructions . 208
19.3 Implementation using AVX instructions 211

A Using gdb 217


A.1 Preparing for gdb . 217
A.2 Starting . . . . . . 219
A.3 Quitting . . . . . . 219
A .4 Setting break points 219
A.5 Running . . . . . . . .
·
219
A.6 Printing a trace of stack frames 220
A.7 Examining registers 222
A.8 Examining memory . . . . . . . 223
CONTENTS Xlll

B Using scanf and printf 225


B . l scanf . 225
B . 2 printf . . . . . . . 227

C Using macros in yasm 229


C.l Single line macros 229
C.2 Multi-line macros . 230
C .3 Preprocessor variables 232

D Sources for more information 233


D .1 yasm user manual . . . . . . . . . . . 233
D.2 nasm user manual . . . . . . . . . . . 233
D.3 Dr. Paul Carter's free assembly book . 233
D .4 64 bit Machine Level Programming . 233
D.5 GDB Manual . . . . 234
D.6 DDD Manual . . . . 234
D .7 Intel Documentation 234
XIV CONTENTS
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 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 per­
form some functions which cannot be handled in a high-level language.
The goal of this book is to teach general principles of assembly lan­
guage programming. It targets people with some experience in program­
ming 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 Linux operating system, due to the free availabil­
ity of excellent compilers, assemblers and debuggers. The instructions
are the same on x86-64 systems regardless of the operating system and
BSD and Mac OS /X operating systems use the same function call stan­
dards, though there are differences between Windows and Linux along
with library and system call differences. Differences between assembly
programming for Windows 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

1
2 CHAPTER 1 . INTROD UCTION

and AVX instructions. The coming trend is for the size of SIMD registers
to increase and it generally requires assembly language to take advantage
of the SIMD capabilities.

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 ma;ny 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
even the function call interface employed in x86-64 Linux 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 relia­
bility. 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 assem­
bly 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
1 . 1 . WHY STUDY ASSEMBLY LANGUAGE? 3

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
other hand an assembly programmer with similar skills can achieve re­
markable results. A good example is the Atlas ( Automatically Tuned Lin­
ear 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 pos­


sible 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. Un­
derstanding 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 lan­
guage is fundamental in understanding why bugs behave the way they do.
Without studying assembly language, a programming language is primar­
ily a mathematical concept obeying mathematical laws. Underneath this
mathematical exterior the computer executes machine instructions which
have limits and can have unexpected behavior.
4 CHAPTER 1 . INTRODUCTION

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 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.

1.2 . 1 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
m use.
A byte can be interpreted as a binary number. The binary number
01010101 equals the decimal number 85. 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.

1.2 . 2 Program execution

A program in execution occupies a range of addresses for the instructions


of the program. The following 12 bytes constitute a very simple program
which simply exits (with status 5) :
1 . 3. MACHINE LANGUAGE 5

Address Value
4000b0 184
4000b1 1
4000b2 0
4000b3 0
4000b4 0
4000b5 187
4000b6 5
4000b7 0
4000b8 0
4000b9 0
4000ba 205
4000bb 128

The addresses are listed in hexadecimal, though they could have


started with the equivalent decimal number 4194480. The hexadecimal
values are more informative in this case, since there are numerous 0 val­
ues in the hexadecimal representation. This gives a clue to the way the
operating system maps a program into memory. Pages of memory begin
with addresses with the rightmost 3 hexadecimal "digits" equal to 0, so
the beginning of the 12 byte program is fairly close to the start of a page
of memory.

1.3 Machine language


Each type of computer has a collection of instructions it can execute.
These instructions are stored in memory and fetched, interpreted and
executed during the execution of a program. The sequence of bytes (like
the previous 12 byte program) is called a "machine language" program. It
would be quite painful to use machine language. You would have to enter
the correct bytes for each instruction of your program. You would have
to know the addresses of all data used in your program. A more realistic
program would have branching instructions. The address to branch to
depends on where the computer loads your program into memory when
it is executed. Furthermore the address to branch to can change when
you add, delete or change instructions in your program.
The very first computers were programmed in machine language, but
6 CHAPTER 1 . INTROD UCTION

people soon figured out ways to make the task easier. The first improve­
ment is to use words like mov to indicate the selection of a particular in­
struction. In addition people started using symbolic names to represent
addresses of instructions and data in a program. Using symbolic names
prevents the need to calculate addresses and insulates the programmer
from changes in the source code.

1 .4 Assembly language
Very early in the history of computing ( 1950s) , programmers developed
symbolic assembly languages. This rapidly replaced the use of machine
language, eliminating a lot of tedious work. Machine languages are con­
sidered "first-generation" programming languages, while assembly lan­
guages are considered "second-generation" .
Many programs continued to be written in assembly language .after
the invention of Fortran and Cobol ( "third-generation" languages) in the
late 1950s. In particular operating systems were typically nearly 100%
assembly until the creation of C as the primary language for the UNIX
operating system.
The source code for the 12 byte program from earlier is listed below:

Program : exit

Exe cutes the exit system call

No input

Output : only the exit status ($? in the shell)

segment . t ext
global _start

_start :
mov eax , 1 1 is the exit sys call number
mov ebx , 5 the status value to return
int Ox80 execute a system call
1.4. ASSEMBLY LANGUAGE 7

You will observe the use of ";" to signal the start of comments in this
program. Some of the comments are stand-alone comments and others are
end-of-line comments. It is fairly common to place end-of-line comments
on each assembly instruction.
Lines of assembly code consist of labels and instructions. A label
usually starts in column 1, but this is not required. A label establishes
a symbolic name to the current point in the assembler. A label on a line
by itself must have a colon after it, while the colon is optional if there is
more to the line.
Instructions can be machine instructions, macros or instructions to
the assembler. Instructions usually are placed further right than column
1 . Most people establish a pattern of starting all instructions in the same
column.
The statement "segment . text" is an instruction to the assembler
itself rather than a machine instruction. This statement indicates that the
data or instructions following it are to be placed in the text segment or
.

section. In Linux this is where the instructions of a program are located.


The statement "global _start" is another instruction to the assem­
bler, called an assembler directive or a pseudo opcode (pseudo-op) . This
pseudo-op informs the assembler that the label _start is to be made
known to the linker program when the program is linked. The _start
function is the most basic "entry point" for a Linux program. When the
system runs a program it transfers control to the _start function. A
typical C program has a main function which is called indirectly via a
_start function in the C library.
The line beginning with _start is a label. Since no code has been
generated up to this point, the label refers to location 0 of the program's
text segment.
The remaining 3 lines are symbolic opcodes representing the 3 ex­
ecutable instructions in the program. The first instruction moves the
constant 1 into register eax while the second moves the constant 5 into
register ebx. The final instruction generates a software interrupt num­
bered Ox80 which is the way Linux handles 32 bit system calls. (This
code works on both 32 bit and 64 bit Linux systems. )
8 CHAPTER 1 . INTROD UCTION

1.5 Assembling and linking


We use the yasm assembler to produce an object file from an assembly
source code file:
yasm -f elf64 -g dwarf2 -1 exit . lst exit . asm

The yasm assembler is modeled after the nasm assembler. yasm pro­
duces object code which works properly with the gdb and ddd debuggers,
while nasm did not produce acceptable code for debugging during testing.
The -f elf64 option selects a 64 bit output format which is compatible
with Linux and gee. The -g dwarf2 option selects the dwarf2 debugging
format, which is essential for use with a debugger. The -1 exit . 1st asks
for a listing file which shows the generated code in hexadecimal.
The yasm command produces an object file named exit . o , which
contains the generated instructions and data in a form ready to link with
other code from other object files or libraries. In the case of an assembly
program with the _start function the linking needs to be done with ld:
ld -o exit exit . o

The -o exit option gives a name to the executable file produced by


ld. Without that option, ld produces a file named a . out . If the assembly
program defines main rather than _start, then the linking needs to be
done using gee:

gee -o exit exit . o

In this case gee will incorporate its own version of _start and will
call main from _start (or indirectly from _start ) .
You can execute the program using:
. /exit
1 . 5. ASSEMBLING AND LINKING 9

Exercises

1 . Enter the assembly language program from this chapter and assem­
ble and link it. Then execute the program and enter echo $?. A
non-zero status indicates an error. Change the program to yield a
0 status.
2. Modify the assembly program to define main rather than _start.
Assemble it and link it using gee. What is the difference in size of
the executables?
3. In C and many other languages, 0 means false and 1 (or non-zero)
means true. In the shell 0 for the status of a process means success
and non-zero means an error. Shell if statements essentially use 0
for true. Why did the writer of the first shell decide to use 0 for
true?
10 CHAPTER 1. INTROD UCTION
Chapter 2

Numbers

All information in a computer is stored as collections of bits. These bits


can be interpreted in a variety of ways as numbers. In this chapter we
will discuss binary numbers, hexadecimal numbers, integers and floating
point numbers.

2.1 Binary numbers


We are used to representing numbers in the decimal place-value system.
In this representation, a number like 1234 means 1 * 103 + 2 * 102 + 3 * 10+4.
Similarly binary numbers are represented in a place-value system using 0
and 1 as the "digits" and powers of 2 rather than powers of 10.
Let's consider the binary number 10101 1 1 1 . This is an 8 bit number
so the highest power of 2 is 27 . So this number is

10101 1 1 1 = 2 7 + 25 + 2 3 + 22 + 2 + 1
= 128 + 32 + 8 + 4 + 2 + 1
= 175

The bits of an 8 bit number are numbered from 0 to 7 with 0 being the
least significant bit and 7 being the most significant bit. The number
175 has its bits defined below.
The conversion from binary to decimal is straightforward. It takes a
little more ingenuity to convert from decimal to binary. Let 's examine

11
12 .CHAPTER 2. NUMBERS

bit value 1 I 0 I 1 I 0 I 1 1 1 I 1 I
bit position 7 6 5 4 3 2 1 0

the number 741 . The highest power of 2 less than (or equal to) 741 is
29 = 512. So we have

741 = 512 + 229


= 29 + 229

Now we need to work on 229. The highest power of 2 less than 229 is
27 = 1 28 . So we now have

741 = 512 + 128 + 101


= 2 9 + 2 7 + 101

The process continues with 101. The highest power of 2 less than 101
is 26 = 64. So we get

741 = 512 + 128 + 64 + 37


= 29 + 27 + 26 + 37

Next we can find that 37 is greater than 25 = 32, so

741 = 512 + 128 + 64 + 32 + 5


= 29 + 2 7 + 26 + 25 + 5

Working on the 5 we see that

741 = 512 + 128 + 64 + 32 + 4 + 1


= + 27 + 26 + 25 + 22 + 1
29
= 1011 100101

Below is 741 expressed as a 16 bit integer.

bit value Io I oI oI oIo I oI1 I oI1 I 1 I 1 I oIo I1 Io I 1 I


bit position 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
2.2. HEXADECIMAL NUMBERS 13

A binary constant can be represented in the yasm assembler by ap­


pending "b" to the end of a string of O's and 1 's. So we could represent
741 as 1 0 1 1 1001 01b.
An alternative method for converting a decimal number to binary is
by repeated division by 2. At each step, the remainder yields the next
higher bit.
Let 's convert 741 again.
division remainder bits
741/2 370 1 1
370/2 185 0 01
185/2 92 1 101
92/2 46 0 0101
46/2 23 0 00101
23/2 11 1 100101
11/2 5 1 1100101
5/2 2 1 11100101
2/2 1 0 011100101
1/2 0 1 1011100101

The repeated division algorithm is easier since you don't have to iden­
tify (guess? ) powers of 2 less than or equal to the number under question.
It is also easy to program.

2.2 Hexadecimal numbers


Binary numbers are a fairly effective way of representing a string of bits,
but they can get pretty tedious if the string is long. In a 64 bit computer
it is fairly common to work with 64 bit integers. Entering a number as
64 bits followed by a "b" would be tough. Decimal numbers are a much
more compact representation, but it is not immediately apparent what
bits are O's and 1 's in a decimal number. Enter hexadecimal. . .
A hexadecimal number is a number in base 16. So we need "digits"
from 0 to 15. The digits from 0-9 are just like in decimal. The digits
from 10-15 are represented by the letters 'A' through 'F'. We can also
use lower case letters. Fortunately both yasm and C/C++ represent hex­
adecimal numbers using the prefix Ox. You could probably use OX but
the lower case x tends to make the numbers more visually obvious.
14 CHAPTER 2. NUMBERS

Let's consider the value of Oxala. This number uses a which means
10, so we have

Oxal a = 10 * 162 + 1 * 1 6 + 10
= 10 * 256 + 16 + 10
= 2586

Converting a decimal number to hexadecimal follows a pattern like the


one used before for binary numbers except that we have to find the highest
power of 1 6 and divide by that number to get the correct "digit" . Let's
convert 40007 to hexadecimal. The first power of 16 to use is 163 = 4096.
40007/4096 9 with a remainder of 3143, so we have
=

40007 = 9 * 1 63 + 3 143

3143/162 = 3143/256 = 12 with a remainder of 71, so we get

40007 = 9 * 1 63 + 12 * 162 + 71

71/16 = 4 with a remainder of 7, so the final result is

40007 = 9 * 1 63 + 1 2 * 1 62 + 4 * 16 + 7 = Ox9c47

As with conversion to binary we can perform repeated division and


build the number by keeping the remainders.

division remainder hex


40007/ 1 6 2500 7 7
2500/ 1 6 1 56 4 47
1 56/ 1 6 9 12 c47
9/16 0 9 9c47

Converting back and forth between decimal and binary or decimal


and hexadecimal is a bit painful. Computers can do that quite handily,
but why would you want to convert from decimal to hexadecimal? If
you are entering a value in the assembler, simply enter it in the form
which matches your interpretation. If you're looking at the number 1027
and need to use it in your program, enter it as a decimal number. If you
want to represent some pattern of bits in the computer, then your choices
2.2. HEXADECIMAL NUMBERS 15

are binary and hexadecimal. Binary is pretty obvious t o use, but only
for fairly short binary strings. Hexadecimal is more practical for longer
binary strings.
The bottom line is conversion between binary and hexadecimal is
all that one normally needs to do. This task is made easier since each
hexadecimal "digit" represents exactly 4 bits (frequently referred to as
a "nibble" ) . Consult the table below to convert between binary and
hexadecimal.

Hex Binary
0 0000
1 0001
2 0010
3 001 1
4 0100
5 0101
6 0110
7 0111
8 1000
9 1001
a 1010
b 1011
c 1 100
d 1 101
e 1 1 10
f 1111

Let's now consider converting Ox1a5b t o binary. 1 = 000 1 , a = 1010,


5 = 0101 and b = 1 0 1 1 , so we get

Ox1a5b = 0001 1010 0 1 0 1 1 0 1 1 = 000 1 1 0 10010 1 10 1 1b

Below Ox1a5b is shown with each bit position labeled:

bit value lolololtltloltlololtloltl1lolt 1


bit position 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
16 CHAPTER 2. NUMBERS

2.3 Integers
On the x86-64 architecture integers can be 1 byte, 2 bytes, 4 bytes, or 8
bytes in length. Furthermore for each length the numbers can be either
signed or unsigned: Below is a table listing minimum and maximum
values for each type of integer.

Variety Bits Bytes Minimum Maximum


unsigned 8 1 0 255
signed 8 1 -128 127
unsigned 16 2 0 65535
signed 16 2 -32768 32767
unsigned 32 4 0 4294967295
signed 32 4 -2147483648 2147483647
unsigned 64 8 0 1 8446744073709551615
signed 64 8 -9223372036854775808 9223372036854775807

The range of 64 bit integers is large enough for most needs. Of course
there are exceptions, like 20! 51090942171 709440000.
=

Unsigned integers are precisely the binary numbers discussed earlier.


Signed integers are stored in a useful format called "two's complement" .
The first bit of a signed integer is the sign bit. If the sign bit is 0, the
number is positive. If the sign bit is 1 , the number is negative. The most
obvious way to store negative numbers would be to use the remaining
bits to store the absolute value of the number.

31 0
sign bit value

Let's consider 8 bit signed integers and what we would get if we used
the existing circuitry to add 2 such integers. Let's add -1 and 1 . Well, if
we store -1 with a sign bit and then the value we would get
-1 = 1000 000 1
1 = 00, 0 0 000 1

-1+1 = 1000 0002


2.3. INTEGERS 17

Oops! We end up with -2 rather than 0.


Let's try storing 8 bit numbers as a sign bit and invert the bits for
the absolute value part of the number:
-1 = 1111 1110
1 = 0000 0001

-1+1 = 1111 1111


Now this is interesting: the result is actually -0, rather than 0. This
sounds somewhat hopeful. Let's try a different pair of numbers:
-1 = 1 1 1 1 1 1 10
4 = 0000 0 100

-1+4 = 0000 0010 = 2


Too bad! It was close. What we need it to add one to the complemented
absolute value for the number. This is referred to as "two's complement"
arithmetic. It works out well using the same circuitry as for unsigned
numbers and is mainly a matter of interpretation.
So let 's convert -1 to its two's complement format .
-1 1 for the sign bit
000000 1 for the absolute value
1 1 1 1 1 10 for the complement
1 1 1 1 1 1 1 after adding 1 to the complement
-1 = 1 1 1 1 1 1 1 1 after prefixing the sign bit
Using two's complement numbers the largest negative 8 bit integer is
1 0000000. To convert this back, complement the rightmost 7 bits and add
1 . This gives 1 1 1 1 1 1 1 + 1 = 1 0000000 = 128 , so 10000000 = -128.
You may have noticed in the table of minimum and maximums that the
minimum values were all 1 larger in absolute value than the maximums.
This is due to complementing and adding 1. The complement yields a
string of 1 's and adding 1 to that yields a single 1 with a bunch of O's.
The result is that the largest value for ann-bit signed integer is 2 n- l - 1
and the smallest value is - 2n-l .
Now let's convert the number -750 to a signed binary number.
750 = 512 + 128 + 64 + 32 + 8 + 4 + 2 = 101 1 1 0 1 1 1 0b
18 CHAPTER 2. NUMBERS

Now expressing this as a 15 bit binary number (with spaces to help keep
track of the bits) we get 000 0010 1 1 10 1 1 10. Next we invert the bits to
get 1 1 1 1 1 0 1 000 1 000 1 . Finally we add 1 and prefix the number with
the sign bit to get -750 = 1 1 1 1 1 10 1 0001 0010 = OxFD12.
Next let's convert the hexadecimal value OxFA13 from a 16 bit signed
integer to a decimal value. Start by converting the rightmost 15 bits
to binary: 1 11 1010 0001 001 1. Then invert the bits: 000 0 1 0 1 1 1 10
1 100. Add 1 to get the 2's complement : 000 0101 1 1 10 1 1 0 1 . Convert
this to decimal 1 024 + 256 + 128 + 64 + 32 + 8 + 4 + 1 = 1517, so OxFA13
= -15 17.
Let's add -750 and -1517 in binary:
1 1 1 1 1 1 0 1 0001 0010
1 1 1 1 1010 0001 001 1

1 1 1 1 1 0 1 1 1 0010 0101

We can ignore the leading 1 bit (a result of a carry ) . The 16 bit sum
is 1 1 1 1 0 1 1 1 00 10 0101, which is negative. Inverting the lower-most 1 5
bits: 0000 1 000 1 101 1010. Next adding 1 to get the two's complement:
0000 1000 1 101 1 0 1 1 . So the number is 2048+ 128 + 64 + 1 6 + 8 + 2 + 1 =
2267. So we have -750 + -1 517 = -2267.

2.3.1 Binary addition

Performing binary addition is a lot like decimal addition. Let 's add 2
binary numbers

1 0 10 1 1 1 1
+ 1 10 1 00 1 0
1

The first pair of bits was easy. Adding the second pair of bits gives a
value of 2, but 2 = 10b, so we place a 0 on the bottom and carry a 1

1
1000 1 1 1 1
+ 0101 1010
01
2. 3. INTEGERS 19

We continue in the same way:


1
1000 1 1 1 1
+ 0101 1 0 1 0
001

1
1000 1 1 1 1
+ 01011010
1001

1
1000 1 1 1 1
+ 0101 1010
01001

1000 1 1 1 1
+ 0101 1 0 1 0
1 1 10 1001

2.3.2 Binary multiplication

Binary multiplication is also much like decimal multiplication. You mul­


tiply one bit at a time of the second number by the top number and write
these products down staggered to the left . Of course these "products"
are trivial. You are multiplying by either 0 or 1. In the case of 0, you
just skip it. For 1 bits, you simply copy the top number in the correct
columns.
After copying the top number enough times, you add all the partial
products. Here is an example:
1010101
*
10101
1010101
1010101
1010101
1 10 1 1 1 1 1001
20 CHAPTER 2. NUMBERS

2.4 Floating point numbers


The x86-64 architecture supports 3 different varieties of floating point
numbers: 32 bit, 64 bit and 80 bit numbers. These numbers are stored in
IEEE 754 format . Below are the pertinent characteristics of these types:

Variety Bits Exponent Exponent Bias Fraction Precision


float 32 8 127 23 "'7 digits
double 64 11 1023 52 "'1 6 digits
long double 80 15 1 6383 64 19 digits

The IEEE format treats these different length numbers in the same
way, but with different lengths for the fields. In each format the highest
order bit is the sign bit. A negative number has its sign bit set to 1 and
the remaining bits are just like the corresponding positive number. Each
number has a binary exponent and a fraction. We will focus on the float
type to reduce the number of bits involved.

31 30 23 22 0
sign bit exponent value

The exponent for a float is an 8 bit field. To allow large numbers or


small numbers to be stored, the exponent is interpreted as positive or
negative. The actual exponent is the value of the 8 bit field minus 127.
127 is the "exponent bias" for 32 bit floating point numbers.
The fraction field of a float holds a small surprise. Since 0.0 is defined
as all bits set to 0, there is no need to worry about representing 0.0 as
an exponent field equal to 127 and fraction field set to all O's. All other
numbers have at least one 1 bit, so the IEEE 754 format uses an implicit 1
bit to save space. So if the fraction field is 00000000000000000000000, it
is interpreted as 1 . 00000000000000000000000. This allows the fraction
field to be effectively 24 bits. This is a clever trick made possible by
making exponent fields of OxOO and OxFF special.
A number with exponent field equal to OxOO is defined to be 0. In­
terestingly, it is possible to store a negative 0. An exponent of OxFF is
used to mean either negative or positive infinity. There are more details
2. 4. FLOATING POINT NUMBERS 21

required for a complete description of IEEE 754, but this is sufficient for
our needs.
To illustrate floating point data, consider the following assembly file

segment . data
zero dd 0.0
one dd 1.0
neg! dd -1 . 0
a dd 1 . 75
b dd 1 22 . 5
d dd 1.1
e dd 10000000000 . 0

This is not a program, it is simply a definition of 7 f loat values in the


. data segment. The dd command specifies a double word data item.
Other options include db ( data byte ) , dw (data word) and dq (data quad­
word ) . A word is 2 bytes, a double word is 4 bytes and a quad-word is 8
bytes.
Now consider the listing file produced by yasm

1 %line 1+1 fp . asm


2 [sect ion . data]
3 00000000 00000000 zero dd 0 . 0
4 00000004 0000803F one dd 1 . 0
5 00000008 000080BF neg1 dd - 1 . 0
6 OOOOOOOC OOOOE03F a dd 1 . 75
7 000000 10 OOOOF542 b dd 122 . 5
8 000000 14 CDCC8C3F d dd 1 . 1
9 000000 18 F9021550 e dd 10000000000 . 0

The zero variable is stored as expected - all 0 bits. The other numbers
might be a little surprising. Look at one - the bytes are backwards!
Reverse them and you get 3F800000. The most significant byte is 3F.
The sign bit is 0. The exponent field consists of the other 7 bits of
the most significant byte and the first bit of the next byte. This means
that the exponent field is 127 and the actual binary exponent is 0. The
remaining bits are the binary fraction field - all O's. Thus the value is
1.0 * 2° 1 .0.
=
22 CHAPTER 2. NUMBERS

There is only 1 negative value shown: -1 .0. It differs in only the sign
bit from 1 .0.
You will notice that 1 .75 and 122.5 have a significant number of O's
in the fraction field. This is because . 75 and .5 are both expressible as
sums of negative powers of 2.

0.75 = 0.5 + 0 .2 5 = 2-l + 2-2

On the other hand 1 . 1 is a repeating sequence of bits when expressed in


binary. This is somewhat similar to expressing 1/1 1 in decimal:

1/11 = 0.090909 . . .

Looking at 1 . 1 in the proper order 1 . 1 Ox3F8CCCCD. The exponent is


==

0 and the fraction field in binary is 000 1 1001 1001 1001 1001 10 1 . It looks
like the last bit has been rounded up and that the repeated pattern is
1 100.
1 . 1 10 1 .0001 100 1 10011001 1001100 . . '2
=

Having seen that floating point numbers are backwards, then you
might suspect that integers are backwards also. This is indeed true.
Consider the following code which defines some 32 bit integers
segment data
zero dd 0
one dd 1
neg1 dd -1
a dd 175
b dd 4097
d dd 65536
e dd 100000000
The associated listing file shows the bits generated for each number .
The bytes are backwards. Notice that 4097 is represented as Ox0 1 100000
in memory. The first byte is the least significant byte. We would prefer
to consider this as Ox0000 1001, but the CPU stores least significant byte
first.

1 %line 1+1 int . asm


2 [sect i on . data]
2.4. FLOATING POINT NUMBERS 23

3 00000000 00000000 zero dd 0


4 00000004 0 1000000 one dd 1
5 00000008 FFFFFFFF neg1 dd -1
6 OOOOOOOC AFOOOOOO a dd 175
7 00000010 0 1 100000 b dd 4097
8 00000014 00000 100 d dd 65536
9 00000018 OOE1F505 e dd 100000000

2 .4 . 1 Converting decimal numb ers t o floats

Let's work on an example to see how to do the conversion. Let 's convert
-121 .6875 to decimal.
First let's note that the sign bit is 1 . Now we will work on 121 .6875.
It's fairly easy to convert the integer portion of the number: 121 =

1 1 1 1 001b. Now we need to work on the fraction.


Let 's suppose we have a binary fraction x = 0 . abcdefgh, where the
letters indicate either a 0 or a 1 . Then 2*x a . bcdefgh. This indicates
=
·

that multiplying a fraction by 2 will expose a bit.


We have 2 x 0.6875 1 .375 so the first bit to the right of the binary
=

point is 1 . So far our number is 1 1 1 100 1 . 1b.


Next multiply the next fraction: 2 x 0.375 0.75 , so the next bit is
=

0. We have 1 1 1 1001 . 1 0b
Multiplying again: 2 x 0.75 1 . 5, so the next bit is 1 . We now have
=

1 1 1 1001 . 101b .
Multiplying again: 2 x 0 . 5 = 1 , so the last bit is ! leaving 1 1 1 1001 . 1 0 1 1b
So our number -121 .6875 - 1 1 1 1 001 . 1 0 1 1b . We need to get this
=

into exponential notation with a power of 2.

- 12 1 .6875 = - 1 1 1 1001 . 101 1


= - 1 . 1 1 10011011 * 26

We now have all the pieces. The sign bit is 1 , the fraction (without
the implied 1 ) is 1 1 100 1 1 0 1 10000000000000 and the exponent field is
127+6 133 10000 101. So our number is
= =

1 100001 0 1 1 1 1001 1 0 1 1 0000000000000.


Organized into nibbles, this is 1 100 0010 1 1 1 1 00 1 1 0 1 1 0 0000 0000
24 CHAPTER 2. NUMBERS

0000 or Oxc2f36000. Of course if you see this in a listing it will be


reversed: . 0060f3c2.

2 .4. 2 Converting floats to decimal

An example will illustrate how to convert a float to a decimal number.


Let 's work on the float value Ox43263000.
The sign bit is 0, so the number is positive. The exponent field is
010000 1 1 0 which is 134, so the binary exponent is 7. The fraction field
is 010 0 1 10 001 1 0000 0000 0000 0000, so the fraction with implied 1
is 1 . 0100 1 1000 1 1 .

1 .01001 1000 1 1 2 * 27 = 101001 10.00 1 1 2


= 166 + 2- 3 + 2- 4
= 166 + 0. 125 + 0.0625
= 166.1875

2.4.3 Floating point addition

In order to add two floating point numbers, we must first convert the
numbers to binary real numbers. Then we need to align the binary points
and add the numbers. Finally we need to convert back to floating point .
Let's add the numbers 41.275 and 0.315. In hexadecimal these num­
bers are Ox4225 199a and Ox3ea147ae . Now let 's convert Ox42251 99a to
a binary number with a binary exponent. The exponent field is com­
posed of the first two nibbles and a 0 bit from the next nibble. This is
10000 1 002 132, so the exponent is 132 - 127 5. The fractional part
= =

with the understood 1 bit is

1 .01001010001 1001 1001 10102

So we have

Ox4225 199a = 1 .01001010001 1001100110102 * 25


= 101001 .010001 1001 1001 10102
2.4. FLOATING POINT NUMBERS 25

Similarly Ox3ea147ae has an exponent field of the first 2 nibbles and


a 1 from the third nibble. So the exponent field is 0 1 1 1 1 1 012 = 125
yielding an exponent of -2. The fractional part with the understood 1 bit
IS

1.010000101000111101011102

So we have
2
Ox3ea147ae = 1.010000101000111101011102 * 2-
= 0.01010000101000111101011102

Now we can align the numbers and add


1 0 1 00 1 . 0 1 0 00 1 100 1 10 0 1 1 0 10
+ 0 . 0 1 0 1 0000 1 0 1 00 0 1 1 1 10 1 0 1 1 1 0
1 0 1 00 1 . 1 0 0 10 1 1 10 000 1 0 100 1 0 1 0 1 1 1 0
Now we have too many bits to store in a 32 bit float . The rightmost
7 bits will be rounded (dropped in this case) to get
1 0 1 0 0 1. 1 00 1 0 1 1 10000 1 0 1 0 0 1 2

= 1. 0 1 00 1 10 0 1 0 1 1 10000 1 0 1 0 0 1 2 * 25
So the exponent is 5 and the exponent field is again 132. Dropping
the leading 0, we get Ox42265c29 which is 41.59 (approximately) .
You should be able to see that we lost some bits of precision on the
smaller number. In an extreme case we could try to add 1.0 to a number
like 1038 and have no effect.

2.4.4 Floating point multiplication

Floating point multiplication can be performed in binary much like dec­


imal multiplication. Let's skip the floating point to/from binary conver­
sion and just focus on the multiplication of 7. 5 and 4.375.
7.5 1 1 1.12
*
4.375 100. 0 1 1 2
1 1 1 12
1 1 1 102
1 1 1 1 000002
100000. 1 10 1 2
26 CHAPTER 2. NUMBERS

Exercises

1 . Convert the following integers to binary.


a. 37 c. -65
b. 350 d. -427
2. Convert the following 16 bit signed integers to decimal.
a. 000000 1010101 0 1 0b c. Ox0 101
b. 1 1 1 1 1 1 1 1 1 1 101 101b d. Oxffcc
3 . Convert the following 16 bit unsigned integers to binary.
a. Ox0 15a c. Ox0 101
b. Oxfedc d. Oxacdc
4 . Convert the following numbers to 32 bit floating point.
a. 1 .375 c. -571 .3125
b. 0.041 015625 d. 409 1 . 125
5 . Convert the following numbers from 32 bit floating point to decimal.
a. Ox3F82000 c. Ox4F84000
b. OxBF82000 d. Ox3C86000
6. Perform the binary addition of 2 unsigned integers below. Show
each carry as a 1 above the proper position.

000 100101 100 1 0 1 1


+1 1 1 0 1 10 1 1 1 1 0 1 0 1 1

7. Perform the binary multiplication of the following unsigned binary


numbers. Show each row where a 1 is multiplied times the top
number. You may omit rows where a 0 is multiplied times the top
number.

101 100 1 0 1 1
* 1 1 0 1 101

8. Write an assembly "program" (data only ) defining data values using


dw and dd for all the numbers in exercises 1-4.
Chapter 3

Computer rnernory

In this chapter we will discuss how a modern computer performs memory


mapping to give each process a protected address space and how the
Linux system manages the memory for a process. A practical benefit
of this chapter is a discussion of how to examine memory using the gdb
debugger.

3.1 Memory mapping


The memory of a computer can be considered an array of bytes. Each
byte of memory has an address. The first byte is at address 0, the second
byte at address 1 , and so on until the last byte of the computer's memory.
In modern CPUs there are hardware mapping registers which are used
to give each process a protected address space. This means that multiple
people can each run a program which starts at address Ox4004c8 at the
same time. These processes perceive the same "logical" addresses, while
they are using memory at different "physical" addresses.
The hardware mapping registers on an x86-64 CPU can map pages of
2 different sizes - 4096 bytes and 2 megabytes. Linux uses 2 MB pages
for the kernel and 4 KB pages for most other uses. In some of the more
recent CPUs there is also support for 1 GB pages.
The operation of the memory system is to translate the upper bits of
the address -from a process's logical address to a physical address. Let's
consider only 4 KB pages. Then an address is translated based on the

27
28 CHAPTER 3. COMPUTER MEMORY

page number and the address within the page. Suppose a reference is
made to logical address Ox4000002220. Since 4096 = 2 12 , the offset
within the page is the right-most 1 2 bits (Ox220) . The page number
is the rest of the bits (Oc=x4000002). A hardware register (or multiple
registers) translates this page number to a physical page address, let's say
Ox780000000. Then the two addresses are combined to get the physical
address Ox780000220.
Amazingly the CPU generally performs the translations without slow­
'
ing down and this benefits the users in several ways. The most obvious
benefit is memory protection. User processes are limited to reading and
writing only their own pages. This means that the operating system is
protected from malicious or poorly coded user programs. Also each user
process is protected from other user processes. In addition to protection
from writing, users can't read other users' data.
There are instructions used by the operating system to manage the
hardware mapping registers. These instructions are not discussed in this
book. Our focus is on programming user processes.
So why bother to discuss paging, if we are not discussing the instruc­
tions to manage paging? Primarily this improves one's understanding
of the computer. When you write software which accesses data beyond
the end of an array, you sometimes get a segmentation fault . However
you only get a segmentation fault when your logic:al address reaches far
enough past the end of the array to cause the CPU to reference a page
table entry which is not mapped into your process.

3.2 Process memory model in Linux


In Linux memory for a process is divided into 4 logical regions: text ,
data, heap and stack. The stack is mapped to the highest address of a
process and on x86-64 Linux this is Ox7fffffffffff or 131 TB. This
address is selected based on the maximum number of bits allowed in
logical addresses being 48 bits. This address is 4 7 bits of all 1 bits. The
decision was made to not use bit 48, since canonical addresses have to
extend bit 48 through bits 49-63.
In figure 3.1 we see the arrangement of the various memory segments.
At the lowest address we have the text segment ( . text for yasm) . This
segment is shown starting at 0, though both _start and main are at
3.2. PROCESS MEMORY MODEL IN LINUX 29

higher addresses. It appears that the lowest ad­ 1 3 1TB


dress in an x86-64 process is Ox400000. The text
segment does not typically need to grow, so the
data segment is placed immediately above the text
segment. Above these two segments are the heap
and stack segments.
The data segment starts with the . data seg­
ment which contains initialized data. Above that is
the . bss segment which stands for "block started
by symbol" . The . bss segment contains data which data

is statically allocated in a process, but is not stored


in the executable file. Instead this data is allocated
when the process is loaded into memory. The initial 0
contents of the . bss segment are all 0 bits.
The heap is not really a heap in the sense dis- Figure 3.1: Process
cussed in a data structures course. Instead is a dy- memory layout
namically resizable region of memory which is used
to allocate memory to a process through functions like malloc in C and
the new operator in C++. In x86-64 Linux this region can grow to very
large sizes. The limit is imposed by the sum of physical memory and
swap space.
The final segment of a process is the stack segment. This segment is
restricted in size by the Linux kernel, typically to 16 megabytes. This is
not a large amount of space, but as long as the programmer avoids putting
large arrays on the stack it serves the purpose quite well of managing the
run-time stack keeping track of function calls, parameters, local variables
and return addresses.
Given the top of the stack as Ox7fffffffffff and the stack size
limited to 1 6 megabytes we see that the lowest valid stack address is
Ox7fffff000000. The stack automatically grows when needed by the
operating system responding to a page fault . The operating system rec­
ognizes the faulting address as being in the range from Ox7fffff000000
to Ox7fffffffffff, which is only used for the stack and allocates a new
page of memory (4096 bytes) to the process.
This simple memory layout is not entirely accurate. There are shared
object files which can be mapped into a process after the program is
loaded which will result in regions in the heap range being used to to
30 CHAPTER 3. COMPUTER MEMORY

store instructions and data. This region is also used for mapping shared
memory regions into a process.
If you wish to examine the memory used by one of your processes,
you can execute "cat /proc/999/maps" where 999 needs to be replaced
by your process id. To see the memory used by your shell process, enter

cat /proc/$$/maps

3.3 Memory example


Here is a sample assembly program with several memory items defined:

segment . data
a dd 4
b dd 4.4
c t imes 10 dd 0
d dw 1' 2
e db Oxfb
f db "hello world" , 0

segment . bs s
g resd 1
h resd 10
i resb 100

segment . text
global main l et the linker know about main
main :
push rbp set up a stack frame for main
mov rbp , rsp set rbp to po int to the stack fram·
sub rsp , 1 6 leave some room for local variable�
leave rsp on a 16 byte boundary
xor eax , eax set rax to 0 for return value
leave undo the stack frame manipul ations
ret

After assembling the program we get the following listing file:


3. 3. MEMORY EXAMPLE 31

1 %l ine 1+1 memory . asm


2 [sect ion . data]
3 00000000 04000000 a dd 4
4 00000004 CDCC8C40 b dd 4 . 4
5 00000008 OOOOOOOO<rept> c t imes 10 dd 0
6 00000030 01000200 d dw 1 , 2
7 00000034 FB e db Oxfb
8 00000035 68656C6C6F20776F72- f db "hello world" , 0
9 00000035 6C6400
10
11 [section . bss]
12 00000000 <gap> g resd 1
13 00000004 <gap> h resd 10
14 0000002C <gap> i resb 100
15
16 [sect ion . text]
17 [global main]
18 mai n :
19 00000000 55 push rbp
20 0000000 1 4889E5 mov rbp , rsp
21 00000004 4883EC10 sub rsp , 1 6
22 00000008 31CO xor eax , eax
23 OOOOOOOA C9 leave
24 OOOOOOOB C3 ret
You can see from the listing the relative addresses of the defined data
elements. In the data section we have a double word (4 bytes) named a
at location 0. Notice that the bytes of a are reversed compared to what
you might prefer.
Following a is a double word defined as a floating point value named
b at relative address 4. The bytes for b are also reversed. Consider it as
Ox408ccccd. Then the sign bit is 0, the exponent field is the rightmost
7 bits of the "first" byte, Ox40, with the leftmost bit of the next byte,
Ox8 c. So the exponent field is Ox81 = 129, which is a binary exponent of
2. The fraction field ( with the implied initial 1 bit ) is Ox8cc ccd. So b
=

1 . 000 1100 1 1001 1001 1001 101 * 2 2 4.4.


=

The next data item is the array c defined with the times pseudo-op
which has 1 0 double word locations. The relative location for c is 8 and
32 CHAPTER 3. COMPUTER MEMORY

c consists of 40 bytes, so the next item after c is at relative address 48 or


Ox30.
Following c is the length 2 array d with values 1 and 2. Array d is of
type word so each value is 2 bytes. Again you can see that the bytes are
reversed for each word of d.
The next data item is the byte variable e with initial value Oxfb.
After e is the byte array f which is initialized with a string. Notice that
I have added a terminal null byte explicitly to f . Strings in yasm do not
end in null bytes.
After the data segment I have included a bss segment with 3 variables.
These are listed with their relative addresses as part of the bss segment .
After linking the bss data items will be loaded into memory beginning
with g defined by resd op-code which means "reserve" double word. With
resd the number 1 means 1 double word. The next bss item is h which has
10 reserved double words. The last bss item is i which has 100 reserved
bytes. All these data items are shown in the listing with addresses relative
to the start of the bss segment. They will all have value 0 when the
program starts.

3.4 Examining memory with gdb

In this section we will focus on using the gdb print (p) and examine ( x)
commands. Print is a simple command which can print some data values
and is versatile enough to print various forms of C expressions. Examine
is strictly for printing data from memory and is quite useful for printing
arrays of various types.

3 .4 . 1 P rinting with gdb

The format for the p command is either p expression or p/FMT expre ssion
where FMT is a single letter defining the format of data to print . The for­
mat choices are
3. 4. EXAMINING MEMORY WITH GDB 33

letter format
d decimal (default)
X hexadecimal
t binary
u unsigned
f floating point
1 instruction
c character
s string
a address
Let's see a few commands in action in gdb:
(gdb) p a
$32 = 4
(gdb) p/a &a
$33 = Ox601018 <a>
(gdb) p b
$34 = 1082969293
(gdb) p/f b
$35 = 4 . 400000 1
(gdb) p/a &b
$36 = Ox60101c <b>
(gdb) p/x &b
$37 = Ox60101c
(gdb) p/a &c
$39 = Ox601 020 <c>
(gdb) p/a &d
$40 = Ox601 048 <d>
(gdb) p/a &e
$41 = Ox60 1 04c <e>
(gdb) p/a &f
$42 = Ox601 04d <f>
(gdb) p/a &g
$43 = Ox601070 <g>
(gdb) p/a &h
$45 = Ox601074 <h>
(gdb) p/a &i
34 CHAPTER 3. COMPUTER MEMORY

$46 = Ox60109c <i>

We see that gdb handles a perfectly. It gets the type right and the
length. It needs the If option to print b correctly. Notice that a is
located at address Ox60 1018 which is 24 bytes after the start of a page
in memory. gdb will prohibit accessing memory before a, though there is
no hardware restriction to the previous 24 bytes. We see that the data
segment variables are placed in memory one after another until f which
starts at Ox60104d and extends to Oc601058. There is a gap until the bss
segment which starts with g at address Ox60 1070. The bss data items
are placed back to back in memory with no gaps.

3.4.2 Examining memory

Notice that there are no length specifiers with p. If you want to print
doubles in memory it could be done with some mental gymnastics with
p. The examine command handles this job readily.
The format for examine is x/NFS address where N is a number of
items to print (default 1 ) , F is a single letter format as used in the print
command and S is the size of each memory location. Unfortunately gdb
picked some size letters which conflict with some of the size options in
yasm. Here are the size options:

letter SIZe bytes


b byte 1
h halfword 2
w word 4
g giant 8
Here are some examples of examining memory:

(gdb) x/w &a


Ox601018 <a> : Ox4
(gdb) x/fw &b
Ox60101c <b> : 4 . 4000001
(gdb) x/fg &b
Ox60 101c <b> : 5 . 3505792317228316e-315
(gdb) x/10dw &c
Another Random Document on
Scribd Without Any Related Topics
Sometimes I stop in the middle of something as if her hand were on
my shoulder. Your sister can come next week, then?”

“As far as I know; she’ll be ten times better help than Judith; she’s
strong and used to sickness. She can lift Rody, and that’s what you
want. I thought the parsonage folks had spoilt Judith for you by
making her too much of a lady.”

“Judith is not spoiled,” was the quiet rejoinder.

“You will find my sister Sarah ready for any emergency. What do you
think she’s been doing to get into the paper? She sent me the paper
with the thing marked in it. I wish I had brought the paper; I’ll show
it to you some time. You know she lives, when she’s at home, near a
tunnel; well that tunnel caved in one day just after a passenger train
had passed through; she knew there would be another train soon,
and she had her red petticoat ready and ran out as it came
thundering on, and swung it in the air until she stopped the train—
and just within a few feet of the tunnel, too. Wasn’t that pluck?”

“Where’s Judith?” called Joe’s voice. “I have a letter for her; one of
the foreign letters she used to be so raving glad to get.”

In the half light Judith sprang toward the letter. There was no light
in the sitting-room; on the kitchen table a lamp was burning; she
was glad to read it unquestioned. Snatching at its meaning she ran
through the three thin sheets; then she read it deliberately,
understandingly.

He had written to tell her of his marriage, and two weeks afterward,
on his wedding tour, found the unmailed letter in his pocket. That
letter he had destroyed, and, after a week to plan and decide what
to propose to her, had written again—was writing again now, in fact.
The shortest way to her forgiveness he believed to be to ask her to
come to England, not to be his housekeeper, but to be his wife’s
dear little friend and cousin, as well as his own. But, if she decided
not to do that, and the plan did have its disadvantages (he had not
yet asked his wife’s advice or consent), would she be happy to stay
on at the parsonage, or at Aunt Affy’s just as usual? He would never
forget her, she would always be his dearest little cousin in the world,
and he knew she and Florence would be the best of friends if they
could know each other. Florence had a prejudice against America,
but that would wear off. He very much regretted he had never
written about Florence, but she was something of a flirt and had
never allowed him to be sure of her until she knew he had taken
passage for America. He hoped she would write to Florence and
then they would understand each other better. She must be sure to
write to him by return mail. He hoped the delayed letter had not
made her uncomfortable. He was always her devoted Cousin Don.

Mrs. Evans went home, passing through the kitchen; Aunt Affy had
told her of the unexpected marriage of Judith’s cousin; she was
curious to catch a glimpse of the girl’s face over his letter. It would
be something to tell Nettie. With her usual thoughtfulness Aunt Affy
asked no question concerning the letter. That night Judith could not
bring herself to show the letter; the next morning she gave it to her
to read, and then asked if she might be spared to go to the
parsonage.

“Yes, dear child. And stay all day if you like. I’ll do for Rody. She will
not ask for you. She called me Becky in the night. It’s the first time
she has not recognized me. And when Mrs. Evans’s sister, Mrs.
Treadwell comes, you may go and have a long rest and study again.”

“I don’t deserve that,” said Judith, breaking into sobs; “I haven’t


been good, and I don’t deserve anything.”

“No matter, you’ll get it just the same,” said Aunt Affy, patting her
shoulder with a loving touch. “And, after this, you are to come to me
for money—you are to be my own child; my little girl, and Cephas’
little girl.”
With her head on Aunt Affy’s shoulder Judith laughed and cried; she
even began to feel glad of something—not that Don was married, or
that she was not to be his housekeeper, or that she was not to be
Aunt Rody’s nurse; it was almost wrong to be glad when she should
be disappointed; then she knew she was glad because no one in all
the world had the right to take her away from the parsonage.

The way of obedience had been easier than she thought. She stayed
that day with Aunt Rody, doing little last things for her, and telling
Aunt Affy ways of nursing that pleased Aunt Rody that she had
discovered for herself.

“She will miss you,” Aunt Affy said that evening, as Judith came into
the sitting-room dressed for her walk. Doodles was snoring upon his
cushion on the lounge; Uncle Cephas, at the round table, was lost in
the day’s paper; Joe, at another table, was reading a book he had
found under rubbish in the storeroom: this last year he had
developed a taste for books.

The girl lingered, with her satchel in her hand; the dear old home
was a hard place to leave; without the cloud of Aunt Rody’s
presence it was peace and sunshine.

Aunt Affy, with her pretty, gray head, her light step, her words of
comfort and courage, moved about like a benediction; Uncle Cephas,
rough and kindly, with strength in reserve for every emergency,
gave, to the house the headship it had always lacked; Joe, to-night,
was fine and sturdy, and growing into somebody; would they miss
her?

Was the girl going away any real part of the strength and beauty of
the old Sparrow place?

She was going because she chose to go.

Joe had asked her if she were “going for good.” Was to-night
another turning-point?
If she stayed would her life to come be any different?

In anybody’s eyes was there a difference between belonging to the


parsonage and belonging to the Sparrow place?

No one was taking her away, she was going of her own free will.

With a sudden impulse she dropped her satchel in Aunt Rody’s


empty chair and ran up the kitchen stairs to stay a few moments
alone in the chamber her mother used to have when she was a little
girl.
XXVII. HIS VERY BEST.

“Lord, teach us to pray.”

—Luke xi. 1.
“O Thou, by whom we come to God,
The Life, the Truth, the Way!
The path of prayer Thyself hast trod;
Lord, teach me to pray.”

Judith stood on the parsonage piazza; a voice within was unfamiliar,


then in a change of tone she recognized something and was
reminded of her afternoon at Meadow Centre; that laugh she had
heard before, it was not Don—it was—the face at the window looked
out into the shadows,—it was Richard King. He was a strong tower;
he was safe, like her parsonage life; she would go in and feel at
home. No new face or voice would ever come between and keep her
away. Across the room, as she discovered by a peep through the
curtains, Marion sat with some of her usual pretty work in her hand;
Roger was not there.

“In the excavations in Babylon,” Mr. King went on in easy


continuation of the subject in hand, “a collection of bowls was found,
inscribed with adjurations of all sorts of spirits by name, and with
indications that could not be mistaken of medicines they once held.
You know, that capital R with which the physician heads his
prescription, believing it stands for Recipe, in the days of superstition
was understood to be an appeal to Jupiter.”
“That was consistent,” Marion replied, still bending over her work.

“Imagine our physicians writing at the head of a prescription: In the


name of Jesus Christ.”

“As Peter did when he healed the lame man.”

“Our old Meadow Brook physician prays with his patients very often;
I tell him he leaves nothing for the parson to do.”

“Roger says sometimes the doctor has a way of getting nearer our
Bensalem people than he has.”

“I am not sure of that. They tell the doctor a different kind of


trouble. You would be amazed—if you were not the minister’s sister
—at the histories people tell me about themselves, and their
neighbors.”

“I am always delighted that people have a story to tell. When I first


came to Bensalem I thought no man, woman, or child, lived a life
worth living. Now I know the sweetest stories. Aunt Affy is one, and
Nettie Evans, and even her hard-featured mother brims over once in
a while with an experience.”

The coming back from Babylon to Bensalem brought Judith to the


consciousness that she might be considered an eavesdropper; at
that instant Roger entered in his shirt-sleeves, remarking: “Let’s be
informal, like Wordsworth. He used to take out his teeth evenings
when he did not expect callers.”

“But you have a caller,” remonstrated Marion, when the laughter


ceased.

“Yes, and here’s another one,” Roger replied, as Judith walked softly
in. “Judith, must I put on my coat? I’ve been potting plants for
Marion and I couldn’t afford to soil my coat.”
“Yes,” said Judith, who was always on Marion’s side in influencing
the Bensalem minister to remember the claims of society.

“I wish you had stayed at home. What are you looking so full of
news about?”

“I have come back—to stay. No one else in the world wants me.”

“And we don’t,” declared Roger.

Something in the gleam of the eyes under Richard King’s tangled


eyebrows was a revelation to Marion. She knew his secret. She
would keep it. Roger was stupid, he would never guess. But how
could she keep it from Judith? Poor little Judith, was she growing up
to have a love story? To-night Marion did not like love stories.

She wished the tall girl with the serious eyes and braided hair were a
little girl with long curls.

“Did you get a letter from Don to-night?” Roger asked.

“Yes.”

“How do you like it?”

“I—think I like it. It will not make any difference to me—only the
difference that it hasn’t made.”

“A good distinction,” remarked Richard King.

“May I go upstairs, Marion?”

“Surely—your room has been waiting for you as the Holy Land
waited for the Israelites to return from their captivity; nobody
spoiled either, or occupied either.”

“Mine was not seventy years,” said Judith, “although sometimes it


seemed like it.”
Marion did not follow her; it would not be an easy thing to talk to
Judith about Don’s marriage; she was relieved that the only view the
girl would take of it would be in regard to the difference it made to
herself.

When Judith returned, feeling as much at home as though she had


been away but for a night, Marion was matching silks for her work,
and the gentlemen were talking, sitting opposite each other in the
bay window.

It had been so long since she had heard Roger talk; that “talk” was
one of the delights of her parsonage life. She had heard him preach
but once during her stay at Aunt Affy’s.

“That point about praying came up,” Mr. King was saying, “and I am
not satisfied with the answer I gave. The man gave his experience—
it was an experience of years—and then he asked me what was the
matter with his prayer, and I decidedly did not know. I know he has
fulfilled the conditions, praying in faith, and in the name of Christ,
and the thing prayed for was innocent in itself. He said, ‘What is the
matter with me?’ and I could not tell. He went away unsatisfied. I
went down on my knees, you may be sure, thinking something was
the matter with me because I had no illumination for him.”

Roger’s strong, brown hand was stretched along the arm of his
chair; he looked down at his fingers in deep thought.

“He said he had been praying months to learn if the petition in itself
were not acceptable to God, and had, he thought, studied a hundred
prayers in the Bible, comparing his prayer with the acceptable and
unacceptable prayers of the old saints.”

“He is determined to get at the bottom of it,” said Roger.

“I never saw a man more determined. I quoted Phillips Brooks to


him: ‘You have not got your answer, but you have got God.’”
“He was not satisfied with that getting?”

“No. He said he knew he should not be satisfied until he had God’s


answer to himself. I think he has almost lost sight of the thing he
was anxious for when he began to pray. It has been worth a course
in theology to him.”

Marion dropped her silks; Judith was listening with all the eagerness
of her childhood. She felt sure Aunt Affy could explain the difficulty.

“The thing that strikes me,” began Roger, “is that he may be like
those men sent to the house of God to inquire about fasting.”

“Well?” questioned Richard King.

“These men went to pray before the Lord and to ask a question.
Their question was about fasting; but fasting has to do with praying
—your friend has certainly been in a weeping and fasting spirit. They
asked: Should I weep in the fifth month separating myself, as I have
done these so many years?

“The Lord’s answer came through the prophet Zechariah. He


understood all about that so many years separating themselves and
fasting. He told them the fasting was not so much to him as for
them to hear the words which the Lord hath cried by the former
prophets. They might better study his revealed will than seek to find
a new answer to this question of fasting. The fasting in itself was all
right if they wished to fast. ‘When ye fasted did ye do it to me?’ he
asked. ‘When ye did eat and when ye did drink, did ye not eat for
yourselves, and drink for yourselves?’ In feasting and fasting they
had been selfish. Then he gives them plain words of command, like
the plain words the former prophets had spoken. Obedience was
better than fasting; better even than coming to him to inquire about
fasting. There is a parallel in the history of one of Joshua’s prayers.
He could not understand why the people should flee before their
enemies. Then he rent his clothes and fell to the earth, the elders,
also, all day, with dust on their heads; praying and fasting.
“But the Lord’s answer was: ‘Get thee up; wherefore liest thou thus
upon thy face?’

“Tell your old man praying and fasting are good, but sometimes God
has enough of them. He prefers obedience. The conditions of the
covenant had been violated by disobedience in both instances.
Praying in faith, and in the name of Christ, are but two conditions;
hearing and obeying is a third condition. Your man may be in the
midst of a very interesting experience, but I would advise him to
stop questioning the Lord, and try what a little obedience would do.”

“But, he’s a good man, Roger,” urged Judith, “only a good man could
bear a trial like that.”

“Good men have favorite little ways of disobedience, sometimes;


God’s own remedy is more obedience.”

“I wish we could know all about it—the rest of the story, and, if he
ever has his prayer,” said Marion, to whom “people” were becoming
a real and live interest.

“Joshua had his prayer. The story of Ai is the story of how God
answers prayer when he has made way for it; it shows his
disciplinary government; it places obedience before all things;
obedience makes God’s answers to prayer a natural proceeding.”

“I’m afraid I have depended too much on prayer,” Judith answered,


troubled.

“Oh, no,” Mr. King reassured her, “only you have not depended
enough on obedience. I will call upon my old man to-morrow and
tell him these two stories of disciplinary government.”

“You are not going home, to-night, old fellow,” urged Roger, “the
girls will give us some music. We four will make a fine quartette.”
“Miss Judith, did you know I have a housekeeper?” he asked, turning
brightly to Judith.

“I am very glad.”

“So are we all of us,” declared Roger.

“A man and his wife I have taken in. She’s a good cook; the house is
a different affair; I wish you would come and see. The man gets
work among the farmers and takes care of my horse, which I used
to do myself. They are both grateful for a home and I am very happy
to be set in a family.”

Judith fell asleep thinking of Aunt Rody’s beef-tea, and wondering if


Aunt Affy would remember to keep the water bag at her poor, cold
feet.

It was luxury to be at home again; to be at home and in the way of


obedience. That was God’s will on earth as it was in Heaven.

The next day the gentlemen went fishing and Marion and Judith kept
the long day to themselves. In the afternoon Marion and Nettie had
their weekly history talk, and, Judith shut herself up in the study and
wrote a story about a girl who learned a new lesson in the way of
obedience. The story was from a child’s standpoint; in writing for
children she was keeping her heart as fresh as the heart of a little
child.

“Judith,” said Roger that evening as the “quartette” were together in


the study, “I have a thought of work for you; you smell work from
afar as the warhorse scents the battle; how would you like to write
up the childhood of a dozen famous women? The study itself will be
delightful, and the writing more so. Call the series: ‘When I was a
Girl.’”

“I would like it,” was the unhesitating reply, “if I can do it.”
“You can do it. You can do anything you like.”

“Then I will,” she decided, thus encouraged.

“But the books?” said Richard King, ready to place his own
bookshelves at her service.

“Oh, the books are easily found. There’s our school library, and the
Public Library in Dunellen, and everybody’s house to ransack in
Bensalem. Besides, my own library is no mean affair. Books and
fishing are my laziness and luxury. No hurried work, Judith,
remember. You shall not read the first one of the series to me until a
month from to-day.”

“Are you such a slow worker yourself?” Roger’s friend inquired.

“I am a plodder. And I believe in other people plodding. I believe


that genius is an infinite capacity for taking pains. I have sermons
laid away to mellow that I’ve been six months on.”

“But you do other writing and studying in the mean time,” said
Judith.

“Oh, yes, while the seed is sprouting.”

“Kenney, you are planning something.”

“Yes, I am planning to salt down a barrel of sermons before I take a


new charge.”

“Mellowing, salting, sprouting,” laughed Judith.

“Roger, a new charge!” exclaimed Marion, startled.

“A new charge, my dear sister. I am too small for Bensalem, they


need a bigger man here.”
“But, Roger,” remonstrated Judith, with big, distressed eyes; “will
you not give dear, little Bensalem your best?”

“My very best,” he answered, solemnly.


XXVIII. A NEW ANXIETY.

“Our eyes see all around, in gloom or glow,


Hues of their own fresh borrowed from the heart.”

—Keble.

It was chilly that evening in the old rooms of the house with three
windows in the roof; Roger Kenney’s father and mother sat near the
grate in the front parlor; curtains and portieres were dropped, the
piano lamp with its crimson silk shade threw a glow over the two
faces sitting in cosy content opposite each other. The house was
still; the girls, Martha and Lou, and the two boys, Maurice and John,
had gone down town to an illustrated lecture on India; the maid had
her evening out; even Nip, the house-dog, had gone out for an
evening ramble; the two “old people,” as in their early sixties they
loved to call each other, were alone with each other and a new
anxiety.

Mr. Kenney told his wife that nothing in the world made her quite so
happy as a new worry, and he wished he could get one for her
oftener.

“This will do for awhile,” she remarked; “but this isn’t as bad as that
old trouble of Marion’s; a man can work himself out; and Roger has
work enough on hand for two worries.”

“Now, what are you going to do about this?” inquired her husband,
folding the evening’s paper and laying it upon his knee. “You sent
Marion to Bensalem for her charm; will you get Roger away for his?”

“That would do no good,” she replied, discontentedly, “he would not


be got away in the first place, and Judith is not a fixture in
Bensalem.”

“Judith is worth having,” was the complacent reply.

“That’s the worst of it. So was Don Mackenzie.”

“It’s the best of it, I think. You wouldn’t have your boys and girls
carried away by somebody not worth having.”

“But, then, being disappointed in somebody might help them bear it,
and turn them around to look at somebody else.”

“A disappointment like that is poor consolation.”

“I don’t suppose the disappointment is the consolation. The


somebody else is.”

“You never had the consolation of the somebody else.”

“I have only had the consolation of you,” she retorted.

“Marion has never taken up with anybody,” he said, reflectively.

“She has had no chance—”

“That you know,” he interrupted.

“—That I know,” she accepted meekly, “excepting David Prince.”

“She wouldn’t look at him.”

“No, she wouldn’t. He was younger in the first place—and so


different from Don.”
“I’d like to see that English beauty Don has married.”

“How do you know she is a beauty?” asked Marion’s mother, with a


touch of jealousy.

“Oh, he wrote that to Roger in his first young admiration. An orphan,


living with an uncle, years younger, a capricious beauty, with a little
money; wasn’t that the description?”

“Something like it. Marion has carried herself well about this
marriage.”

“Why shouldn’t she? She had nothing to carry herself about.”

“You don’t know girls. A memory is a memory.”

“How do you know?” he laughed.

“But this is not helping us out about Roger,” she remarked, ignoring
his words and laugh.

“Roger will help himself out; he isn’t his father’s son for nothing.”

“As Marion was not her mother’s girl for nothing,” was the demure
reply.

“How do you know—how can you be so certain sure that he wants


Judith?”

“She is the very light of his eyes. She has been for years. A mother
can see. The thought of her is always about him.”

“Does Marion see it?” Roger’s father inquired, convinced. He had a


thorough respect for his wife’s judgment.

“No; that’s the queer part of it. I think Roger is guarded with her. He
never had a secret from his mother.”
“Young men never have,” the young man’s father threw in.

“But I know Roger; I wouldn’t be afraid to ask him.”

“Then, why don’t you?”

“Because I know without asking,” she silenced him.

“Now, to come back to the starting point—what do you intend to do


about it?”

“Bring Judith here,” she replied impressively.

“That’s a fine move; an effectual separation.”

“If I could send her anywhere else he would think it his duty to go
and see her, he would have to know how she was doing—pay her
bills, and so forth. There’s no one else to be a father to her. Mrs.
Brush leaves everything with him. She has no knowledge of any
world outside of that village.”

“Perhaps she is trying to catch him for Judith.”

“Such a worldly thought would never enter her dear, pretty, simple,
shrewd head. She has her catch, and she didn’t catch him with guile.
She would rather keep Judith than set her on the throne of England.
That’s out of the question.”

“Well, I do see that point about bringing her here. He can see her
naturally here; nothing to thwart him; she’s such a girl, no older
than Martha—you never have any scares about Martha.”

“Martha has never been thrown so with anybody, I wouldn’t allow it.
I try to be always on the safe side?”

“You didn’t seem to be on Judith’s safe side.”


“I couldn’t. Nobody asked me. There she was studying at the
parsonage, before I knew it.”

“She was only a child then.”

“And I thought it such a good outlet for Marion—it was one of the
first things that roused her—that and her Outing Society. My only
fear was that she was taking Judith up for the sake of her Cousin
Don. His influence somehow seems to run through everything. But I
know better now. Judith won her own way. But I didn’t know I was
sacrificing Roger to Marion.”

“How could you have hindered?”

“I could have brought Marion home,” she answered, decidedly.

“And spoiled the good Bensalem was doing for her.”

“Oh, dear,” with a sigh, “how lives are tangled up.”

“And it’s rather dangerous for our fingers to get into the tangle,” he
suggested, with mild reproof.

“But we must do something,” she exclaimed, in despair.

“Well, yes, I suppose so—when the time comes.”

“Well, the time has come now.”

“I don’t see anything the matter with Roger. He can walk ten miles
on a stretch, he rides horseback, he cuts his own kindling wood and
makes his own garden, he gives his people two strong sermons a
week, beside the prayer meeting and weekly lectures; he goes
hunting with one of his deacons and talks farming with another; he
neglects nobody, and works like a drum-major. He isn’t hurt.”

“But he will be. Judith will refuse him.”


“How do you know that?”

“Because she has never thought of such a thing.”

“I grant that. Why should she? But she will think of it when he
suggests it.”

“She will not think of it as he does. He is an old fellow to her; let me


see; she was thirteen when she went to Bensalem, and he was—
how queer for me to forget—he was twenty-six, just twice her age.”

“He isn’t twice her age now,” observed Mr. Kenney, comically.

“And a woman is always older than a man,” Mrs. Kenney, reflected.


“She is nearer his age then, I think, childish as she is. With her hair
up she does look older; it’s those blue eyes like a baby, and that
complexion. I told Roger she might sit for a picture of Priscilla the
Puritan maiden, in her new-fashioned, old-fashioned dress, and he
said he had thought of it himself. But, now, Roger,” with a
deprecating little appeal, “it will do no harm to bring her here.”

“Not the least bit in the world,” he consented, cheerfully.


XXIX. JUDITH’S “FUTURE.”

“God never loved me in so sweet a way before:


’Tis he alone who can such blessings send:
And when his love would new expression find,
He brought thee to me, and he said, ‘Behold—a friend.’”

Exactly a month from the day Roger planned the Girl Papers for her,
Judith knocked at the study door with her manuscript in her hand.
She had written three papers; if he took sufficient interest in the first
she would read the others.

Beside the education for herself she had another thought in writing
them; she would send them to some child’s paper and earn money.
She knew that Marion had never depended upon the parsonage for
money; every month her father sent her a check; she had no father
to send her a check. No money had come to her from her Cousin
Don since his hurried marriage. Probably he considered her old
enough to earn money for herself. It would be hard to tell Aunt Affy
when she needed a dress, or shoes, or money, when she was not
doing anything for Aunt Affy’s comfort.

Last Sunday she had no money for Sunday-school or church; she


had no money for anything.

Her last story had been refused, and how she had cried over the
refusal. It was even hard to laugh when Roger told her that Queen
Victoria had sent an article to a paper under a “pen-name” and it
had been “returned with thanks.” She wished she were a dressmaker
like Agnes Trembly, or that she could go into a farmer’s kitchen, like
Jean Draper’s sister Lottie, and earn money and not be ashamed.

“Come in,” called Roger from among his books.

Her eyes were suspiciously red, she was relieved that his back was
toward her; he wheeled around in his chair as she seated herself,
and looked as though he had nothing in the world to do but listen to
her.

“Have you leisure to hear my Girl Papers?” she asked, with some
embarrassment. “They are horrid. I tried an essay, and failed. It was
stilted and stupid. I can make girls talk, so I threw my garnered
information into a conversation. But you may not care for this style.”

“I can bear anything,” he said, making a comical effort at self-


control.

After the first was read, with an inward quaking, she was delighted
with his word of encouragement:

“Read the others; I cannot know how bad they are until you read
them all.”

More hopefully she began the second paper, which she read in a
clear, conversational tone:—

“Do you know,” began grandmother, “who said that she could be
happy anywhere with good health and a bit of marble?”

And then we were all astir with eager interest.

“Rosa Bonheur was ‘happy anywhere’ with canvas, colors, and


brush; and this girl loved marble just as well, and brought breathing
life out of the cold marble, as Rosa brought it out on her canvas. But
Harriet was an American child, born into a luxurious home, with no
brothers or sisters, and her mother soon died and left her alone with
her father. Her mother died with consumption, and her father had
buried his other child besides Harriet with the same disease, so no
wonder he was afraid for his little girl, and determined to give her a
playful childhood in air and sunshine. Harriet Hosmer was born in
Watertown, Mass., October 9th, 1830.”

“And now she’s older than you are, grandmother,” said Bess. “I like
to know about when grandmothers were little girls.”

“But she and Rosa Bonheur are not grandmothers. They have had
canvas and marble instead of a home with children and
grandchildren in it. As soon as little Harriet was old enough a pet
dog was given to her, and she ornamented it with ribbons and bells.
Instead of tin cup and iron spoon, which Rosa had, she revelled in all
the pretty things that children love. The River Charles ran past her
home; her father gave her a boat and told her to take her air and
sunshine on the water and learn to develop her muscles by the oars.
And then he had built for her a Venetian gondola with velvet
cushions and silver prow.

“‘She will be spoiled,’ the neighbors foreboded, but her wise father
was not afraid; he knew how much happiness his child could bear
and not be rendered selfish. The next thing to help her become
strong was a gun; she soon became what your brothers would call a
good shot. By and by you will know how strong her hands and arms
became and what she could do with them. All this time, just as you
are, girls, these common days, she was being made ready for her
own special work.”

Juliet grew radiant. She was hoping for “special work.”

“Her room was a museum. Gathered and prepared by her own eager
and wise hands she had beetles, snakes, bats, birds, stuffed or
preserved in spirits. From the egg of a sea gull and the body of a
kingfisher she made an ink-stand; she climbed to the top of a tree
for a crow’s nest. Miles and miles she learned to walk without being
wearied. In her work and habits and strength she was like a boy.
She was fond of books, but just as fond of the clay-pit in her garden
where, to her father’s delight as well as her own, she molded dogs
and horses.

“When Harriet Hosmer was taken to a famous school (at home they
called her ‘happy Hatty’) the teacher said: ‘I have a reputation for
training wild colts; I will try this one.’ She stayed three years. On her
return home she began to take lessons in drawing, modeling, and in
anatomical studies, often walking fourteen miles to Boston and back,
with hours of work and study. Was not that a day’s work? She went
to the Medical College of St. Louis to take a thorough course in
anatomy.”

“You have to know things to get things out of marble,” remarked


Ethel.

“Grandmother, how hard girls can work!” exclaimed Nan, who did
not love work.

“After she had finished her studies she traveled alone to New
Orleans, and then north to the Falls of St. Anthony, smoking the pipe
of peace with the chief of the Dakota Indians, explored lead mines in
Dubuque, and scaled a high mountain to which her name was
afterward given.”

“That was fun,” said Nan. “I’m glad she had some fun with her hard
work.”

“After work in her studio at home her father sent her to Rome. Girl
as she was, in her studio at home she wielded for eight or ten hours
a day a leaden mallet weighing four pounds and a half. And it was
then she told a friend that she would not be homesick, for she could
be happy anywhere with good health and a bit of marble. For seven
years she worked on her ‘bit of marble’ in Rome. She made beautiful
and wonderful things with her good health and her marble, with
hard work, and the insight into beauty that God, who makes all
beautiful things, gave to this ready and obedient child.

“The first work she copied for her teacher was the Venus of Milo;
when almost completed the iron, which held the clay firm, snapped,
and all her work was spoiled.”

“Oh!” sighed Ethel.

“But she did not shriek nor cry herself to sleep (that anybody knew),
but bravely went to work again. Her works were exhibited in Boston
and much admired. Her teacher said he had never seen surpassed
her genius of imitating the roundness and softness of flesh. Look at
other marble statues and see if the flesh looks soft and round like
Harriet’s. One of her works, a girl lying asleep, was exhibited in
London and in several American cities. She said once she would
work as though she had to earn her daily bread, and, strange to tell,
very soon after that her father wrote that he had lost his property
and could send her no more money. And then she hired a cheap
room, sold her handsome saddle-horse, and went to work in reality
to earn her daily bread. Her first work, in her time of sorrow, was a
fun-loving, four-year-old child. With the several copies she made
from it she earned for her daily bread thirty thousand dollars.”

“And oh! grandmother,” I said (for I am a poor girl myself), “when


our heavenly Father has work for us to do, it doesn’t matter whether
we are born poor or rich.”

“Either way it takes hard work,” said grandmother.

With a shy glance into his satisfied face she opened her third paper:

“Children have more need of models than of critics,” said


grandmother, “therefore I will give you another model to-night. You
will think I am always choosing for you stories of girls that work; but
where can I find models of any other kind? What do girls amount to
who think only of their own pleasure, and never persevere to the
successful end? Now I will tell you about a girl who came in
womanhood to live in an observatory. This is her home. She is a
dear old lady with white hair, dressed in gray or brown, in rather
Quakerish fashion. She said to the girls she teaches: ‘All the clothing
I have on cost but seventeen dollars.’ In this unusual home (she is
not a grandmother, either), she keeps the things she loves best,—
her books, her pictures, her astronomical clock, and a bust of Mary
Somerville, of whom I will tell you some time.”

“And then we will remember that her bust is in somebody’s


observatory home,” said Bess.

“It is not a wonder that Maria Mitchell has great respect for girls who
do something, and for idle girls none at all. As Juliet was at
Nantucket last summer she will be interested to know that Maria
Mitchell was born in that quiet, delightful place. She was in a home
of ten children. Her mother was a Quaker girl, a descendant of
Benjamin Franklin. Her father was a school teacher. Little Maria went
to school to her father. At school she studied, and with ten little
people at home, what do you think she did? She herself calls her
work, ‘endless washing of dishes.’ The dishwashing never hindered. I
think it helped. I believe in dishwashing. I wonder what this little girl
would have thought of the dishwasher that some people have in
their kitchens, and is warranted to wash sixty-five dishes (in the
smaller affair) at once, in the soap-sudsy, steamy, crank-turning
space of three blessed minutes. And all dried, too. But in her
observatory she had no need to think of dishwashing. Like Rosa
Bonheur, and Harriet Hosmer, she had a good father and a wise
father. When he was eight years old his father called him to the door
to look at the planet Saturn, and from that time the boy calculated
his age from the position of the planet, year by year.”

“Then it began with her grandfather,” said Juliet, who liked to find
the beginnings of things.
“Her father had a little observatory of his own, on his own land, that
he might study the stars. So it is no marvel that his daughter is
ending her useful days in a big observatory. When Maria went to her
observatory, her father was seventy years of age; he needed her as
nurse and companion, but he said, ‘Go, and I will go with you.’”

“This is the loveliest story of all,” exclaimed Grace, who loves her
own old father dearly.

“For four years her father lived to be proud of her, and enjoyed her
work and her pupils at Vassar College. When Maria was a girl her
father could see no reason why she should not become as well
educated as his boys, so he gave her, as to them, a special drill in
navigation.”

“Grandmother,” asked Ethel, “did you know all these little girls when
they were little?”

“No, darling,” said grandmother, “I found out about them in books.


And telling you about the girls is getting you ready to read about
them all the little things the world has a right to know. For they
belong to the whole world. Maria did not learn fancy work. I can
guess what she would say of some girls who care more for fancy
stitches than for studies. She has said, ‘A woman might be learning
seven languages while she is learning fancy work.’ Still, girls,
educate your fingers, and make your homes pretty and attractive.
But don’t let stitches hinder the stars—God has his place for both.”

“Yes, the women worked pretty things for the Tabernacle,” I said.
(For I love to make pretty things.)

“But she did know how to knit, and she knit stockings a yard long for
her father as long as he lived. She studied while she knit, as I used
to do when I was a little girl. When she was a little girl how she did
read! Before she was ten years old she read through Rollin’s Ancient
History.
“One night in October, 1847, she was gazing through her telescope,
and what do you think she saw? An unknown comet. She was afraid
it was an old story. Frederick VI., King of Denmark, sixteen years
before, had offered a gold medal to the person who should discover
a telescopic comet. And the little Nantucket girl, who had knitted
stockings a yard long, and washed endless dishes, discovered the
telescopic comet, and to her was awarded the gold medal. And now
the scientific journals announced Miss Mitchell’s comet. In England
she was eagerly welcomed by Sir John and Lady Herschel, and
Alexander Von Humboldt took her beside him on a sofa and talked to
her about everybody he knew and everything he knew. And, oh! the
other great people who were glad to see her. She saw in Rome
Frederika Bremer, of whose comical, interesting, sad girlhood I must
tell you some day. But I musn’t forget the little house Maria bought
for her father before she went to the observatory of Vassar College.
It cost sixteen hundred and fifty dollars, and she saved the money
out of her yearly salary of one hundred dollars, and what she could
earn in government work.”

“I don’t think I mind washing dishes so much now,” declared Nan.

And we all laughed.

“Good,” exclaimed Judith’s listener. “Keep on with the dozen, and salt
them down. When I Was a Boy series will be a good thing for you.
Judith, honest, now, would you rather go away to school this winter,
or read and write with Marion and me?”

“Study with you,” was the quick decision; “I can think of nothing in
the world I would like so well.”

“Then that is settled,” he replied with satisfaction; “I feared you


would be restless. You are at the frisky and restless age. Marion was
sure you would not be.”

“But—” Judith hesitated and colored painfully, “if I am to teach by


and by, would it be better for me to go to school? I can borrow the
money and then earn it by teaching and repay Aunt Affy.”

“We are not making a teacher of you; we are making an educated


woman—”

“But, Roger,” she persisted, “unless I go back to Aunt Affy I must


support myself. I am not willing to be dependent upon any one
except Aunt Affy.”

“Upon whom are you dependent now? Are you not earning your
board by being co-operative housekeeper?”

“If you and Marion think so.”

“Ask Marion.”

“But I would like to ask you, too?”

“I thought my little sister had more delicacy of feeling than to ask


such a question.”

“Roger, don’t be a goose,” she said, indignantly, “that was all very
well when I was a child. You forget that I am grown up.”

“You will not let me forget it.”

“I wish you not to forget it. In the spring, on my nineteenth birthday,


I shall decide upon my future. Just think, I have a future,” she
laughed. “I am only too glad of the study and music this winter.
Then I shall go out into the world, or go back to Aunt Affy. I do not
mean to be too proud—” with a quiver of the lip.

“Only just proud enough. You are exactly that. Let us live in peace
this winter, and then your nineteenth birthday may do its worst for
us all.”

“You will not be serious,” she answered, with vexed tears; “my life is
a great deal to me.”
“It is a great deal to us all, dear. Work and be patient, and you will
have as happy an ending as any story you write.”

“My children end as children,” she said, with a quick laugh. “I


shouldn’t know what to do with them if they grew up.”

“There is One who does know what to do with his children when
they grow up,” said Roger, bending as he stood beside her and
touching her lips with his own. It was the first time he had ever
kissed her. She took the kiss as gravely and simply as it was given.
Something was sealed between them. She would never be proud
with him again.

“I will not kiss you again,” said Roger to himself, “until you promise
to be my wife.”

That afternoon Roger asked Marion to drive to Meadow Centre.

“I am glad you did not ask Judith,” replied Marion, with something in
her voice.

“Why not?” he asked, indignantly, “why shouldn’t I ask Judith to


drive with me?”

“My point was not driving with you, but driving to Meadow Centre.”

“I confess I do not understand you.”

“I knew you didn’t. Men are blind creatures.”

“Then open the eyes of one blind creature.”

“Haven’t you seen that Mr. King is interested in Judith?” she asked,
somewhat impatiently.

“We are all interested in Judith.”


“Not just as he is. You are not,” looking straight into his frank,
smiling eyes.

“You don’t mean—”

“Yes, I do mean—”

“What about her?” he asked with the color hot in his face. But
Marion was a “blind creature” then and did not see.

“I don’t know about her. She isn’t grown up enough to think. But I
know he is wonderfully attractive to her.”

“He’s a good fellow. I will not stand in his way.”

“For pity’s sake, Roger, don’t think you must do anything,” cried
Marion, dismayed; “let her alone. He will take care of himself.”

“I shall certainly let her alone. He is so artless that he will be taken


care of. It is like him to stumble into the best thing in the universe
and then wonder how he ever got it.”

“I hope you don’t call Meadow Centre one of the best things,”
retorted Marion.

“It’s a good place for a man to make something of himself; he is


writing sermons that will make a stir somewhere. Meadow Centre is
to him what Paul’s three years in Arabia were to him.”

“Then we must do our best to make Judith ready—”

“What a plotter you are,” he exclaimed, angrily; then, more quietly:


“But we will make Judith ready,” and he walked off with a laugh that
was a mixture of things.

This day, in which God’s daily bread and his daily will were given to
Judith as upon all the other days, was one of the very happiest days
of her happy life.
Roger’s kiss gave her an undefined sense of safety and protection; if
she were not wise enough to decide when the time came she would
take refuge in that safety and protection, and—another kiss.

That evening Joe came for her, saying Aunt Rody was worse. She
went home with him, and “watched” with Aunt Affy, until poor Aunt
Rody passed away from the home she had toiled so unceasingly for
and taken so little comfort in. One week she stayed with Aunt Affy:
“I miss her so,” wept Aunt Affy broken-heartedly; “I never was in the
world without her before.”

“I suppose we musn’t keep you, Judith,” Uncle Cephas remarked one


evening behind his newspaper.

“Not yet,” said Judith. “I want to be as busy as a bee this winter to


get ready for something.”

“Then we will have to adopt Joe; we must have some young thing
about the house.”

Judith’s first words to Roger and Marion as they went out to


welcome her on the piazza were in a burst: “I do think those two old
people growing old together is the loveliest thing I ever saw.”

“How young must two people begin to grow old together?” inquired
Roger, comically.

“As soon as they think about growing old,” said Marion.

“Then I will not begin to think until my birthday,” said Judith.


“Marion, I am too happy in having two homes. Some better girl than
I should have them.”

“You forget your third home in England,” remarked Roger, seriously.

“Oh, poor Don. Roger, I am afraid Don isn’t happy,” she said, with
slow emphasis.
What Roger thought he did not say.

Don’s letters were brief, constrained; Judith’s letter to her “new, dear
Cousin Florence” had met with no response—that Judith knew.
XXX. A TALK AND WHAT CAME OF IT.
“There is nothing which faith does not overcome; nothing
which it will not accept.”

—Bishop Huntington.

“Roger,” began Judith, doubtfully.

“Begin again, I don’t like that tone.”

“I was afraid you were thinking—”

“I should be sorry not to be.”

“I was afraid you were thinking too deeply to be disturbed.”

“Then I shouldn’t be disturbed; my mind would be absent from my


ear and I should not hear that doubtful appeal. The doubt is what I
object to.”

Marion and her mother had not returned from their drive to Meadow
Centre, where Mrs. Kenney had a school friend. They intended to
“spend an old-fashioned day,” Mrs. Kenney remarked at the
breakfast table; it was five o’clock in the November afternoon and
the old-fashioned day was not yet ended.

Judith and her fancy work, covers for Nettie’s bureau, had taken
possession of the light in the bay window; as the light faded, she sat
thinking with her work in her lap. Roger entered and threw himself
upon the lounge, clasping his hands above his head; his thinking
was weaving itself in and out of a suggestion of his mother’s that
she should take Judith home for the winter.

To the suggestion he had replied nothing at all.

“Then the doubt is gone,” answered Judith, brightly. “I do not know


how to put my thought.”
“Isn’t that rather a new experience?”

“It is the experience of every day,” she answered, unmindful of his


teasing. “I wonder why God keeps us so much in the dark.”

“Perhaps we keep ourselves in the dark.”

“That is what I wanted to know.”

“Can you tell me exactly what you mean? Are you in the dark about
anything?”

“About everything,” she exclaimed with such energy that his only
reply was a laugh.

“Just now I mean one special thing that I cannot tell you about.”

“O, Judith, are you growing up to have secrets?” he groaned.

“I am growing up with secrets. Aunt Rody used to exasperate me by


telling me I would ‘outgrow’ something, when all the time I knew I
was growing into something.”

“Growing into a new thing is the best way to outgrow an old thing.”

“Then I am satisfied about something.”

Roger wished that he could be—about something.

“I wish I could tell you. But I don’t know why I shouldn’t. I’m afraid
Marion doesn’t care for Mr. King, and I want her to so much.”

In the twilight she could not see the illumination in the face across
the room on the lounge.

He was satisfied about something.

“What are you getting down into?” he asked jubilantly.


Welcome to our website – the perfect destination for book lovers and
knowledge seekers. We believe that every book holds a new world,
offering opportunities for learning, discovery, and personal growth.
That’s why we are dedicated to bringing you a diverse collection of
books, ranging from classic literature and specialized publications to
self-development guides and children's books.

More than just a book-buying platform, we strive to be a bridge


connecting you with timeless cultural and intellectual values. With an
elegant, user-friendly interface and a smart search system, you can
quickly find the books that best suit your interests. Additionally,
our special promotions and home delivery services help you save time
and fully enjoy the joy of reading.

Join us on a journey of knowledge exploration, passion nurturing, and


personal growth every day!

ebookbell.com

You might also like