Converting Programs from Pbasic to Zbasic
Total Page:16
File Type:pdf, Size:1020Kb
Guide to Converting Programs from PBasic to ZBasic Version 1.1 Copyright © 2008 Elba Corp. All rights Reserved. Publication History August 2008 – First draft release September 2008 – First public release November 2008 – Minor corrections Disclaimer Elba Corp. makes no warranty regarding the accuracy of or the fitness for any particular purpose of the information in this document or the techniques described herein. The reader assumes the entire responsibility for the evaluation of and use of the information presented. The Company reserves the right to change the information described herein at any time without notice and does not make any commitment to update the information contained herein. No license to use proprietary information belonging to the Company or other parties is expressed or implied. Trademarks ZBasic, ZX-24, ZX-24a, ZX-24n, ZX-24p, ZX-40, ZX-40a, ZX-40n, ZX-40p, ZX-44, ZX-44a, ZX-44n, ZX- 44p, ZX-1280, ZX-1280n, ZX-1281 and ZX-1281n are trademarks of Elba Corp. Other brand and product names are trademarks or registered trademarks of their respective owners. ii Table of Contents Introduction ............................................................................................................................................. 1 General Issues ........................................................................................................................................1 I/O Ports and Pins ...................................................................................................................................2 Defining and Using Constants..................................................................................................................4 Using Numeric Constants ........................................................................................................................5 Defining and Using Variables...................................................................................................................6 Expressions, Operators and Order of Operations.....................................................................................8 Defining and Using Subroutines...............................................................................................................9 Defining and Using Functions ..................................................................................................................9 PBasic Statements, Commands and Directives...................................................................................... 11 BRANCH.......................................................................................................................................... 11 BUTTON .......................................................................................................................................... 12 COUNT ............................................................................................................................................ 12 DATA ............................................................................................................................................... 12 DEBUG ............................................................................................................................................ 13 DEBUGIN......................................................................................................................................... 13 DO…LOOP ...................................................................................................................................... 13 DTMFOUT........................................................................................................................................ 13 END ................................................................................................................................................. 13 FOR…NEXT .................................................................................................................................... 13 FREQOUT........................................................................................................................................ 13 GOSUB ............................................................................................................................................ 14 GOTO .............................................................................................................................................. 14 HIGH................................................................................................................................................ 15 IF…THEN......................................................................................................................................... 15 INPUT .............................................................................................................................................. 15 LOOKDOWN.................................................................................................................................... 16 LOOKUP .......................................................................................................................................... 16 LOW................................................................................................................................................. 17 NAP ................................................................................................................................................. 17 ON…GOSUB ................................................................................................................................... 18 ON…GOTO...................................................................................................................................... 18 OUTPUT .......................................................................................................................................... 18 PAUSE............................................................................................................................................. 18 PULSIN ............................................................................................................................................ 19 PULSOUT ........................................................................................................................................ 19 PWM................................................................................................................................................ 20 RANDOM ......................................................................................................................................... 20 RCTIME ........................................................................................................................................... 20 READ............................................................................................................................................... 21 RETURN .......................................................................................................................................... 21 REVERSE........................................................................................................................................ 21 SELECT…CASE .............................................................................................................................. 22 SERIN.............................................................................................................................................. 22 SEROUT .......................................................................................................................................... 22 SHIFTIN ........................................................................................................................................... 23 iii SHIFTOUT ....................................................................................................................................... 23 SLEEP ............................................................................................................................................. 23 STOP ............................................................................................................................................... 24 TOGGLE .......................................................................................................................................... 24 WRITE ............................................................................................................................................. 24 XOUT............................................................................................................................................... 25 PBasic Conversion Example.................................................................................................................. 26 Conversion Phase 1 ......................................................................................................................... 27 Conversion Phase 2 ......................................................................................................................... 32 PBasic Conversion Helper Code............................................................................................................ 34 iv This page is intentionally blank. v Guide to Converting Programs from PBasic to ZBasic Introduction The original BASIC programming language was designed in 1964 by John Kemeny and Thomas Kurtz at