“Soul” of CP/M: the Universal System Calls That Make CP/M the World’S Most Popular Microcomputer Operating System

“Soul” of CP/M: the Universal System Calls That Make CP/M the World’S Most Popular Microcomputer Operating System

SOUL OF CP/M® (How to Use the Hidden Power of Your CP/M® System) by Mitchell Waite and Robert Lafore Howard W. Sams & Co. A Division of Macmillan, Inc. 4300 West 62nd Street, Indianapolis, IN 46268 USA © 1983 by the Waite Group, Inc. FIRST EDITION THIRD PRINTING - 1986 All rights reserved. No part of this book shall be repro­ duced, stored in a retrieval system, or transmitted by any means, electronic, mechanical, photocopying, recording, or otherwise, without written permission from the publisher. No patent liability is assumed with respect to the use of the information contained herein. While every precaution has been taken in the preparation of this book, the pub­ lisher assumes no responsibility for errors or omissions. Neither is any liability assumed for damages resulting from the use of the information contained herein. International Standard Book Number: 0-672-22030-X Library of Congress Catalog Card Number: 83-61059 Edited by: Frank N. Speights Illustrated by: Kevin Caddell Printed in the United States of America. Preface * Have you ever wanted to know how the CP/M® operating system really works? * Would you like to use CP/M’s hidden power in your own BASIC or assembly language programs? * Are you a BASIC programmer who would like to learn assembly lan­ guage, but have been told that it’s too complicated? * Do you need to modify CP/M to work with a particular printer or some other I/O device? * Do you want to write programs that will work with any version of CP/M ? If the answer to any of these questions is yes, then this book, with its unique approach to teaching both CP/M systems calls and 8080 assembly language programming, is for you. Starting with simple three- and four-line programs, we ease you into the “soul” of CP/M: the universal system calls that make CP/M the world’s most popular microcomputer operating system. Gradually and easily, you’ll learn how to write programs to control all your I/O devices, including the disk system, and, also, perform a variety of other functions. Remember, you don’t need to know how to program in assembly language to understand this book! We’ll teach you all the 8080 assembly language that you will need to know and, since you’ll be learning the system calls at the same time, your programs will be able to perform powerful functions from the very beginning. CP/M is the registered trademark of Digital Research, Inc., Pacific Grove, CA Soul of CP/M® You’ll also learn how to use these powerful system calls in your BASIC programs, how CP/M manages disk files, and how to modify CP/M’s “BIOS” (Basic Input/Output System) to work with different I/O devices, so that you can customize CP/M for a particular printer or other device. All in all, if you want to do more with your CP/M system than simply run applications programs, then this book is for you! M it c h e l l W a it e a n d R o b e r t La f o r e Acknowledgments The authors would like to thank Mark Berger, Phil Chapnick, and Scott Kamins for their many helpful comments, criticisms, and suggestions. Their pioneering journey on the road followed by this book has resulted in remov­ ing many obstacles from the path of future readers. Dedication by Robert Lafore This book is dedicated to my parents. Contents Introduction ............................................................ 11 Soul of CP/M-Who Is This Book For—What This Book Will Teach You-8080, 8080A, 8085, Z-80: W hat’s the Difference?- What You Need To Know To Get the Most Out of This Book— How This Book Is Organized—How To Enjoy This Book CHAPTER 1 T h e B ig Pic t u r e : H ow CP/M Is O r g a n iz e d ................................................... 17 What Is an Operating System, Anyway?—What’s So Great About CP/M?-The Parts of CP/M—8080 Architecture—DDT-The Programmer’s X Ray and Probe—Back Down to Earth CHAPTER 2 ONE T o e IN t h e W a t e r : Console System C a lls....................................... 31 Console Output System Call—Get Console Status—Barber-Pole Display Program-Console Input—Executing Programs From CP/M —System Rest-A Warm Boot—So Long, Chapter 2, It’s Been Good To Know You CHAPTER 3 G e t t in g in D e e p e r : Advanced Console System Calls .......................... 71 Print String-Read Console Buffer—Echo Program-Name Display Program—Direct Console I/O-List Output to Printer-Reader Input-Punch Output-Get I/O Byte-Set I/O Byte-Goodbye, Nondisk System Calls CHAPTER 4 U s in g t h e A s s e m b l e r ................................................................................................... 107 What’s an Assembler Do, Anyway?—What ASM Does—The “DECIBIN” Routine-Reads Decimal From Keyboard-DECIHEX Program-Converts Decimal to Hex, on Screen—BINIHEX-Binary to Decimal Conversion Routine—Using CP/M’s Submit Utility— Graduation Time CHAPTER 5 D isk Sy st e m C a l l s ............................................................................................................137 Records, Files, Tracks, Sectors, Allocation Units, Extents, and Goodness Knows What Else—Talking to BDOS—Open File—The Problem With Where the DMA Is Located—Read Sequential Sys­ tem Call—Set DMA Address—TYPE2 Program-Imitates the “TYPE” Command—LINES Program-Prints Number of Lines in Text File—Life on the Fast Track CHAPTER 6 W riting to t h e D i s k ......................................................................................................169 Writing a Sequential Record—Make File—Write Sequential Rec­ ord-Close File System Call—Program to Write a Sequential Rec­ ord—STORE Program-Stores Text in File-Delete File System Call—Random Records-Read Random System Call-Write Ran­ dom System Call—RANDYMOD-Program to Modify a Random Record—Compute File Size System Call-Set Random Record Sys­ tem Call-Out of Ink CHAPTER 7 So u l Se a r c h in g : Wildcards and the Disk D ire c to ry ...............................201 How CP/M Stores Files on the Disk—Search For First System Call—Wildcards—Search For Next System Call—Erased Files—Sav­ ing an Erased File—The Bit Map-WORDS Program-Counts Words in Files and Uses Wildcards CHAPTER 8 T e a m w o r k : Using System Calls From B A S IC ............................................243 Where Do We Put the A-L Program in Memory?—How To Get the A-L Program Where We Want It To Go—How Do We Transfer Control Between BASIC and the A-L Routine?-How Do We Pass Arguments Between BASIC and the A-L Routine?-BINIHEX2- A-L Routine Called From BASIC-Other Ways To Put the A-L Routine Into Memory-HEXIBIN2-Passing Arguments to BASIC From an A-L Routine-Operating on Strings With an A-L Rou­ tine-Back to Basics CHAPTER 9 T h e In n e r m o s t So u l o f CP/M : H ow To Modify CP/M for Different Peripherals............................................................................................ 279 Why You’re Reading This Chapter-What Is the BIOS Anyway?— Learning Your Way Around the BIOS-The Complete BIOS List­ ing—How to Modify Your Printer Driver—Installing the New Driver Into Your BlOS-Inserting the New Driver Into the CP/M System-A Shortcut-Modifying BIOS for Different Control Char- acters-The Sky’s the Limit APPENDIX A H e x a d e c im a l N o t a t i o n ............................................................................................... 323 Why Use Hexadecimal Notation?—Binary Notation—Decimal Notation—Hexadecimal Notation—Converting Hex to Decimal- Converting Decimal to Hex APPENDIX B U t il it y Pr o g r a m s ............................................................................................. 331 HEXDUMP-Micro Space Invaders-HEXIDEC-FILEDUMP APPENDIX C Su m m a r y o f 8080 Instructions ................................................................... 345 8080 Architecture—8080 Instructions—Assembler Directives APPENDIX D T a b l e s ..................................: ............................................................................. 359 ASCII Character Set With Hexadecimal Equivalents—Hexadeci- mal-to-Decimal Conversion—Multiples of IK (1024), in Decimal and Hexadecimal—Decimal, Hex, and Binary Conversion APPENDIX E Su m m a r y o f B D O S Sy st e m Ca lls (F o r CP/M 2.2) 365 APPENDIX F Su m m a r y o f DDT C o m m a n d s ......................................................................369 Loading DDT—“A” for Assemble—“D” for Dump Memory—“F” for Fill—“G” for GO—“H” for Hexadecimal Arithmetic—“I” Com- mand-“L” for List-“M” for Move-“R” for Read-“S” for Set Memory-“T” for Trace-“U” for Untrace-“X” for Examine Reg­ isters APPENDIX G Su m m a r ie s o f P r o g r a m s U s e d a n d Lo c a t io n s o f In s t r u c t io n D escription s ....................................................................................................................... 379 Programs Used-Descriptions of Instructions In d e x 383 Introduction SOUL OF CP/M® What do we mean by the “Soul” of CP/M? One of CP/M’s most pleasant features is its ease of use. The loading of applications programs, the use of such CP/M functions as DIR, STAT, and PIP, and the use of higher-level languages such as BASIC or FORTRAN, are all simple and straightforward 11 Soul of CP/M® in the CP/M environment. In fact, this efficient facade is all that many users will ever know about CP/M.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    397 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us