Sridhar Anandakrishnan
Propeller ProgrammingUsing Assembler, Spin, and C
Sridhar Anandakrishnan
Department of Geosciences, University Park, Pennsylvania, USA
Any source code or other supplementary material referenced by the author in this book is available to readers on GitHub via the book’s product page, located at www.​apress.​com/​9781484233535 . For more detailed information, please visit www.​apress.​com/​source-code .
ISBN 978-1-4842-3353-5e-ISBN 978-1-4842-3354-2
Library of Congress Control Number: 2018935236
© Sridhar Anandakrishnan 2018
This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of publication, neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or omissions that may be made. The publisher makes no warranty, express or implied, with respect to the material contained herein.
Printed on acid-free paper
Distributed to the book trade worldwide by Springer Science+Business Media New York, 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@springer-sbm.com, or visit www.springeronline.com. Apress Media, LLC is a California LLC and the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation.
Preface
This book is intended for those who are familiar with Spin programming for the Parallax Propeller microcontroller but who want to learn Propeller C and Propeller Assembly (PASM) programming. The overall task you will pursue in the book is to implement a delta compression algorithm (a way to store a string of numbers in less space), first in Spin, then in PASM, and finally in C. Along the way, I talk about Test-Driven Development and will end with a chapter on hardware manipulations.

Intended Audience

It will be helpful to have some knowledge of a programming language. The intent is to help you extend the capabilities of the Propeller processor by using C and the Assembler language. If you don’t know Spin but do know another programming language (C or Python, for example), you will still be able to follow along actively.
You will learn by doing, so you must purchase a Propeller board such as the QuickStart board ( https://www.parallax.com/product/40000 ) so that you can run the code.

Formatting

In this book, code listings are typeset in a typewriter font: nSamps := 1 .
To keep the bloat down, I often elide lines that have been explained earlier. I will insert an ellipsis to indicate that: ... .
Lines of code in Spin may not have a line break. When a long line listing is broken into two because of the page width, this is indicated with an arrow: ( A459910_1_En_BookFrontmatter_Figc_HTML.gif ). You can download the code examples from GitHub ( https://github.com/Apress/propeller-programming ). Two libraries ( FullDuplexSerial4PortPlus_0v3 and Numbers ) are used in the code. Both can be downloaded from the Propeller Object Exchange ( http://obex.parallax.com ), and for convenience I include them in the GitHub repository.

Trains

As you will discover, I like trains! But my choice of trains as an analog for the Propeller isn’t entirely arbitrary. Like the Propeller, train stations have many parallel tracks with trains moving at different speeds and performing different tasks and with the need to somehow communicate between each other and with the outside world.
As with trains there is always the possibility of a crash! Gentle programmer, as in any journey, you will experience tears and heartache en route to your destination, but if you persist, there is a great reward at the end of the journey!
A459910_1_En_BookFrontmatter_Figb_HTML.jpg
Acknowledgments
I would like to thank Peter Burkett, Bruce Long, and Don Voigt for their help in the lab and in the field. They designed and deployed rugged and precise instruments in Antarctica and Greenland that helped to shape our knowledge of those continents. I would like to thank the US National Science Foundation, whose financial and logistical support has made this work possible. I would like to thank my wife Martha Bright, whose love and support has made this book possible.
Table of Contents
Part II: Spin and PASM75
Index311
About the Author
Sridhar Anandakrishnan
is a professor of glaciology and geophysics at Pennsylvania State University where he studies the flow of glaciers in Antarctica and Greenland. Sridhar uses the Propeller chip in a seismic data acquisition device that is used “on the ice,” as they say!