# MCS BASIC-52 REFERENCE MANUAL

# with BASIC v1.2a additions

## Table of Contents

###
CHAPTER 1
Introduction

1.1 | Introduction to MCS BASIC-52
1.2 | Getting Started
1.3 | Getting Started-What Happens After Reset
1.4 | Definition of Terms
1.5 | What's the difference between Version 1.0 and Version 1.1

### CHAPTER 2
Description of Commands

2.1 | RUN
2.2 | CONT
2.3 | LIST
2.4 | LIST#
2.5 | LlST@
2.6 | NEW
2.7 | NULL

### CHAPTER 3
Description of EPROM File Commands

3.1 | RAM and ROM
3.2 | XFER
3.3 | PROG
3.4 | PROG1 and PROG2
3.5 | FPROG, FPROG1 and FPROG2
3.6 | PROG3, PROG4, FPROG3, and FPROG4 (Version 1.1 only)
3.7 | PROG5, PROG6, FPROG5, and FPROG6 (Version 1.1 only)

### CHAPTER 4
Description of Statements

4.1 | BAUD
4.2 | CALL
4.3 | CLEAR
4.4 | CLEARS and CLEARI
4.5 | CLOCK1 and CLOCK0
4.6 | DATA-READ-RESTORE
4.7 | DIM
4.8 | DO-UNTIL
4.9 | DO-WHILE
4.10 | END
4.11 | FOR-TO-STEP-NEXT
4.12 | GOSUB-RETURN
4.13 | GOTO
4.14 | ON GOTO-ON GOSUB
4.15 | IF-THEN-ELSE
4.16 | INPUT
4.17 | LET
4.18 | ONERR
4.19 | ONEX1
4.20 | ONTIME
4.21 | PRINT
4.22 | PRINT#
4.23 | PH0., PH1., PH0. #, PH1. #
4.24 | PRlNT@, PHO.@, PH1.@ (Version 1.1 Only)
4.25 | PUSH
4.26 | POP
4.27 | PWM
4.28 | REM
4.29 | RETI
4.30 | STOP
4.31 | STRING
4.32 | UI1 AND UI0
4.33 | UO1 and UO0
4.34 | IDLE (Version 1.1 only)
4.35 | RROM (Version 1.1 only)
4.36 | LD@ and ST@ (Version 1.1 only)
4.37 | PGM (Version 1.1 only)

### CHAPTER 5
Description of Arithmetic/Logical Operators and Expressions

5.1 | Dual Operand (DYADIC) Operators
5.2 | Unary Operators
5.2.1 | General Purpose
5.2.2 | Log Functions
5.2.3 | Trig Functions
5.3 | Understanding Precedence of Operators
5.4 | How Relational Expressions Work

### CHAPTER 6
Description of String Operators

6.1 | What are Strings?
6.2 | The ASC Operator
6.3 | The CHR Operator

### CHAPTER 7
Special Operators

7.1 | Special Function Operators
7.2 | Examples of Manipulating Special Function Operators
7.3 | System Control Values

### CHAPTER 8
Error Messages, Bells, Whistles, and Anomalies

8.1 | Error Messages
8.2 | Disabling Control-C
8.3 | Implementating "Fake DMA"
8.4 | Run Trap Option (Version 1.1 only)
8.5 | Anomalies

### CHAPTER 9
Assembly Language Linkage

9.1 | Overview
9.2 | General Purpose Routines
9.3 | Unary Operators
9.4 | Special Operators
9.5 | Dual Operand Operators
9.6 | Added Link Routines to Version 1.1
9.7 | Interrupts
9.8 | I/O Resource Allocation

### CHAPTER 10
System Configuration

10.1 | Memory/Hardware Configuration
10.2 | EPROM Programming Configuration/Timing
10.3 | Serial Port Implementation

### CHAPTER 11

| Reset Options (Version 1.1 only)

### CHAPTER 12

| Command/Statement Extensions (Version 1.1 only)

### CHAPTER 13

| Mapping User Code Memory (Version 1.1 only)

### APPENDIX A

1.1 | Memory Usage (Version 1.0 and Version 1.1)
1.2 | Using the PWM Statement
1.3 | Baud Rates and Crystals
1.4 | Quick Reference
1.5 | Instruction Set Summary
1.6 | Floating Point Format
1.7 | Storage Allocation
1.8 | Format of an MCS BASIC-52 program
1.9 | Answers to a Few Questions
1.10 | Pin-out List
1.11 | 8052AH Special Function Registers
1.12 | References

### APPENDIX B

| Instruction Set Summary

### APPENDIX C

| Version 1.2
| Version 1.2a

COLOUR CONVENTIONS :

Bright green | Chapter heading
Orange | Subsection
Dark green | Command/statement
Dark blue | Additional information
Dark purple | Additional information that has not been verified
Light blue italics | Version 1.1, 1.2 and 1.2a specific