Assembly Language Programming ARM Cortex M3 1st Edition Mahoutpdf download
Assembly Language Programming ARM Cortex M3 1st Edition Mahoutpdf download
or textbooks at https://ebookultra.com
https://ebookultra.com/download/assembly-language-
programming-arm-cortex-m3-1st-edition-mahout/
https://ebookultra.com/download/modern-assembly-language-programming-
with-the-arm-processor-1st-edition-larry-d-pyeatt/
https://ebookultra.com/download/professional-assembly-language-
richard-blum/
https://ebookultra.com/download/assembly-language-
for-x86-processors-6th-edition-kip-irvine/
https://ebookultra.com/download/assembly-language-
for-x86-processors-6th-edition-edition-kip-r-irvine/
Introduction to 80X86 Assembly Language and Computer
Architecture Richard C. Detmer
https://ebookultra.com/download/introduction-to-80x86-assembly-
language-and-computer-architecture-richard-c-detmer/
https://ebookultra.com/download/programming-language-fundamentals-by-
example-1st-edition-d-e-stevenson/
https://ebookultra.com/download/programming-language-pragmatics-2nd-
edition-michael-l-scott/
https://ebookultra.com/download/the-java-tm-programming-language-4th-
edition-ken-arnold/
https://ebookultra.com/download/the-scheme-programming-language-
fourth-edition-r-kent-dybvig/
Assembly Language Programming ARM Cortex M3 1st
Edition Mahout Digital Instant Download
Author(s): Mahout, Vincent
ISBN(s): 9783420120053, 1848213298
Edition: 1
File Details: PDF, 4.06 MB
Year: 2013
Language: english
Assembly Language Programming
Assembly Language
Programming
ARM Cortex-M3
Vincent Mahout
First published 2012 in Great Britain and the United States by ISTE Ltd and John Wiley & Sons, Inc.
Apart from any fair dealing for the purposes of research or private study, or criticism or review, as
permitted under the Copyright, Designs and Patents Act 1988, this publication may only be reproduced,
stored or transmitted, in any form or by any means, with the prior permission in writing of the publishers,
or in the case of reprographic reproduction in accordance with the terms and licenses issued by the
CLA. Enquiries concerning reproduction outside these terms should be sent to the publishers at the
undermentioned address:
www.iste.co.uk www.wiley.com
The rights of Vincent Mahout to be identified as the author of this work have been asserted by him in
accordance with the Copyright, Designs and Patents Act 1988.
____________________________________________________________________________________
Library of Congress Cataloging-in-Publication Data
Mahout, Vincent.
Assembly language programming : ARM Cortex-M3 / Vincent Mahout.
p. cm.
Includes bibliographical references and index.
ISBN 978-1-84821-329-6
1. Embedded computer systems. 2. Microprocessors. 3. Assembler language (Computer program
language) I. Title.
TK7895.E42M34 2012
005.2--dc23
2011049418
Printed and bound in Great Britain by CPI Group (UK) Ltd., Croydon, Surrey CR0 4YY
Table of Contents
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix
Appendices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199
Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241
Preface
To be able to plan and write this type of book, you need a good work
environment. In my case, I was able to benefit from the best working conditions for
this enterprise. In terms of infrastructure and material, the Institut National de
Sciences Appliquées de Toulouse, France (Toulouse National Institute of Applied
Sciences), and in particular their Electrical and Computer Engineering Department,
has never hesitated to invest in computer systems engineering, so that the training of
our future engineers will always be able to keep up with rapid technological change.
I express my profound gratitude to this institution. These systems would not have
amounted to much unless, over the years, there was an educational and technical
team bringing their enthusiasm and dynamism to implement them. The following
pages also contain the hard work of Pascal Acco, Guillaume Auriol, Pierre-
Emmanuel Hladik, Didier Le Botlan, José Martin, Sébastien Di Mercurio and
Thierry Rocacher. I thank them sincerely. Two final respectful and friendly nods go
to François Pompignac and Bernard Fauré who, before retirement, did much work to
fertilize this now thriving land.
It is possible to program directly in machine language – that is, to write the bit
instruction sequences in machine language. In practice, however, this is not realistic,
even when using a more condensed script thanks to hexadecimal notation
(numeration in base 16) for the instructions. It is therefore preferable to use an
assembly language. This allows code to be represented by symbolic names, adapted
to human understanding, which correspond to instructions in machine language.
2 Assembly Language Programming
Assembly language also allows the programmer to reserve the space needed for the
system stack and data areas by giving them an initial value, if necessary. Take this
example of an instruction to copy in the no. 1 general register of a processor with the
value 170 (AA in hexadecimal). Here it is, written using the syntax of assembly
language studied here:
The assembler is a program responsible for translating the program from the
assembly language in which it is written into machine language. Upon input, it
receives a source file that is written in assembly language, and creates two files: the
object file containing machine language (and the necessary information for the
fabrication of an executable program), and the printout assembly file containing a
report that details the work carried out by the assembler.
This book deals with assembly language in general, but focuses on processors
based on Cortex-M3, as set out by Advanced RISC Machines (abbreviated to ARM).
Different designers (Freescale, STmicroelectronics, NXP, etc.) then integrate this
structure into μcontrollers containing memory and multiple peripherals as well as
this processor core. Part of the documentation regarding this processor core is
available in PDF format at www.arm.com.
ARM does not directly produce semiconductors, but rather provides licenses for
microprocessor cores with 32-bit RISC architecture.
Since 1985 and its first architecture (named ARM1), ARM architectures have
certainly changed. The architecture upon which Cortex-M3 is based is called
ARMV7-M.
ARM’s collection is structured around four main families of products, for which
many licenses have been filed1:
– the ARM 7 family (173 licenses);
– the ARM 9 family (269 licenses);
– the ARM 10 family (76 licenses);
– the Cortex-A family (33 licenses);
– the Cortex-M family (51 licenses, of which 23 are for the M3 version);
– the Cortex-R family (17 licenses).
1.2.1. Cortex-M3
T
HE question where was the “convenient and fit harbor,” the “fair
and good bay,” which Drake entered on the Pacific coast, and
where he careened and repaired the “Pelican,” is still
undecided, after much discussion by the Californian
geographers, who have now their capital in the city of San Francisco,
—on that matchless land-locked harbor which is entered by the
narrow passage known as the “Golden Gate.” The authorities are not
many, and are not quite in accord.
The narrative of Fletcher, which has been followed in the text,
gives the latitude of this bay as 38° 30′ north. But the briefer
narrative in Hakluyt[153] says: “We came within thirty-eight degrees
towardes the line; in which height it pleased God to send us into a
faire and good bay, with a good wind to enter the same.” Here is a
difference of half a degree. But the text in Hakluyt is supported by a
manuscript marginal note on what seems to be the original drawing
of Dudley’s map, and which is preserved in Munich, where the
language (Italian) is: “This map begins with the port of New Albion,
in longitude 237° and latitude 38°, discovered by the Englishman
Drake in 1579 or thereabout, as above,—a convenient place to water
and to collect other refreshment.” The manuscript has a note, which
the engraving has not, “Porto bonissimo.” But on the coast farther
north, where the same author speaks of the cold, he says: “Drake
returned to 38½ degrees, and the weather was temperate, and he
called it New Albion.” The Arcano del Mare, in which these maps are
printed, was not published till 1646. But Dudley, the author, was
active in maritime affairs in England in all the last ten years of the
sixteenth century. He was the son of Elizabeth’s Earl of Leicester; he
was brother-in-law of Cavendish, administered on his estate, and
must have seen his chart.[154] Hakluyt had wished to publish his
narrative of Drake in his edition of 1589; but this account by Pretty
was not regularly embodied by Hakluyt in his great work till 1600.
[155] The World Encompassed was not printed until 1628, but is from
Fletcher’s contemporary notes. Dudley himself prepared an
expedition to the South Seas. He may be spoken of as a valuable
contemporary authority. The English Government did not publish
such discoveries. But Cavendish would have had Drake’s charts.
Now the opening of the Golden Gate is in latitude 37° 46′: it
exactly corresponds with “within 38° N.” of one account, but it lacks
44′ of the 38° 30′ of the other two. The discrepancy is not so
important when we find that in 38° 30′ there is no harbor and no
bay, good or bad. The voyager
must come down the coast as far
as 38° 15′ to find Bodega Bay,
which has, accordingly, been
assigned by some conjectures as
Sir Francis’ resting-place. Just
south of this, near the line of
38°, is an open roadstead which
has some advocates in this
discussion. Between this bay and
the Golden Gate, the point of Los
Reyes runs out southwest. East
of this, and northwest of the
Golden Gate, is another open
roadstead, facing the south,
which for many years, long
before the discovery of
MODERN MAP. Californian gold, had been known
This sketch will indicate the relative as Jack’s Bay, or Sir Francis
positions of the several bays. Drake’s Bay. One of these four
bays is chosen by one or another
geographer as the fair and good harbor into which a special
providence drove Drake by a favorable wind.
In this discussion, the map of Dudley, whose information was
nearly at first-hand, plays an important part. His representation of
Drake’s bay—a sort of bottle-shaped harbor—so far resembles the
double bay of San Francisco, that it would probably decide the
question, but that, unfortunately, he gives two such bays. His two
maps, also, do not very closely resemble each other. It becomes
necessary to suppose that one of his bays was that which we know
as Bodega Bay, or that both are drawn from the imagination. The
map of Hondius gives a chart of Drake’s bay,[156] which has,
unfortunately, no representation to any bay on the coast, and is
purely imaginary.
The discussion is complicated
from the fact, that, if Drake
entered San Francisco Bay, the
English Government kept its
secret so well that they forgot it
themselves. What is curious is,
that for two centuries the
Spaniards were seeking at
intervals for “Port St. Francisco,”
and did not find it. In 1603,
Viscaino put into a bay which he
called Port St. Francisco; but it is
urged[157] that Viscaino really
entered the Bay of Monterey. The
Spaniards by this time were
eagerly seeking a bay of refuge
for their Asiatic squadrons.[158]
They knew that Drake had
repaired a vessel somewhere.
Viscaino passed “Port St. VISCAINO’S MAP.
Francisco” in a gale, and
Carta de los
returned into it, according to the Sketch from
reconocimentos hechos en 1602 por el
narrative. It was not until 1769 Capitan Sebastian Vizcaino formada por
that a land party of Franciscan los Planos que hizo el misno durante su
monks finally discovered to Spain comision, in an atlas in the State
the magnificent Bay of San Department at Washington.
Francisco. One theory is that no
one ever discovered it before; but a contemporary manuscript
account of the discovery, preserved in the British Museum, says
distinctly that this famous port, according to the signs given by
history, is called San Francisco. It is distant from St. Diego two
hundred leagues, and is to be found in 38½°. “They say it is the best
bay they have discovered; and while it might shelter all the navies in
Europe, it is entered by a straight of three leagues, and surrounded
with mountains which make the waters tranquil.”
COAST OF NOVA ALBION, FROM DUDLEY’S
ARCANO DEL MARE.
The reader must understand that all the maps had a port of Sir
Francis, or a Puerto San Francisco, or some similar name. One
English map bravely says,[159] “Port Sr. Francis Drake, not St.
Francisco,” for the bay discovered in 1770.
So soon as this discovery was known in
England, Captain Burney claimed it as
Drake’s bay; in America, Davidson, in the
Coast Pilot, and Mr. Greenhow give the same
decision.
Probably the early maps must be taken
as the best and decisive authorities.
The reader has before him Dudley’s two
maps. Of these, Dudley says that California
was drawn by an English pilot. In his text
JEFFERYS’ SKETCH.
describing the shore, he goes no further
than Cape St. Lucas, and then crosses to
California, which suggests that he is following Cavendish, who took
this course, and who was Dudley’s near kinsman. On the margin in
the manuscript of Dudley’s map at Munich, he calls Drake’s bay
“Porto bonissimo,” “the best of harbors,”—an expression which
certainly does not belong to Jack’s Bay. In both maps, also, it is
represented as the southern of the two deep bays, of which the
northern appears to correspond to Bodega Bay, and the southern to
San Francisco Bay. On the larger of the two maps Drake’s bay is
placed in the same relation to Monterey as is held by San Francisco.
In the curious “new
map” mentioned by
Shakespeare in “Twelfth
Night,”[160] the spot
where Drake landed is
indicated. The names, as
one reads southward
from the parallel of 40°,
are C. Roxo, Sierra de los
Pescadores,—Tierra de
Paxaros R. Grande, which DUDLEY’S CARTA PRIMA.
seems to be Drake’s
[This is a section from a marginal map
harbor,—Rio Hermoso, C. on the “Carta Prima” of Dudley’s Arcano
Frio, Sierra Nevada, C. del Mare, vol. i. lib. 2, p.19. Key:—
Blanco, Cicuic, Playa, 1. C. Arboledo.
Tiguer. Cicuic and Tiguer 2. Ensa Larga.
are evidently borrowed 3. Po. di Don Gasper.
4. R. Salado.
from Ciceyé and Tiguex
5. Po. dell Nuovo Albion scoperto dal
of Coronado’s narrative.
Drago Cno. Inglese.
The same position is
6. Enseada
given to Tiguex in
7. Po. di Anonaebo.
Hondius’s map. Of this
8. Po. di Moneerei.
the scale is so small that 9. C. S. Barbera.
Drake’s Bay could not be 10. C. S. Agostino.
determined from it, were 11. Quivira Ro.
it not for the issuing of 12. Nuova Albione.—Ed.]
the dotted line showing
his homeward track.
The Spanish geographers are at work on this subject, with full
understanding of the points involved in the problem. It will not be
long, probably, before the question is decided. This writer does not
hesitate to say that he believes it will prove that Drake repaired his
ship in San Francisco Bay, and that this bay took its name not
indirectly from Francis of Assisi, but from the bold English explorer
who had struck terror to all the western coast of New Spain.[161]
EDITORIAL NOTES
T
HE fresh spirit of maritime adventure which marked the last
decade of the fifteenth century and the first quarter of the
sixteenth century, owed its origin to mistaken theories as to the
distance between the west of Europe and the east of Asia.
Columbus believed that the land which he first discovered was an
island on the coast of Japan; and he seems never to have relinquished
this idea. The contemporary geographers all cherished the same
mistake; and the early maps give a much better representation of the
coast-line of Asia than they do of the shores of North America.[185] It
is a curious fact that the true position and form of South America were
familiar to cartographers long before there was any exact knowledge
of the northern half of the continent. North America was regarded as
an island or a collection of islands, through which it would not be
difficult to find a short passage to Zipangu and Cathay,—the modern
Japan and China.[186] Gradually these mistakes yielded to more
correct views; but it was still believed that a feasible passage existed
around the northern shore of the new continent. This belief was the
inspiring motive of all the early northwestern explorations, and it
lingered almost to our own time, long after every one knew that such
a passage would be of no practical use. At length the problem has
been solved; but the introduction of new methods of ocean and land
trade and travel has deprived it of all but a purely scientific and
geographical interest. Meanwhile the search for a northwest passage
has developed an heroic endurance and a perseverance in
surmounting obstacles scarcely paralleled anywhere else, and has
added largely to the stores of human knowledge.
At the head of the long list of explorers for a northwest passage
stand the names of the Cabots; but the intricate questions as to the
measure of just fame to be assigned to father and son have been fully
treated in another chapter of this work,[187] and neither John nor
Sebastian penetrated the more northern waters with which our inquiry
is mainly concerned. It is enough now to recall their names as the
leaders in an enterprise in which for nearly three centuries England
took a foremost part, and that so early as 1497 John Cabot set sail in
the hope of this great discovery. Within the next half century he was
followed by his son Sebastian, the Cortereals, Cartier, and Hore, not
one of whom sought to reach a high northern latitude. It was not until
Frobisher sailed on his first voyage that the real northwest
explorations can be said fairly to have begun. Since that time more
than one hundred voyages and land journeys have been undertaken in
this vain quest.
In two of the northwestern voyages of Martin Frobisher the
discovery of a short way to the South Sea was only a secondary
object. The adventurers at whose cost they were undertaken looked
mainly to the profit from a successful search for gold, though they
were not unmindful of the advantages to be gained by shortening the
distance to the Spice Islands of the East. In the bitter quarrel between
Frobisher and Michael Lok, after the third voyage, it was charged that
Frobisher had neglected this part of the undertaking. But it was
natural that Lok, who had no doubt lost heavily by the voyages,
should be angry with Frobisher, and endeavor to make the most of any
failure on his part to carry out the whole plan; and there is no reason
to believe that Frobisher wilfully neglected the interests or the wishes
of his employers, however much they may have been disappointed.
The whole amount subscribed for the three voyages was upward of
twenty thousand pounds, and of this sum Lok subscribed, for himself
and his children, nearly one fourth. Among the subscribers were
Queen Elizabeth, who invested four thousand pounds, Lord Burleigh,
the Earl and Countess of Warwick, the Earl of Leicester, the Earl and
Countess of Pembroke, Sir Philip Sidney, Sir Thomas Gresham, Sir
Francis Walsingham, and others scarcely less conspicuous in that
generation.
Frobisher’s first expedition consisted of two small vessels, the
“Gabriel” and the “Michael,” one of twenty-five tons and the other of
twenty tons, and a pinnace of ten tons. They set sail from Blackwall
on the 15th of June, 1576, but it was not until the 1st of July that they
were clear of the coast of England. Not long after coming in sight of
Friesland, Frobisher parted company with the pinnace, in which were
four men, who were never seen again; and about the same time the
“Michael” slipped away without any warning, and returned to England.
Nevertheless, Frobisher pressed on, and on the 21st he entered the
opening now known as Frobisher’s Strait or Bay, “having upon eyther
hande a great mayne or continent; and that land uppon hys right
hande as hee sayled westward, he judged to be the continente of
Asia, and there to bee devided from the firme of America, which lyeth
uppon the lefte hande over against the same.”[188] Into this bay, as it
is now known to be, he sailed about sixty leagues, capturing one of
the natives, whom he carried to England. The land, Meta Incognita, he
took possession of in the name of the Queen of England, commanding
his company, “if by anye possible meanes they could get ashore, to
bring him whatsoever thing they could first find, whether it were living
or dead, stocke or stone, in token of Christian possession.”[189] Some
of the men returned to him with flowers, some with green grass, “and
one brought a peece of black stone, much lyke to a seacole in coloure,
which by the waight seemed to be some kinde of mettall or mynerall.”
Frobisher reached England on his return in the following October, and
on his arrival presented the stone to one of his friends, an adventurer
in the voyage. The wife of this gentleman accidentally threw it into the
fire, where it remained for some time, when it was taken out and
quenched in vinegar. It then appeared of a bright gold color, and on
being submitted to a goldfinder in London, was said to be rich in gold;
and large profits were promised if the ore was sufficiently abundant.
With this report, there was
little difficulty in providing means
for a second voyage. The new
expedition consisted of a “tall ship
of her Majesty’s,” named the
“Ayde,” of two hundred tons, and
of two smaller vessels, with the
same names as those in the
former voyage, but now said to be
of thirty tons each. They were
manned in all by one hundred and
twenty men, to which number
Frobisher was limited by his
orders. After some delay, he sailed
from Harwich on the 31st of May,
1577. By his orders he was This cut follows the engraving in the
directed to proceed at once to the Hakluyt Society’s edition of Frobisher’s
place where the mineral was Voyages.
found, and set the miners at work.
There he was to leave the “Ayde,” and then to sail to another place
visited on his first voyage, where a further attempt at mining was to
be made, and where one of the small barks was to be left. With the
remaining bark he was to sail fifty or a hundred leagues farther west,
to make “certayne that you are entred into the South Sea; and in yor
passage to learne all that you can, and not to tarye so longe from the
‘Ayde’ and worckmen but that you bee able to retorne homewards wth
the shippes in due tyme.” If the mines should prove less productive
than it was hoped they would be, he was to “proceade towards the
discovering of Cathaya wth the two barcks, and returne the ‘Ayde’ for
England agayne.”[190] Frobisher had his first sight of Friesland on the
4th of July; and he reached Milford Haven, in Wales, on his return
voyage, about the 23d of September. During this period of a little
more than two months, his energies were mainly devoted to procuring
ore, of which, in twenty days, he obtained nearly two hundred tons;
but he also made as careful an examination as was practicable of the
region previously visited by him, and added something to the stock of
geographical knowledge. Two of the natives were captured, and were
carried to England to be educated as interpreters.
Frobisher’s third voyage was planned on a much larger scale than
any other which hitherto had been sent to the Arctic regions, and he
was placed in command of fifteen vessels. They were all collected at
Harwich by the 27th of May, 1578; and after receiving their
instructions from Frobisher, they sailed together on the 31st. On the
2d of July they reached the mouth of Frobisher’s Bay; but after
entering it a short distance, they found it so choked with ice that it
was impossible to proceed. One of the vessels was soon sunk by the
ice, and all suffered more or less. After beating about for several days,
they entered a strait, supposed at first to lead to their desired goal,
but which was, in fact, what is now known as Hudson’s Strait, the
entrance to the great bay which bears his name, “havyng alwayes a
fayre continente uppon their starreboorde syde, and a continuance still
of an open sea before them.” According to Best, one of the captains,
and an historian of the expedition, Frobisher was probably one of the
first to discover the mistake, though he persuaded his followers that
they were in the right course and the known straits. “Howbeit,” he
adds, “I suppose he rather dissembled his opinion therein than
otherwyse, meaning by that policie (being hymself ledde with an
honorable desire of further discoverie) to enduce ye fleete to follow
him, to see a further proofe of that place. And, as some of the
company reported, he hath since confessed, that, if it had not bin for
the charge and care he had of ye fleete and fraughted shippes, he
both would and could have gone through to the South Sea, called
Mare del Sur, and dissolved the long doubt of the passage which we
seeke to find to the rich countrey of Cataya.”[191] Toward the latter
part of July it was determined not to proceed any farther, and after
many difficulties and dangers they returned to Meta Incognita. It had
been their intention to erect a house here, and to leave a considerable
party to spend the winter. But after a full consideration it was decided
that this plan was impracticable, and it was relinquished. A house of
lime and stone was, however, built on the Countess of Warwick’s
Island, in which numerous articles were deposited. On the last day of
August the fleet, having completed their loading with more than
thirteen hundred tons of ore, sailed for England, where they arrived at
various times about the 1st of October, and with the loss of not more
than forty men in all. The ore proved to be of very little value, and the
adventurers lost a large part of what they had subscribed.[192]
Of the voyages of Sir Humphrey Gilbert, who is often included
among the northwest explorers, little need be said here; for though he
wrote an elaborate Discourse of a Discovery for a new Passage to
Cataia, to stimulate the search for a northwest passage, the voyage in
which he lost his life was not extended beyond the coasts of
Newfoundland.[193]
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.
ebookultra.com