100% found this document useful (4 votes)
45 views45 pages

First Steps With Embedded Systems 1st Edition by Byte Craft Limited ISBN Download

Ebook

Uploaded by

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

First Steps With Embedded Systems 1st Edition by Byte Craft Limited ISBN Download

Ebook

Uploaded by

stanzahartel
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/ 45

First Steps with Embedded Systems 1st Edition by

Byte Craft Limited ISBN pdf download

https://ebookball.com/product/first-steps-with-embedded-
systems-1st-edition-by-byte-craft-limited-isbn-12312/

Explore and download more ebooks or textbooks


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

Embedded System Design Embedded Systems Foundations of


Cyber Physical Systems and the Internet of Things 3rd
Edition by Peter Marwedel ISBN 331956045X 9783319560458
https://ebookball.com/product/embedded-system-design-embedded-systems-
foundations-of-cyber-physical-systems-and-the-internet-of-things-3rd-
edition-by-peter-marwedel-isbn-331956045x-9783319560458-15824/

The Anatomy of a Best Seller: 3 Steps to Deconstruct


Winning Books and Teach Yourself Craft 1st edition by
Sacha Black ISBN 1913236161 978-1913236168
https://ebookball.com/product/the-anatomy-of-a-best-seller-3-steps-to-
deconstruct-winning-books-and-teach-yourself-craft-1st-edition-by-
sacha-black-isbn-1913236161-978-1913236168-20380/

Systems Controls Embedded Systems Energy and Machines 1st


Edition by Richard Dorf 0849373476 9780849373473

https://ebookball.com/product/systems-controls-embedded-systems-
energy-and-machines-1st-edition-by-richard-
dorf-0849373476-9780849373473-17526/

Cryptographic Hardware and Embedded Systems CHES 2011 1st


Edition by Bart Preneel, Tsuyoshi Takagi ISBN 364223951X
9783642239519
https://ebookball.com/product/cryptographic-hardware-and-embedded-
systems-ches-2011-1st-edition-by-bart-preneel-tsuyoshi-takagi-
isbn-364223951x-9783642239519-13282/
Embedded Systems Design Based on Formal Models of
Computation 1st Edition by Ivan Radojevic, Zoran Salcic
ISBN 9789400715943
https://ebookball.com/product/embedded-systems-design-based-on-formal-
models-of-computation-1st-edition-by-ivan-radojevic-zoran-salcic-
isbn-9789400715943-8954/

Real Time Embedded Systems Design Principles and


Engineering Practices 1st Edition by Xiaocong Fan
0128015071 9780128015070
https://ebookball.com/product/real-time-embedded-systems-design-
principles-and-engineering-practices-1st-edition-by-xiaocong-
fan-0128015071-9780128015070-17208/

The Art of The Art of Designing Embedded Systems 1st


edition by Jack Ganssle 9780080499352 008049935X

https://ebookball.com/product/the-art-of-the-art-of-designing-
embedded-systems-1st-edition-by-jack-
ganssle-9780080499352-008049935x-8874/

Security Engineering for Embedded and Cyber Physical


Systems 1st edition by Saad Motahhir, Yassine Maleh
1000644235 9781000644234
https://ebookball.com/product/security-engineering-for-embedded-and-
cyber-physical-systems-1st-edition-by-saad-motahhir-yassine-
maleh-1000644235-9781000644234-20190/

Embedded System Design With the Atmel AVR Microcontroller


Part 1 1st Edition by Steven Barrett 3031798058
9783031798054
https://ebookball.com/product/embedded-system-design-with-the-atmel-
avr-microcontroller-part-1-1st-edition-by-steven-
barrett-3031798058-9783031798054-17158/
First Steps
with
Embedded
Systems

Byte Craft Limited

02A4 A ox40;
02A6 B gs&0x20)
02A9 C table();
[email protected]
CDSCode Development Systems
The Byte Craft Limited Code Development
Systems are high-performance embedded
[email protected]

Do Byte Craft Limited compilers


support ANSI C?
development packages designed for serious All Byte Craft compilers are ANSI compatible within the
developers. They generate small, fast, and limitations of the target hardware.
efficient code. They enable the professional How efficient is the optimizer
developer to produce stand-alone single-chip compared to hand-written
microcontroller applications quickly. Developers assembler code?
can easily port C language applications written The compiler generates object code as tight and
for other embedded platforms to the CDS. efficient as most hand-written assembler code.
Can I combine C code and
www.bytecraft.com assembler in my programs?
You can embed assembler code within your C program,
Features using #asm and #endasm preprocessor directives. The
! The Code Development Systems support embedded code can call C functions and directly
entire families of microcontrollers. access C variables. To pass arguments conveniently,
! The optimizing C language cross-compilers are embed your assembly code in the body of a C function.
ANSI-compatible within hardware limitations. What kinds of emulator hardware
! Tight, fast and efficient code optimization do the compilers support?
generates clean, customized applications. For more information on supported emulator products,
! A built-in Macro Assembler allows inline contact Byte Craft Limited support staff.
assembly language in C source. How do the compilers handle local
! CDS generate symbol and source reference variable declarations?
Our compilers store locally-declared variables in
information for C source-level debugging with
reusable local memory spaces. The scope of local
popular emulators. variables is protected.
! C language support for interrupt service
What are Byte Craft Limited's
routines and direct access to ports. terms?
! Device files for individual parts precisely
For Canada and the U.S.: For company purchases (on
control code generation and resource usage. approved credit), NET 30 days after shipping. Byte
! Complete user documentation comes with
Craft ships next day FedEx free of charge. All other
every Code Development System. orders must be prepaid, with American Express, VISA,
! Absolute Code Mode lets you compile directly check with order, or direct wire transfer.
to final code without a separate linking phase. For overseas: All orders, prepaid with American
Alternatively, you can use the BClink Express, VISA, check with order, or direct wire transfer.
Optimizing Linker. Either method performs a Shipping is extra. Please call for more information.
final optimization pass on an entire program. Please obtain appropriate import documentation.
! Demonstration versions are available from: If for any reason you are unsatisfied with your
http://www.bytecraft.com/ purchase, you can return it within 30 days for a full
refund.
Versatility
Code Development Systems install under
Windows 95, 98, ME, NT, 2000, or under MS/PC A2-490 Dutton Drive
DOS. Waterloo, Ontario
CDS provide symbol table information and a Canada
listing file: a merged listing of C source and N2L 6H7
generated assembly language to permit detailed Tel: 519-888-6911
Fax: 519-746-6751
analysis.
First Steps
with Embedded Systems
by

Byte Craft Limited


BYTE CRAFT LIMITED
A2-490 Dutton Drive
Waterloo, Ontario
Canada N2L 6H7
Telephone: (519) 888-6911
FAX: (519) 746-6751
Email: [email protected]

http://www.bytecraft.com

Copyright ! 1997, 2002 Byte Craft Limited. Licensed Material. All rights reserved.
First Steps with Embedded Systems is protected by copyrights. All rights reserved. No part of this
publication may be reproduced, stored in a retrieval system, or transmitted in any form or by any
means, electronic, mechanical, photocopying, recording, or otherwise without the prior written
permission of Byte Craft Limited.
All example and program code is protected by copyright.
Printed in Canada 14 November, 2002
Table of Contents

1. Introduction 1
1.1 Typographical Conventions....................................................................... 1
1.2 Explaining the Microcontroller ................................................................. 2
1.3 Book Contents ........................................................................................... 3

2. Microcontroller Overview 5
2.1 What is a Microcontroller?......................................................................... 5
2.2 The Microcontroller in a System............................................................... 7
2.3 Architecture ............................................................................................... 7
2.3.1 Von Neumann ......................................................................................................................8
2.3.2 Von Neumann Memory Map.............................................................................................8
2.3.3 Harvard ..................................................................................................................................9
2.3.4 Harvard Memory Map.......................................................................................................10
2.3.5 The Central Processing Unit ............................................................................................11
2.3.6 Central Processing Unit.....................................................................................................13
2.3.7 ROM.....................................................................................................................................14
2.3.8 RAM .....................................................................................................................................15
2.3.9 I/O Ports.............................................................................................................................16
2.3.10 Timer..................................................................................................................................17
2.3.11 Interrupt Circuitry............................................................................................................18
2.3.12 Buses ..................................................................................................................................19
2.4 Sample Microcontroller Configurations.................................................. 19
2.4.1 Motorola MC68HC705C8 ................................................................................................19
2.4.2 National Semiconductor COP8SAA7 ............................................................................20
2.4.3 Microchip PIC16C54.........................................................................................................20
2.4.4 Microchip PIC16C74.........................................................................................................21

i
Table of Contents

3. The Embedded Environment 23


3.1 The Embedded Difference ......................................................................23
3.2 Fabrication Techniques ..........................................................................24
3.3 Memory Addressing and Types ..............................................................24
3.3.1 RAM..................................................................................................................................... 24
3.3.2 ROM .................................................................................................................................... 25
3.3.3 PROM ................................................................................................................................. 25
3.3.4 EPROM .............................................................................................................................. 25
3.3.5 EEPROM ........................................................................................................................... 26
3.3.6 Flash Memory..................................................................................................................... 27
3.3.7 Registers .............................................................................................................................. 27
3.3.8 Scratch Pad ......................................................................................................................... 28
3.4 Interrupts .................................................................................................29
3.4.1 Interrupt Handling ............................................................................................................ 30
3.4.2 Synchronous and Asynchronous Interrupt Acknowledgement................................. 30
3.4.3 Servicing Interrupts ........................................................................................................... 31
3.4.4 Interrupt Detection ........................................................................................................... 32
3.4.5 Executing Interrupt Handlers.......................................................................................... 33
3.4.6 Multiple Interrupts ............................................................................................................ 34
3.5 Specific Interrupts ...................................................................................34
3.5.1 RESET ................................................................................................................................ 35
3.5.2 Software Interrupt/Trap .................................................................................................. 35
3.5.3 IRQ ...................................................................................................................................... 36
3.5.4 TIMER ................................................................................................................................ 36
3.6 Power .......................................................................................................37
3.6.1 Brownout ............................................................................................................................ 37
3.6.2 Halt/Idle ............................................................................................................................. 37
3.7 Input and Output.....................................................................................37
3.7.1 Ports..................................................................................................................................... 37
3.7.2 Serial Input and Output.................................................................................................... 38
3.8 Analog to Digital Conversion ..................................................................40
3.9 Miscellaneous .......................................................................................... 41
3.9.1 Digital Signal Processor .................................................................................................... 41
3.9.2 Clock Monitor .................................................................................................................... 41

ii
Table of Contents

3.10 Devices................................................................................................... 41
3.10.1 Mask ROM........................................................................................................................41
3.10.2 Windowed Parts ...............................................................................................................41
3.10.3 OTP....................................................................................................................................41

4. Programming Fundamentals 43
4.1 What is a Program?.................................................................................. 43
4.2 Number Systems ..................................................................................... 43
4.3 Binary Information.................................................................................. 44
4.4 Memory Addressing ................................................................................ 46
4.5 Machine Language.................................................................................. 46
4.6 Assembly Language ................................................................................ 46
4.6.1 Assembler ............................................................................................................................47
4.7 Instruction Sets........................................................................................ 47
4.8 The Development of Programming Languages ..................................... 48
4.9 Compilers ................................................................................................ 50
4.9.1 The Preprocessor ...............................................................................................................50
4.9.2 The Compiler ......................................................................................................................50
4.9.3 The Linker ...........................................................................................................................50
4.10 Cross Development................................................................................ 51
4.10.1 Cross compiler..................................................................................................................51
4.10.2 Cross development tools ................................................................................................51
4.10.3 Embedded Development Cycle.....................................................................................52

5. First Look at a C Program 55


5.1 Program Comments................................................................................. 56
5.2 Preprocessor directives............................................................................ 56
5.3 C Functions ............................................................................................. 58
5.3.1 The main( ) function..........................................................................................................58
5.3.2 Calling a Function ..............................................................................................................59

iii
Table of Contents

5.4 The Function Body..................................................................................60


5.4.1 The Assignment Statement .............................................................................................. 60
5.4.2 Control statements ............................................................................................................ 60
5.4.3 Calling Functions ............................................................................................................... 62
5.5 The Embedded Difference......................................................................62
5.5.1 Device Knowledge ............................................................................................................ 63
5.5.2 Special Data Types and Data Access.............................................................................. 63
5.5.3 Program Flow..................................................................................................................... 63
5.5.4 Combining C and Assembly Language .......................................................................... 63
5.5.5 Mechanical Knowledge..................................................................................................... 64

6. C Program Structure 65
6.1 C Preprocessor Directives........................................................................65
6.2 Identifier Declaration ..............................................................................65
6.2.1 Identifiers in Memory ....................................................................................................... 66
6.2.2 Identifier names ................................................................................................................. 66
6.2.3 Variable Data Identifiers................................................................................................... 67
6.2.4 Constant Data Identifiers ................................................................................................. 67
6.2.5 Function Identifiers........................................................................................................... 68
6.3 Statements ...............................................................................................68
6.3.1 The Semicolon Statement Terminator ........................................................................... 69
6.3.2 Combining Statements in a Block................................................................................... 69

7. Basic Data Types 71


7.1 The ASCII Character Set ......................................................................... 71
7.2 Data types ................................................................................................ 71
7.3 Variable Data Types ................................................................................72
7.3.1 Variable Data Type Memory Allocation ........................................................................ 72
7.3.2 Variable Scope.................................................................................................................... 73
7.3.3 Global Scope ...................................................................................................................... 74
7.3.4 Local Scope......................................................................................................................... 74
7.3.5 Declaring Two Variables with the Same Name............................................................ 74
7.3.6 Why Scope is Important................................................................................................... 75
7.4 Function Data Types...............................................................................75
7.4.1 Function Parameter data types ........................................................................................ 76

iv
Table of Contents

7.5 The Character Data Type........................................................................ 76


7.5.1 Assigning a character value...............................................................................................76
7.5.2 ASCII Character Arrangement ........................................................................................77
7.5.3 Numeric Characters ...........................................................................................................77
7.5.4 Escape Sequences...............................................................................................................77
7.6 Integer Data Types.................................................................................. 78
7.6.1 Integer Sign Bit...................................................................................................................78
7.6.2 The short Data Type .........................................................................................................78
7.6.3 The long Data type ............................................................................................................79
7.6.4 Different Notations ...........................................................................................................79
7.7 Data Type Modifiers ............................................................................... 79
7.7.1 Signed and Unsigned .........................................................................................................80
7.7.2 Other Data Type Modifiers..............................................................................................80
7.8 Real Numbers ......................................................................................... 80
7.8.1 The float Data Type...........................................................................................................81
7.8.2 The double and long double Types.................................................................................81
7.8.3 Assigning an Integer to a float .........................................................................................81

8. Operators and Expressions 83


8.1 Operators ................................................................................................. 83
8.2 C Expressions.......................................................................................... 84
8.2.1 Binding.................................................................................................................................85
8.2.2 Unary Operators.................................................................................................................85
8.2.3 Binary Operators ................................................................................................................85
8.2.4 Trinary Operator ................................................................................................................86
8.2.5 Operator Precedence .........................................................................................................86
8.2.6 The = Operator ..................................................................................................................87
8.3 Arithmetic Operators............................................................................... 88
8.3.1 Increment and Decrement Operators ............................................................................89
8.4 Assignment Operators............................................................................. 90
8.5 Comparison Operators ............................................................................ 91
8.5.1 Expressing True and False................................................................................................91
8.5.2 The Equality Operators.....................................................................................................92
8.5.3 Relational Operators..........................................................................................................92
8.5.4 Logical Operators...............................................................................................................93

v
Table of Contents

8.6 Bit Level Operators..................................................................................95


8.6.1 Bit Logical Operators........................................................................................................ 95
8.6.2 Bit shift operators .............................................................................................................. 97

9. Control Structures 99
9.1 Conditional Expressions..........................................................................99
9.2 Decision Structures................................................................................ 100
9.2.1 if and else Statements...................................................................................................... 100
9.2.2 Nested if statements........................................................................................................ 101
9.2.3 Matching else and if......................................................................................................... 102
9.2.4 switch and case................................................................................................................. 103
9.2.5 Execution within a switch .............................................................................................. 103
9.2.6 Fall-through execution.................................................................................................... 104
9.2.7 The default case ............................................................................................................... 105
9.2.8 The goto Statement ......................................................................................................... 105
9.2.9 Comparing goto and switch..case.................................................................................. 106
9.3 Looping Structures ................................................................................ 106
9.3.1 Control expression .......................................................................................................... 106
9.3.2 The while loop.................................................................................................................. 107
9.3.3 The do loop ...................................................................................................................... 107
9.3.4 The for loop...................................................................................................................... 108
9.3.5 How the for loop works ................................................................................................. 108
9.4 Exiting a Loop....................................................................................... 109
9.4.1 The break Statement ....................................................................................................... 109
9.4.2 The continue Statement.................................................................................................. 109

10. Functions 111


10.1 main() ....................................................................................................111
10.2 Executing a Function ...........................................................................111
10.2.1 Calling a Function.......................................................................................................... 112
10.3 Function Prototype Declarations..........................................................113
10.3.1 Defining the Function Interface ................................................................................. 113
10.3.2 Calling Functions in Other Files ................................................................................. 113
10.3.3 Function Type, Name and Parameter List ................................................................ 114
10.3.4 Functions and void........................................................................................................ 115

vi
Table of Contents

10.4 Function Definitions.............................................................................116


10.4.1 Statement Block..............................................................................................................116
10.4.2 Variable Declarations in Function Definitions .........................................................116
10.5 Function Parameters.............................................................................117
10.5.1 Passing Data by Value ...................................................................................................117
10.5.2 Passing Data by Reference ...........................................................................................117
10.5.3 Functions Without Parameters ....................................................................................118

11. Complex Data Types 121


11.1 Pointers..................................................................................................121
11.1.1 Declaring a Pointer ........................................................................................................121
11.1.2 Pointer Operators ..........................................................................................................122
11.1.3 Pointer Pitfalls ................................................................................................................123
11.2 Arrays ....................................................................................................124
11.2.1 Accessing Array Elements ............................................................................................124
11.2.2 Multidimensional Arrays...............................................................................................125
11.2.3 Array Operations and Pointer Arithmetic .................................................................125
11.2.4 Arrays of Pointers ..........................................................................................................126
11.3 User Defined Data Types .....................................................................127
11.3.1 Using typedef to Define New Data Types.................................................................127
11.3.2 Using types defined with typedef ................................................................................128
11.4 Enumerated Types................................................................................128
11.4.1 Enumerated Type Elements.........................................................................................129
11.4.2 Enumerated Type Value Checks .................................................................................129
11.4.3 Specifying Values for Enumerated Elements............................................................130
11.5 Structures ..............................................................................................131
11.5.1 The structure tag ............................................................................................................131
11.5.2 Using typedef to Define a Structure ...........................................................................132
11.5.3 Accessing Structure Members......................................................................................132
11.5.4 Indicating a Field with the Dot Operator ..................................................................132
11.5.5 Indicating a Field with the Structure Pointer ............................................................133
11.5.6 Bit Fields in Structures ..................................................................................................133
11.5.7 Storing bit fields in memory.........................................................................................134
11.5.8 The behaviour of bit fields ...........................................................................................134
11.6 Unions ...................................................................................................135
11.6.1 Retrieving a Union Element.........................................................................................136

vii
Table of Contents

11.6.2 Using Unions with Incompatible Variables .............................................................. 137

12. Storage and Data Type Modifiers 139


12.1 Storage Class Modifiers........................................................................ 139
12.1.1 External linkage.............................................................................................................. 139
12.1.2 Internal linkage............................................................................................................... 139
12.1.3 No linkage....................................................................................................................... 140
12.1.4 The extern Modifier ...................................................................................................... 140
12.1.5 Global Variables and extern......................................................................................... 141
12.1.6 The static Modifier ........................................................................................................ 142
12.1.7 The visibility of static variables ................................................................................... 142
12.1.8 The register Modifier .................................................................................................... 143
12.1.9 The auto Modifier.......................................................................................................... 144
12.2 Data Type Modifiers ............................................................................ 145
12.2.1 Value Constancy Modifiers: const and volatile......................................................... 145
12.2.2 Allowable Values Modifiers: signed and unsigned................................................... 146
12.2.3 Size Modifiers: short and long..................................................................................... 146
12.2.4 Pointer Size Modifiers: near and far ........................................................................... 147
12.2.5 Using near and far pointers.......................................................................................... 148
12.2.6 Default pointer type ...................................................................................................... 148

13. The C Preprocessor 151


13.1 Preprocessor Directive Syntax ..............................................................151
13.2 White Space in the Preprocessor ......................................................... 152
13.3 File Inclusion ....................................................................................... 152
13.3.1 File Inclusion Searches .................................................................................................153
13.4 Defining Symbolic Constants .............................................................. 153
13.4.1 The #undef directive ....................................................................................................154
13.4.2 Defining “empty” symbols .......................................................................................... 155
13.5 Defining Macros .................................................................................. 155
13.5.1 Macro Expansion........................................................................................................... 156
13.5.2 # and ## Operators ..................................................................................................... 157
13.6 Conditional Source Code ..................................................................... 157
13.6.1 #if and #endif................................................................................................................ 157
13.6.2 The defined( ) Function................................................................................................ 158

viii
Table of Contents

13.6.3 The #else and #elif Directives ....................................................................................158


13.6.4 #ifdef and #ifndef .........................................................................................................159
13.7 Producing Error messages ...................................................................159
13.8 Defining Target Hardware ...................................................................160
13.9 In-line Assembly Language..................................................................160
13.9.1 The #asm and #endasm Directives............................................................................160

14. Libraries 161


14.1 Portable Device Driver Libraries ..........................................................161
14.2 An Example Development Scenario.....................................................162
14.2.1 How SPI Works .............................................................................................................163
14.2.2 SPI_set_master(ARGUMENT);.................................................................................164
14.2.3 SPI_send_rec(0,4); .........................................................................................................166
14.3 Device Driver Library Summary...........................................................168

15. Sample Project 169


15.1 Project Specifics ....................................................................................169
15.2 Project Foundations..............................................................................169
15.2.1 Asynchronous.................................................................................................................169
15.2.2 SCI ....................................................................................................................................170
15.2.3 RS-232..............................................................................................................................170
15.3 Electrical Specifications .......................................................................171
15.4 PIC Implementation.............................................................................171
15.4.1 Anatomy of a PC serial port.........................................................................................171
15.4.2 A Note On Chip Sets ....................................................................................................172
15.4.3 IRQ...................................................................................................................................172
15.5 Programming Interrupts.......................................................................177
15.6 The Sample Project Code .....................................................................179
15.6.1 PIC16C74 Code..............................................................................................................179
15.6.2 PC Code...........................................................................................................................180

ix
Table of Contents

16. C Precedence Rules 185


17. ASCII Chart 187
18. Glossary 189
19. Bibliography 197
20. Index 198

x
Table of Examples
Example 1: Defining ports with #pragma directives.............................................................17
Example 2: Using a union structure to create a scratch pad.................................................28
Example 3: Using globally allocated data space in a function ..............................................29
Example 4: A typical assembly language program for the COP8SAA................................49
Example 5: Program in Example 4 compiled for the 68HC705C8 .....................................49
Example 6: A typical microcontroller program ......................................................................55
Example 7: Syntax for the main( ) function ............................................................................59
Example 8: Using the C assignment statement.......................................................................60
Example 9: The if statement syntax..........................................................................................61
Example 10: Nesting if and while statements .........................................................................62
Example 11: Calling one function from another ....................................................................62
Example 12: C functions containing inline assembly language ............................................64
Example 13: Common C keywords..........................................................................................66
Example 14: Using braces to delineate a block.......................................................................70
Example 15: The while loop......................................................................................................70
Example 16: Declaring variable types ......................................................................................72
Example 17: Assigning a character value.................................................................................76
Example 18: Octal, hex and binary notation...........................................................................79
Example 19: Data type modifiers..............................................................................................80
Example 20: Postfix and prefix unary operators ....................................................................85
Example 21: Sample binary operators......................................................................................85
Example 22: Trinary conditional operator...............................................................................86
Example 23: Combining operators in a statement .................................................................86
Example 24: Concatenating expressions with the comma operator....................................87
Example 25: Combining assignment operators in statements..............................................87
Example 26: Addition, subtraction and multiplication operators ........................................88
Example 27: Division and modulus operators........................................................................88
Example 28: Differentiating the division and modulus operators .......................................88
Example 29: Prefix and postfix notation for increment and decrement.............................89
Example 30: Postfix increment and decrement ......................................................................89
Example 31: Using prefix increment and decrement.............................................................90
Example 32: Variations on the assignment statement ...........................................................91
Example 33: Defining constant values for true and false......................................................91
Example 34: Defining constant values for true and false in a portable way.......................92

xi
Random documents with unrelated
content Scribd suggests to you:
noise was deafening, but they plodded on. So steady was the
behaviour of all ranks that General Ponsonby afterwards issued a
special order of the day, stating that the 4th Battalion had come up
to his support as steadily as if it had been on parade. It suffered 30
casualties, which, in view of the amount of shell-fire, may be
considered astonishingly light.
The following graphic description of these two days was written
by Captain M. Chapman in a sketch entitled “Intelligence,” which he
began, but which he never lived to finish.
“On the morning of the — the Battalion marched up a long
wet pavé road in the direction of the gun-flashes and the
Véry Lights, whilst the Battalion ‘drums,’ somewhere in the
dark, played the tune that Grenadiers call their own, and the
C.O. in silence watched his men file by. The test of discipline
and training had begun. The figures of the men looked tall
and grim, magnified by the shadows cast from the shrouded
lanterns of the motor-lorries. The night was dark, and a
driving rain soon soaked the tramping men. In an hour’s time
you could see by the light of a torch a mist rising from the
soaked and perspiring humanity in front.
“A halt was called and men were detailed to pick up
bivouac-sheets and petrol-tins of water. The already heavy-
laden troops moved on again more slowly with their increased
burden, along slippery wooden tracks laid across a field of
mud. Another halt. An officer appeared, dripping with
moisture, accompanied by guides who took charge of the
companies and allotted them their area in which to bivouac.
“To-morrow was zero day, not for the 4th Battalion, but for
some one else. If some one else failed, then the Grenadiers
would have to put matters straight; that is to say, the
Grenadiers were in reserve. The Intelligence Officer gave one
last look at the inky darkness, and going down on hands and
knees crawled into a long, low-arched dug-out. Sleeping men
sprawled across the floor, while at the farther end a solitary
candle burned. Picking his way across the recumbent figures
he saw the Commanding Officer lying on his back, his head
propped against a pack, silently smoking a cigarette and
thinking. The Intelligence Officer lay down by his side, and,
watching the Adjutant writing orders and speaking down a
telephone, fell into a fitful sleep.
“Zero hour for some one else left him cold, unmoved. The
accustomed environment of war and great fatigue dull the
sensibility of man. The steady roar of countless guns was a
pleasing murmur as of rippling water in his sleepy brain.
“A ray of sunlight struggled through the narrow entrance
of the dug-out, and the sleeping mass of humanity near the
door stirred uneasily. The Intelligence Officer shivered, and,
cautiously rising into a stooping posture, crawled out into the
open air. The sun was trying to pierce a passage through the
heavy ground-mist. The troops were cooking their breakfast
and beating their chests with a flapping motion to restore the
circulation in their half-frozen limbs.
“On a modern battlefield, lines of wooden ‘duckboards’ run
like arteries across the trackless waste towards the front. Up
the arteries flow fresh men, new blood, human forms
complete; food to support life, ammunition to destroy it.
Down the arteries flow ghosts of what yesterday were men,
with tissues torn, and muscles rent; gibbering prisoners and
men who have been spared to be shattered another day.
“An artery passed the dug-out door. The Intelligence
Officer observed the circulation to and from the battlefield,
and speculated on the fate of the tide going up, watching the
expression on the faces of the advancing and receding
groups. The men lazily watched the passing tide, exchanging
jokes with friends going either way. Prisoners alone excited
interest, but not sufficient to make men move more than a
few yards from where they stood.
“French gunners in a wood near by ran hotfoot to see each
band of prisoners pass, but our men with British phlegm
stayed where they stood, and eyed the foe with casual
glance. The passing wounded drew no expression of pity from
the onlookers, nor did the fate of the ingoing tide even raise a
questioning expression on their faces. This was the last spot
where selfishness still reigned supreme—the fringe of the
battle. Death and danger were not sufficiently close to draw
out the best in man; he behaved as he did in civil life—each
man for himself and the devil take the hindmost.
“The men who marched up the endless ribbon to the front
looked just like other men, and anxiety for their own safety
left no trace in their expression. They might have been the
crowd that streams through the factory gates in the early
morning. The outgoing men were different. They hastened by
and looked neither to the left nor right. They felt that fate
had been too good to them and that it might change its mind
and rend them if they loitered by the way. They had reached
the fringe where the ‘Ego’ was whispering in their ears with
insistent voice. They were alive; the others—they might be
dead—what matter? They were alive.
“The wounded stared in front of them, except those in
pain, and the prisoners looked cowed and miserable. The
escorts walked with jaunty air, rifle slung, bayonets fixed, and
exchanged jokes with all who would pay attention. The
feeling of victory was still in their veins, for the slouching
prisoners spurred their pride of race; were they not the
symbol of all their friends ‘up there’ had done?
“The stretcher-bearers, intent on their work, passed the
fringe of selfishness untouched. The bond of pain and
suffering held them fast in unselfishness until the moment
when they delivered their charge to the clearing-station in the
rear. While other men hurried from the battlefield, these
slowly and with aching arms and legs carried their burdens
carefully. Human suffering must touch some special chord of
self-sacrifice in man. Duty, discipline, and other self-taught
virtues would never produce that careful studied plod of the
stretcher-bearer under heavy shell-fire, or those deliberate
halts to attend to their patients’ needs.
“Thus the second day passed. The Grenadiers were not
called upon, but sat in the pit and watched the puppets
moving on and off the stage. The Intelligence Officer had the
critic’s box and made his notes. The night passed quietly and
slowly, the news filtered back that our friends in front had
taken all their objectives and that all went well. The morning
brought the fateful news that the 4th Battalion was under
orders to take over the front line that night, and afterwards to
attack. Every one was busy, even the Intelligence Officer, and
the passing puppets moved unnoticed. The 4th Battalion
prepared to leave the pit and occupy the stage.
“The third day passed quickly in preparation. At 4.30 in the
afternoon the first platoon stepped on to the wooden
pathway and moved up towards the front. The Intelligence
Officer started last, with Battalion Headquarters, while the
Commanding Officer and Adjutant and orderlies plodded off
alone. The sun had set and it was growing dark. That ribbon
of wood which led to the unknown had its advantages, for it
gave a hard, though slippery, foothold; but, once you stepped
upon it, you became its slave. The Path began to assume a
sinister character, when ahead you saw it lead into a wood
full of bursting shells. Then it took the form of an endless
moving staircase, surely leading to destruction. The serpent
of men moved into such a wood. The very name it bore was
ominous. No one spoke. The Intelligence Officer noticed his
throat was very dry. His heart pumped at the scream of each
arriving shell. He continued to move forward as in a dream.
At intervals he made way for stretcher cases. The flash of the
bursting shells disclosed a row of gun-emplacements. Two
gunners pinned under an overturned carriage screamed.
“Still Battalion Headquarters moved on—out of the wood
into the open—away from death to what seemed like security.
An odd shell or two burst near the path, while others shrieked
their way overhead, dealing death somewhere behind. The
mind neglected the latter, focussing all attention on the
former. The pathway crossed two streams. By now the
darkness was complete. A snorting, sobbing noise came from
somewhere in front, succeeded by a splashing sound. The
path went by a dark and slimy pool, in which the head and
ears of a bogged horse waggled this way and that
pathetically. Then all was still. A man’s figure could be dimly
seen attempting to cut off the pack saddle before it was
buried in the slough.
“The wooden track abruptly ended. A white tape feebly
glimmered in the dark, hanging loosely between upright iron
stakes, rifles driven muzzle down into the sodden soil, and
portions of broken branches.
“The Intelligence Officer seized the tape and floundered
slowly on. The men behind him breathed heavily, and in quiet
tones cursed the water and the mud, the tape and the hand
that laid it. Some one tripped. A halt was called. The
obstruction proved to be a comrade, some flotsam from the
men ahead. He was alive, warm, but inarticulate. A sergeant
felt him over in the dark. Some one said, ‘My Gawd, Sir, ’e’s
got it through the throat.’ The Intelligence Officer spoke
words of promise to the man and left him there. ‘Outgoing
troops would pick him up,’ and other well-worn words of
comfort, although he knew they might not see him. He felt he
was leaving him to die. This is war.
“The tape suddenly ended. Heaps of broken stone
disclosed the close proximity of a concrete dug-out. A guide
cautiously felt his way into the darkness and presently led the
Intelligence Officer down some steps below the ground. At
the foot of the steps hung a soaking blanket, behind which a
light glimmered feebly. The Intelligence Officer cautiously
pulled the blanket to one side, and blinked at the group
inside. Two Commanding Officers and two Adjutants were
talking. ‘Handing over’ was in process. The outgoing were
clearly anxious to be gone; the incoming were anxious not to
let them go without knowing what lay before them.
“A succession of officers and orderlies peered through the
doorway, saluted and uttered the magic words, ‘Relief
complete, Sir,’ and vanished into the outer darkness. Their
strained expressions did not belie the full meaning of the
sentence. The outgoing C.O. pushing back his chair with a
scraping noise said, with a half-apologetic air, he would be off,
and he and his satellites vanished. He had laid down his
burden; the 4th Battalion had assumed it. His footsteps
sounded light and care-free as they died away.
“All that night officers and men groped their way through
mud and filth, visiting outposts, distributing rations, each bent
on a mission involving the safety and comfort of the other.
The Intelligence Officer felt that the atmosphere had
changed. The Commanding Officer could have reclined on the
German bed in the dug-out, his feet out of the six inches of
liquid slush. Actually he spent his time going round the line,
four hours of intense physical strain. Shells and bullets do not
sound more pleasant because it is dark.
“The Transport Officer might have dumped the rations
beyond the barrage and returned to the security of the horse-
lines, and the warmth of his valise. As a matter of fact, he led
his struggling animals up a broken, shattered road, through
the barrage, round the trunks of fallen trees, and delivered
his consignment at B.H.Q. The Adjutant might have said with
reason that the ration parties had lost their way, that
conditions were impossible, but the Intelligence Officer
watched him supervise everything in person—in the open.
Before dawn the front line was rationed—every post
established, no chances taken. The Intelligence Officer saw it
all and said: ‘If this is war, some parts of it at least are good.’
“At dawn the next morning he arose and stood shivering in
the cold mist. He visited his observation-post, and, watching
trenches through his telescope as the sun slowly made its
way through the haze, he smiled as he recognised well-
known N.C.O.’s and men moving about in the nonchalant
manner which all assume before the sniper starts his work,
and when tired gunners take their rest. He knew that later he
might search for hours and find no movement; all would be
hiding in their shell-hole lairs.
“A distant hum reminding him of some gigantic insect,
drew his attention from his work, and two aeroplanes
appeared, flying very low. In a few minutes the moving
figures vanished from the field of view of his telescope. The
earth swallowed them up. Then commenced manœuvres that
reminded him of sparrow-hawks quartering their haunting
ground for prey. The droning insects flew back and forth. No
movement was visible on the ground. A hooded head looked
over the fuselage of each machine. The Iron Cross showed
clearly on the wings. Then warning lights were dropped from
each machine. Each light marked the position of a trench and
seemed to say, ‘Eat, drink, and be merry, for soon you will
die.’ The whole proceeding revolted the men watching from
the O.P. They knew the full intent of it. Their imagination
heard the scream of the shells which would surely fall where
the lights had dropped. They felt for their friends out there.
Discovered by their enemies, the hiding men used their
weapons viciously. The rattle of machine-guns and rifles was
mixed with the drone of the aeroplanes. The pilots knew their
work was done. They turned to fly. One of them staggered in
his course. The Intelligence Officer watched the machine
crash in flames in a distant forest. The hiding men in their
shell-holes sat down to wait for the punishment that they
knew must come. The Intelligence men watched great spouts
of earth rise skywards and listened to the rending crash that
came slowly across the intervening space. They longed to
help; instead they noted the time and place and entered the
information in their Intelligence report.
“Zero was set for 5 A.M., this time a zero that concerned
the 4th Battalion alone. The Commanding Officer and the
Intelligence Officer moved forward through the darkness to
an advanced position at three o’clock in the morning. Here
the nerve centre of the 4th Battalion was established. Here
would enter the news of battle. The Intelligence Officer
established himself in a corner of the new dug-out. His
carrier-pigeons made little noises to themselves, while the
telephone operators tested and re-tested their lines. The
Intelligence Officer’s hand kept wandering to his watch. The
Commanding Officer snored. His plans had been truly laid;
interference now would be fatal. He was a well-trained
soldier, and he slept.
“Five minutes before zero the Intelligence Officer woke the
Commanding Officer, and both waited for the well-known
throb of innumerable guns. One of them at least thought of
his friends waiting to follow up the moving death. What were
those others, his enemies, doing? Did they realise what hell
would break upon them? Did they suspect the impending
stroke?
“The blow fell to the minute. The dug-out rocked. A sheet
of flame lit up the sky. A thousand devils seemed to be
forging a red-hot band on the earth as far as the eye could
see. Their countless hammer-strokes were merged into one
loud growling, rumbling noise. Gradually the ear became
accustomed to the sound and detected the sharp crack of
answering bullets and the rattle of machine-gun fire. Dawn
was breaking and eyes were strained to pierce the half-light.
Minutes seemed like hours.
“The first messenger arrived at the nerve centre. He
brought good news. Others followed. All reported success.
The Intelligence Officer took out one of his pigeons, attached
a message to its leg, and released it. He noticed how clumsy
his handling of the bird had become. The pigeon circled once
and flew straight as an arrow in the right direction. This was
dramatic, exciting, the cream of war. Then came the sordid
side.
“The enemy artillery awoke. Great shells came hurtling
through the sky.
“The shelling grew less. The machine-gun fire died away.
The enemy was accepting the new situation. We had won; he
had lost. Both sides prepared to settle down where they
found themselves, too tired to prolong the struggle.
“The Commanding Officer was satisfied with the position.
Emerging cautiously from its shelter, the party moved back to
the original Battalion Headquarters. As they passed the
trenches and the scooped-out holes in which the supports
sheltered, inquiries were made as to casualties, and brave
words spoken to cheer the exhausted men. The Intelligence
Officer, ruminating on death, saw many signs of it. The true
value of the body in which for a short period resides the soul
of man was brought home to him. Three men crouched in a
trench. Two were cooking; some conversation was in
progress. The third man sat by their side and took no part.
He seemed by his attitude to be thinking deeply, immersed in
the solution of a problem. His face was turned away. The
attitude was one of puzzled thought.
“The Intelligence Officer made inquiries as to how they
had fared. Two of the men looked up; they gave him a
friendly smile and told him all they knew. The other sat with
his head bent, still studying that inscrutable problem. The
Intelligence Officer noticed with a start the colour of his ears,
how wax-like in appearance; then he knew in a flash—the
man was dead. His comrades did not even explain the fact.
They seemed to realise that the figure by their side no longer
counted, that the soul and personality were fled, that there
was nothing dreadful in the husk that sat there and still
seemed one of them. War had taught them what a small
thing the body really is, what a matter of indifference whether
it is smashed or not. They had learned one thing at least—the
proportionate value of the body and the soul.
“That night the 4th Battalion handed over its burden to
some one else. It was due to be relieved. The Chaplain had
arrived to see to it that the brave dead had decent burial.
When it was possible, the Grenadiers always carried down
their dead, so that in the future, grouped together, they
would stand as a memorial of the cause they fought for, and
indicate plainly to future generations how Grenadiers could
fight and die—a monument to the power of discipline, self-
sacrifice, and pride of race.”
No. 1 Company under Captain Sloane-Stanley, No. 3 under
Lieutenant Nash, and No. 4 under Captain Paton, dug themselves in
with entrenching tools along the Anneux chapel—Mœuvres road,
while No. 2, under Captain Britten, was placed in Anneux chapel
itself. The shelling was very violent, and all the roads, by which
supplies and supports had to move, were accurately and persistently
shelled. The Brigadier, Lord Henry Seymour, came along, quite
unconcerned and not even wearing a helmet, to see how these
companies were getting on, and told them they might have to move
up later into Bourlon Wood. When it got dark snow began to fall,
and it became bitterly cold. The position of a lent battalion is by no
means an enviable one, and soon orders and counter-orders from
different authorities succeeded each other with amazing rapidity.
Finally definite orders were sent to the Battalion to take up a
position in Bourlon Wood, and at the same time it was placed under
the orders of the 186th Brigade. While this move was being carried
out, Lieutenant Nash was wounded in the leg and sent back to the
dressing-station. In order to keep in touch with the 186th Brigade,
Second Lieutenant Tuckwell was sent to Graincourt to act as liaison-
officer to General Bradford, V.C.
Bourlon Wood, which covers about 100 acres, might well have
been a typical English covert, with its tall trees interspersed with
undergrowth about eight feet high. The line to be held consisted of a
road running north and south, parallel to the front line. The ground
was soaking wet, and the men had to force their way through the
dripping leaves and lie out in the wood with no protection of any
kind. Digging through the stubborn soil and soaking undergrowth
was no easy matter with light entrenching tools, but they soon
produced some sort of cover. The Fortieth Division, however, had
succeeded in its attack, and so there was nothing for the 4th
Battalion to do but to remain in the wood where it was. In the
evening, much to the satisfaction of every one, it reverted to the
command of the Guards Division. Lieutenant Ingleby, the acting
Quartermaster, arrived at Battalion Headquarters at 11 that night,
having guided the transport up to Anneux chapel through intense
shelling, and reported that Second Lieutenant N. A. Pearce, the
transport officer, who had shown great determination and pluck in
his efforts to bring all that was wanted up to the men in the
trenches, had been killed by a shell. Major-General Feilding received
the following message from Major-General Ponsonby:
I wish to express on behalf of my Division my sincere
thanks for the support given us on the 24th and 25th by the
Battalions of the Guards Division placed at my disposal for the
defence of Bourlon Wood, namely the 2nd Battalion Scots
Guards and 4th Battalion Grenadier Guards.
I should like to bring to your notice particularly the 2nd
Battalion Scots Guards, who throughout the period prevented
the enemy from breaking through the right flank of the
position, and assisted in repelling at least two of the enemy’s
counter-attacks. I enclose extracts from the report of the
Brigadier-General commanding the 119th Infantry Brigade:
“The 2nd Battalion Scots Guards reinforced the firing line,
which had become very thin, early in the morning of
November 25, and remained in action until they came under
the orders of the 186th Infantry Brigade on the night of 26-
27th November. All ranks behaved with the utmost gallantry,
and assisted to repel at least two German counter-attacks in
addition to continual enemy pressure. They inspired all with
great confidence.
“The 4th Battalion Grenadier Guards came under my
command in the afternoon of the 25th inst. To reach a
position of readiness it had to cross the open in artillery
formation for a great distance under enemy observation, and
were heavily shelled in so doing. The men were as steady as
if on parade. To the above-mentioned units I wish to express
my gratitude.”
Nov. 26. The next day passed quietly, and the company
commanders were able to go in turn to Battalion
Headquarters to have some rest. In the evening snow fell heavily,
and the men had a cold and uncomfortable night. The 4th Battalion
was again to be lent to another brigade, that of General Sergison-
Brooke, who received orders to attack Fontaine. It was not actually
wanted for the attack, but merely to form a defensive line, on which
the assaulting waves could fall back in case of failure.
The enemy put down a heavy barrage on the whole line that
night, and Lord Gort sent Captain Chapman to inquire from the 2nd
Battalion Irish Guards what was happening, but it proved to be
merely the outcome of nervousness on the part of the Germans, and
no attack developed. The Battalion moved off at 5.30 A.M., to take
up new positions facing east instead of north, at very short notice;
and, as the night was very dark and wet and the enemy was so
close, the advance into position required some care. In order to
prevent any confusion in the jumping-off line, the Battalion was told
to occupy a position immediately in rear of the line, and to move up
in the line only when the attack had actually started.

Attack on Fontaine
Nov. 27. In a drizzle of rain, and under an intense enemy barrage,
the attack of Sergison-Brooke’s Brigade started at 6.30 in the
morning of the 27th. It reached its objective, but the cost was so
great, that the survivors found it impossible to maintain the position
they had so dearly gained, without reinforcements. So weak were
the attacking battalions, that they were in danger of being
overwhelmed by counter-attacks. While the 4th Battalion was
waiting for orders about 10 A.M., the German counter-attacks began
to develop, and fire from the left became very heavy. No. 2
Company under Captain Britten was sent off to secure the left flank
of the Division, which seemed to be in a dangerously weak
condition. As they came up Second Lieutenant Windeler was killed
by a sniper, and Captain Britten himself was wounded in the arm by
a rifle bullet. Soon afterwards Second Lieutenant Oliver, who was
now in command of No. 3 Company, was severely wounded in the
chest, arm, and foot, while going out to bring in a wounded Irish
Guardsman. The casualties among other ranks were proportionately
heavy.
A warning order arrived from Brigadier-General Sergison-Brooke
at 10.30 A.M., preparing the Battalion to supply two companies for
the support of the 3rd Battalion Grenadiers and 1st Battalion
Coldstream, but it seemed doubtful whether a couple of companies,
or even four, would be of any use in the circumstances. Captain
Gerard, the Adjutant, reported that he had heard from Captain Paton
that already the 2nd Guards Brigade was falling back to the original
line.
Lord Gort went off at once with Captain Chapman to the
headquarters of the 3rd Battalion, and discussed the new situation
with Colonel Thorne. They decided that it would be inadvisable, in
view of the enemy’s strength, and the absence of any appreciable
reserves on our side, to renew the attack, and so use up the 4th
Battalion with small chance of success. Orders were accordingly
issued for the original line now held by the 4th Battalion to become
the line of resistance, under the command of Captain Paton and
Captain Sloane-Stanley. That night the 4th Battalion was relieved,
and returned to the Hindenburg line at Flesquières.
Nov. 28. On the 28th it marched to Trescault, and pitched a camp
on the open ground between the Trescault—Metz road and
Havrincourt Wood. The enemy’s aircraft left them no peace, and so
the tents were struck the next morning, and pitched again in
Havrincourt Wood. The undergrowth was thick, and the cutting of it
took some time, but when the camp was finished it proved snug and
sheltered.
Attack on Fontaine
November 27. 1917.

Nov. 30. The officers had just finished breakfast on the 30th, and
were about to inspect their companies, when the news
arrived that the Germans had broken through the line near
Gonnelieu. It was said that the enemy had been seen marching in
fours through Gouzeaucourt. Immediately orders were given for the
Battalion to be ready to start at a moment’s notice. Although the
men had expected a quiet day, and were quite unprepared, so
perfect were the organisation and discipline that in half an hour’s
time the Battalion was ready to move off.
Lord Gort’s orders were to concentrate on Metz, and accordingly
the Battalion moved off in that direction. The road was full of
transport moving in the opposite direction, and with it ran a stream
of men looking strangely unlike British soldiers, with no rifles or
equipment—wounded and unwounded with incoherent stories,
officers half-undressed, gunners with breechblocks in their hands, all
with a hunted look. Some high-explosive shells came streaming over,
and pitched not far from the road. Lord Henry Seymour with his
commanding officers rode on ahead to try and glean some
information, while the four battalions of his Brigade marched
through Metz, past the beetroot factory and on to the open ground
beyond, where they lay down and waited.

Attack on Gonnelieu
About 2.30 P.M. the whole Brigade, in artillery formation, moved
off in the direction of Gouzeaucourt, and in the meantime the attack
of De Crespigny’s Brigade had been completely successful and
required no reinforcements. The direction of the march was
consequently slightly changed. The 4th Battalion crossed the
Trescault—Gouzeaucourt road, where, thanks to Lieutenant Ingleby,
the cookers arrived, and the men were provided with hot food. That
night General Walker, commanding the 16th Brigade of the Sixth
Division, held a conference at the 4th Battalion Headquarters. His
object was to ensure that the 4th Battalion understood his scheme
of attack, for if his brigade failed it would have to carry out his plan.
The hurried manner in which the attack was planned, and the
obviously scanty information on which the plan was based, seemed
to indicate that it was not likely to succeed. At 1 A.M. a warning order
was issued to the effect that Seymour’s Brigade would assault
Gonnelieu, if the attack of the 16th Brigade failed. Lord Gort
thereupon wrote out his orders with the very meagre information at
his disposal.
To have to select a definite objective after dark made things very
difficult, since the final disposition depended upon the attack of the
16th Brigade, and whatever happened an indefinite front line would
be the result. If the 16th Brigade succeeded, Seymour’s Brigade
would simply relieve it, but if it failed the attack would have to be
attempted a second time. These considerations alone made it
necessary to work out alternative schemes. Lord Henry Seymour
fortunately prepared a detailed plan for the worst event, and fully
realised that his Brigade was to be employed in a manner generally
accepted as impossible, except in a great emergency, involving the
advance of infantry, unsupported by artillery, across the open against
an enemy occupying trenches, and houses bristling with machine-
guns.
The following officers took part in the attack on Gonnelieu:

Lieut.-Colonel Viscount Gort, Commanding


D.S.O., M.C. , M.C. Officer.
Major W. S. Pilcher, D.S.O. 2nd in Command.
Capt. C. R. Gerard Adjutant.
Capt. M. Chapman Intelligence Officer.
Capt. H. H. Sloane-Stanley No. 1 Company.
Lieut. C. E. Irby ” ”
2nd Lieut. J. M. Chitty ” ”
2nd Lieut. B. J. Hubbard, M.C. No. 2 Company.
2nd Lieut. R. C. Denman ” ”
2nd Lieut. D. E. A. Horne ” ”
Capt. J. B. M. Burke, M.C. No. 3 Company.
Lieut. the Hon. A. H. L. Hardinge ” ”
Lieut. L. R. Abel-Smith ” ”
Capt. G. H. T. Paton, M.C. No. 4 Company.
Lieut. B. C. Layton ” ”
2nd Lieut. J. J. M. Veitch ” ”

When the news of the failure of the 16th Brigade’s attack reached
Lord Gort, he at once started off with the Battalion, and crossed the
Villers Plouich road. On reaching the railway the companies
extended, and dug themselves in. There they waited in the dark for
zero hour.
The order of battle for Seymour’s Brigade was as follows: The 1st
Battalion Welsh Guards on the right and the 4th Battalion Grenadiers
on the left were to undertake the attack. The 1st Battalion
Grenadiers was in support on the left, and had to protect the left
flank as the attack advanced, while the 2nd Battalion Scots Guards
had already occupied the high ground about Villers Plouich. In the
4th Battalion No. 2 Company under Second Lieutenant Hubbard on
the right and No. 3 under Captain Burke on the left formed the first
line. No. 4 Company under Captain Paton was in support, and No. 1
under Captain Sloane-Stanley formed the reserve. Captain Chapman
was sent forward to establish a forward Battalion Headquarters.
Dec. 1. Without any artillery preparation the attack started at 6.30
A.M. It was still fairly dark, but the Germans could see enough
to use their machine-guns with considerable accuracy. The line of
advance was over open ground, up a gentle slope leading to
Gonnelieu, and there was no cover or protection of any kind for the
attackers. On came the leading companies of the 4th Battalion in
perfect order. The men never wavered for an instant, though they
knew that they were to be sacrificed to save the situation. They all
understood that the rules of modern warfare were to be defied, and
that instead of following a creeping barrage they were to advance
across the open, with not even a preliminary bombardment. Though
they knew this, they never faltered.
The enemy’s machine-gun fire when it broke over them was
terrible, like a driving hailstorm, but the pace was never checked for
a moment. Especially on the right the fire was terrific, and No. 2
Company, which had gone rather too far in that direction, suffered
heavy losses: one platoon was practically wiped out. Second
Lieutenant Hubbard himself was killed, and Second Lieutenant
Denman was mortally wounded, gallantly attempting to silence a
German machine-gun, while Second Lieutenant Horne was also
wounded. No. 3 Company under Captain Burke maintained its
direction, and had few casualties until it came up close to the village.
On reaching a road running in the direction of Vacquerie, it had to
pause for a moment to allow No. 4 to come up before continuing its
advance. Second Lieutenant Veitch had his thigh smashed by a
bullet, and fell back into a shell-hole. Almost simultaneously a man
shot through the head fell on the top of him, and being too weak to
move the dying man, for twelve hours he remained in this cramped
position.
The left of the line met with less resistance than the right, and so
got far in advance. No. 3 Company dashed forward into the outskirts
of Gonnelieu, but the village seemed almost impregnable against
infantry unsupported by tanks or artillery. A small enclosure
sheltered by ruined buildings was the only protected spot, the
ground all round it was swept by machine-gun fire, and of course
the shrubs and rank grass were no cover at all. Captain Burke
dashed in on the left, and penetrated into the eastern outskirts of
Gonnelieu, while Lieutenant Hardinge with a few men got round to
the north of the village, and brought up a Lewis gun to a position in
the cemetery. This had a most disconcerting effect on the enemy, for
it threatened his right flank, and enfiladed the troops opposing Nos.
2 and 4 Companies.
The Germans quickly grasped the fact that this movement on
Lieutenant Hardinge’s part required immediate action. They
managed to press back the troops on the left of the Brigade, with a
view of enfilading the cemetery. With great ingenuity they worked
round with their machine-guns, and soon Lieutenant Hardinge’s
position became untenable. All his men were killed or wounded with
the exception of Sergeant Hull. Then the gun jammed. There was
now nothing to be done but to get back as best he could, and being
luckily only slightly wounded, he was able to make his way back,
accompanied by Sergeant H. Hull.
Meanwhile Lieutenant L. Abel-Smith and Sergeant Williams went
down a line of huts to the right, to see if an advance could be made
in that direction, but were met with a withering fire from the right
flank. With two platoons they therefore advanced a short distance
down the centre of the village, but the enemy’s machine-gun fire
was so fierce that the ground over which they crawled was plastered
with bullets. Some men, who were creeping along behind a wall,
were killed by bullets which pierced the brickwork, and Lieutenant L.
Abel-Smith himself was wounded.
This most gallant attempt on the part of No. 3 Company to
capture the village resulted in such heavy losses that it was obvious
it would have to retire. A German counter-attack as it was
attempting to consolidate its position settled the matter. A certain
number of men managed to get back, but most of them were killed
or taken prisoners, including Captain Burke himself, who died
fighting to the last. The same fate befell Second Lieutenant Chitty,
who, with a party of No. 1 Company, had succeeded in entering the
village.
Captain Paton with No. 4 Company had the difficult task of
deciding what he should do, on reaching the trench in front of
Gonnelieu. No. 3 had gone on into the outskirts, and there was no
sign of the Welsh Guards on his right. It was obvious that his best
plan would be to hold the trench until the others came up into line,
so that at least those who had gone on would have a strong
supporting line to retire to. But there was a mixed medley of men on
his left, who seemed to be wavering in the face of the counter-
attack. Captain Paton thereupon leaped out of his trench, and ran
across the open, with machine-gun bullets ploughing up the ground
all round him. With almost reckless bravery he went from trench to
trench in full sight of the German machine-gunners, encouraging
these groups of men from various regiments. At first he seemed to
have almost a charmed life, and his splendid example inspirited all
who saw him. The situation was saved, and he fell soon afterwards
mortally wounded. For this conspicuous act of gallantry he was
posthumously awarded the Victoria Cross. Captain Gerard, the
Adjutant, who came up to obtain information for Lord Gort, found
that owing to Captain Paton’s efforts the left flank was secure.
It was now clear that without considerable reinforcements and
unlimited sacrifices the village could not be taken. The enemy’s
machine-guns were too strong. The Germans were counter-
attacking, and were able to overpower any parties that had gained a
footing in the village. Only one of the fourteen tanks that had been
expected appeared, and, although it was undoubtedly a great help
to the Welsh Guards, it was quite inadequate by itself. The Brigade
on the left and the Welsh Guards on the right had been held up, so
that even had the Battalion taken the village they would not have
been able to hold it. A German officer captured that day stated that
his battalion had attacked from behind Gonnelieu at 6 A.M., and as
our attack started at 6.30 they had been completely disorganised by
our advance, which they imagined was a counter-attack delivered
with amazing rapidity.
Captain Sloane-Stanley, who had come up with No. 1 Company,
determined to consolidate the trench immediately in front of
Gonnelieu, so that it might be held with what remained of the
attacking Companies. Lieutenant Irby of the same Company held a
block in the trench against persistent bombing attacks, and
eventually knocked out a German machine-gun by counter-bombing.
Lord Gort himself now came up to see exactly how matters stood,
and walked about, as he always did on such occasions, with an
absolute disregard for all danger. It was not long, however, before he
was severely wounded; the only wonder was that he had not been
hit before. There were many acts of individual bravery, and perhaps
the gallantry displayed by Sergeants Canham and Buckle was one of
the most conspicuous. At one time, when the enemy were advancing
dangerously near our line, these two sergeants left their trench, and
charged. The Germans, imagining that these two wore only the
foremost of a large party, fled in confusion.
Major Pilcher, who now assumed command of the 4th Battalion,
was confronted with a very difficult situation. The sadly depleted
ranks of the Battalion were holding the trench in front of Gonnelieu,
and there were only three officers left—Captain H. Sloane-Stanley,
Lieutenant Layton, and Lieutenant Irby. The tactical position was
hazardous in the extreme, for both flanks were in the air and
dangerously large gaps in the line seemed to invite a German attack.
When the troops on the left retired, Major Pilcher called on the 1st
Battalion Grenadiers to send up one Company to his assistance, and
Captain Rhodes was sent to form a defensive flank. Later, when
further assistance was required, two more Companies under Captain
Spence and Captain Lawford advanced down the sunken road, and
prolonged the line to the left. This timely assistance undoubtedly
saved the left flank of the 4th Battalion, and enabled it to maintain
its position.
Dec. 3. The line now formed a salient in front of Gonnelieu; the
apex being held by the 4th Battalion with some men of the
Northants Labour Battalion. On the left was the 1st Battalion
Grenadiers, which formed a defensive flank, while the Welsh Guards
écheloned back to the right. This position was maintained until
December 3, when the 4th Battalion was relieved by the 2nd
Battalion Scots Guards, which latter had been due the night before.
Owing to the delay the already exhausted officers and men had to
spend a further twenty-four hours in the trenches, exposed to a hard
frost. It was only through almost superhuman efforts that they
received their rations on the morning of the 2nd, as the failure to
relieve them had upset all arrangements for supply.
On the night of the 3rd they marched back, and bivouacked in
the open on some ground north of Gouzeaucourt Wood, where they
remained ready, in case their services should be required.
When the Guards Division left the area of operations near
Gouzeaucourt, the 4th Battalion proceeded to Etricourt, where they
entrained for Laherliere. Thence they marched to Gouy-en-Artois,
and were placed in comfortable billets in a château. On December
11 they proceeded to Dainville, where they remained till the end of
the month training. The weather became very cold and misty, and
later there was a good deal of snow. On the 23rd the following
officers joined the Battalion: Lieutenant F. C. Lyon, the Hon. C. C. S.
Rodney, Second Lieutenant B. R. Osborne, Second Lieutenant R. D.
Richardson, and Second Lieutenant C. J. Dawson-Greene.

The 1st Battalion


1st Batt. After the operations at Bixschoote in October, the 1st
Nov.
Battalion remained in billets at Zudroue, near Watten. During
this period the following officers joined the Battalion: Lieutenant I.
C. Gascoigne, Second Lieutenant D. B. Topham, Lieutenant R. D.
Lawford, Second Lieutenant A. H. Forbes, Second Lieutenant C.
Cruttenden, and Lieutenant H. G. Wiggins. Captain H. H. Castle,
R.A.M.C., also arrived to take the place of Captain P. H. Wells,
R.A.M.C. While the Battalion was at Zudroue, the Colonel of the
Regiment, Field-Marshal H.R.H. the Duke of Connaught, paid them a
visit.
On November 9 the move south began, and the 1st Battalion
marched to Enquin-les-Mines, continuing its march on the following
day to Fabain Palfart, and then on to Foolinricametz. Second
Lieutenant S. J. Hargreaves joined from the base on the 15th. The
march was continued on the 17th through Ivergny Pommier to
Achiet-le-Petit, where the men had twenty-four hours’ rest. The
greatest secrecy was preserved, and no orders were issued to the
Company Commanders till the last moment, though from the great
concentration of troops it seemed clear that some big move was
impending. The 1st Battalion was brought up in buses to Beaumetz-
les-Cambrai, and from there it marched with the rest of Seymour’s
Brigade to Flesquières. Though two Battalions of the Brigade were
sent up to support the Fortieth Division, which was taking Bourlon
Wood, the 1st Battalion did not take part in these operations. On the
night of the 27th the 1st Battalion Grenadiers and the 1st Battalion
Welsh Guards, assisted by two Companies from the 2nd Battalion
Coldstream Guards, relieved the 2nd Guards Brigade in the front
line. The following officers took part in these operations:

Lieut.-Colonel M. E. Makgill- Commanding


Crichton-Maitland, D.S.O. Officer.
Capt. L. G. Fisher-Rowe, M.C. Second in
Command.
Lieut. W. H. Lovell, M.C. Acting Adjutant.
Lieut. L. de J. Harvard King’s Company.
Lieut. J. A. Lloyd ” ”
2nd Lieut. J. H. Frere ” ”
Capt. A. T. G. Rhodes No. 2 Company.
2nd Lieut. L. G. Byng ” ”
2nd Lieut. E. G. Hawkesworth ” ”
2nd Lieut. W. U. Timmis ” ”
Capt. P. M. Spence, M.C. No. 3 Company.
Lieut. H. G. Wiggins ” ”
Lieut. S. J. Hargreaves ” ”
2nd Lieut. C. Cruttenden ” ”
Capt. R. D. Lawford No. 4 Company.
Lieut. the Hon. P. P. Cary ” ”
2nd Lieut. C. C. Mays ” ”
Lieut. N. G. Chamberlain ” ”
Capt. H. H. Castle, R.A.M.C. Medical Officer.

Conditions were favourable for carrying out the relief, and the
next day passed without incident, although the enemy continued to
shell the valley south of Bourlon Wood. On the evening of the 28th
the 3rd Guards Brigade, having been relieved by the Fifty-ninth
Division, marched to the reserve trenches south-west of Ribecourt.
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

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

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebookball.com

You might also like