Table of Contents. PREFACE... vii CONVENTIONS... vii HOW TO USE THIS MANUAL... vii Further Information...viii

Similar documents
MCS BASIC-52. Versions 1 & 1.1 OPERATING AND REFERENCE MANUAL

8051 Microcontroller

Allen-Bradley. User Manual. BASIC Module. Series B (Cat. No DB)

MATHEMATICAL / NUMERICAL FUNCTIONS

2001 PET POCKET REFERENCE GUIDE TO COMMODORE'S LEADING EDGE COMPUTER PRODUCTS. ~ COPYRIGHT 1979, LEADING EDGE CO. ALL RIGHTS RESERVED

8051 Microcontroller

Introduction To MCS-51

Chapter 09. Programming in Assembly

ASCII BASIC Coprocessor Module

3. (a) Explain the steps involved in the Interfacing of an I/O device (b) Explain various methods of interfacing of I/O devices.

Memory organization Programming model - Program status word - register banks - Addressing modes - instruction set Programming examples.

Functions. Systems Programming Concepts

THE 8051 MICROCONTROLLER

Run time environment of a MIPS program

THE 8051 MICROCONTROLLER

Set No.1. Code No: R

SYLLABUS UNIT - I 8086/8088 ARCHITECTURE AND INSTRUCTION SET

SANKALCHAND PATEL COLLEGE OF ENGINEERING, VISNAGAR. ELECTRONICS & COMMUNICATION DEPARTMENT Question Bank- 1

8051 Microcontrollers

CS 320. Computer Architecture Core Architecture

Chapter 09. Programming in Assembly

Three criteria in Choosing a Microcontroller

Macro Programming Reference Guide. Copyright 2005 Scott Martinez

Ready-Set-Go (RSG) Controller: Getting Starter


Long (LONGMATH) variables may be used the same as short variables. The syntax is the same. A few limitations apply (see below).

INSTITUTE OF AERONAUTICAL ENGINEERING Dundigal, Hyderabad ELECTRONICS AND COMMUNICATION ENGINEERING QUESTION BANK

Long (or LONGMATH ) floating-point (or integer) variables (length up to 1 million, limited by machine memory, range: approx. ±10 1,000,000.

Quick Reference Guide


PART - B (Answer all five units, 5 X 10 = 50 Marks)

10 Using the PCFL Editor In this chapter

MODULE-1. Short Answer Questions

FANF. programming language. written by Konstantin Dimitrov. Revision 0.1 February Programming language FANF 1 / 21

C Programs: Simple Statements and Expressions

Introduction to Computer Programming in Python Dr. William C. Bulko. Data Types


ET2640 Microprocessors

Intel 8086: Instruction Set

Lesson #3. Variables, Operators, and Expressions. 3. Variables, Operators and Expressions - Copyright Denis Hamelin - Ryerson University

Understanding the basic building blocks of a microcontroller device in general. Knows the terminologies like embedded and external memory devices,

SOME ASSEMBLY REQUIRED

CALCA. I/A Series Software Advanced Calculator (CALCA) Block. Product Specifications INTEGRATED CONTROL INTELLIGENT AUTOMATION PSS 21S-3M8 B4

Table of Contents. Chapter Description Page. 1. PLC Fundamentals Ladder Logic

Special Section: Building Your Own Compiler

DEPARTMENT OF ECE QUESTION BANK SUBJECT: MICROPROCESSOR AND MICROCONTROLLER UNIT-1 PART-A (2 MARKS)

MLR INSTITUTE OF TECHNOLOGY DUNDIGAL , HYDERABAD

AVR ISA & AVR Programming (I) Lecturer: Sri Parameswaran Notes by: Annie Guo

SOLUTION MANUAL FOR THE 8051 MICROCONTROLLER 4TH EDITION BY MACKENZIE AND PHAN

The CPU and Memory. How does a computer work? How does a computer interact with data? How are instructions performed? Recall schematic diagram:

1. Attempt any three of the following: 15

UNIT 2 THE 8051 INSTRUCTION SET AND PROGRAMMING

8051 microcontrollers

the SAP-2 I. Intro cmpt-150-arc Sections 8-8, 8-9, 9-4, 9-5, 9.6, We ll do this in bits and pieces, doing the beginning of each section first.

AVR ISA & AVR Programming (I)

Department of Electronics and Instrumentation Engineering Question Bank

19 Much that I bound, I could not free; Much that I freed returned to me. Lee Wilson Dodd

The Microcontroller. Lecture Set 3. Major Microcontroller Families. Example Microcontroller Families Cont. Example Microcontroller Families

GATE Exercises on Microprocessors

B A S I C / 5. User's Manual. For Use with. SOLOS, CUTER and CONSOL

The Microcontroller Idea Book

AVR ISA & AVR Programming (I) Lecturer: Sri Parameswaran Notes by: Annie Guo

8-bit Microcontroller with 8K Bytes In-System Programmable Flash AT89S52

8051 Microcontroller. Ali Ziya Alkar 1

Lecture 5. EEE3410 Microcontroller Applications Department of Electrical Engineering Assembly Language Programming (1)

RCA 1802 BASIC level 3 ver. 1.1 User Manual

Introduction to C Language

Description of the Simulator

Design of Embedded Systems Using 68HC12/11 Microcontrollers

MICROPROCESSOR LABORATORY MANUAL

Microcontroller. Instruction set of 8051

CPEG300 Embedded System Design. Lecture 3 Memory

S3012 User s Manual. Copyright 1990 Systems Engineering Associates, Inc. Revision 1, December All Rights Reserved!

Lecture 2 Microcomputer Organization: Fig.1.1 Basic Components of Microcomputer

Fixed-Point Math and Other Optimizations

9/2/2016. Expressions are Used to Perform Calculations. ECE 120: Introduction to Computing. Five Arithmetic Operators on Numeric Types

1/31/2017. Expressions are Used to Perform Calculations. ECE 120: Introduction to Computing. Five Arithmetic Operators on Numeric Types

PC-12S0 Pocket Computer

e-pg Pathshala Subject : Computer Science Paper: Embedded System Module: Interrupt Handling Module No: CS/ES/13 Quadrant 1 e-text

Small Computer Monitor User Guide

Instruction Set Architecture of MIPS Processor

ELEG3923 Microprocessor Ch.9 Timer Programming

8051 Single Board Monitor Programming. Minmon - Yeralan & Ahluwalia. PaulMon1 & PaulMon2 - Paul Stoffregen


Introduction to Internet of Things Prof. Sudip Misra Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur

Phụ lục 2. Bởi: Khoa CNTT ĐHSP KT Hưng Yên. Returns the absolute value of a number.

JUN / 04 VERSION 7.0

Basic types and definitions. Chapter 3 of Thompson

Introduction to Programming

Computer Components. Software{ User Programs. Operating System. Hardware

CHAPTER ASSEMBLY LANGUAGE PROGRAMMING

Introduction to Arduino. Wilson Wingston Sharon

2. MACHINE REPRESENTATION OF TYPICAL ARITHMETIC DATA FORMATS (NATURAL AND INTEGER NUMBERS).

The advantages of registers over memory locations are as follows:

ECE232: Hardware Organization and Design

INSTITUTE OF ENGINEERING AND MANAGEMENT, KOLKATA Microprocessor

Machine Controller MP900/MP2000 Series New Ladder Editor PROGRAMMING MANUAL MANUAL NO. SIEZ-C C

MSM80C154S MSM83C154S MSM85C154HVS USER'S MANUAL

Microcontrollers. Microcontroller

Tutorial Letter 103/3/2012 Computer Organization COS2621 Semesters 1 & 2

Transcription:

Table of Contents PREFACE... vii CONVENTIONS... vii HOW TO USE THIS MANUAL... vii Further Information...viii USING BASIC-52... 1 BASIC-52 PINOUT AND FEATURES... 1 8052AH and 80C52 DIFFERENCES... 1 DEFINITION OF TERMS... 2 Common Acronyms... 2 BASIC Interpreters and Compilers... 2 Console... 2 Console Serial Port... 3 On-Line/Off-Line... 3 Commands... 3 Operators... 3 Instructions... 3 Expressions... 3 Statements... 3 Program Lines... 4 Strobe... 4 WRITING AND EDITING BASIC PROGRAMS... 4 Anomalies and Bugs... 4 On-Line Editing... 4 ASCII Text Only, Please... 5 Downloading and Uploading Basic Programs... 5 Constants... 5 Variables... 6 Addresses... 7 Arrays... 8 Strings... 8 BASIC PROGRAM LINES... 8 Line Numbers... 8 Multiple Statements on a Line... 8 Remarks... 8 Uppercase/Lowercase... 9 Spaces in Program Lines... 9 Use Of Parentheses... 10 Subroutines and Branching... 10 Passing Variables Between Programs and Subroutines... 11 RUNNING BASIC PROGRAMS... 11 Command and Run Modes... 11 Control-C... 11 Control-S and Control-Q (X-On and X-Off)... 11 STORING BASIC PROGRAMS... 12 Device Pins Used for Programming... 12 Programming Algorithms... 13 EPROM... 13 EEPROM... 13 SRAM... 14 WHAT HAPPENS AFTER RESET... 14 PROGRAMMER'S REFERENCE... 15 PROGRAM EXECUTION and LISTING COMMANDS... 15 RAM... 15 ROM... 16 XFER... 16 RUN... 17 CONT... 17 LIST... 18 LIST#... 18 LIST@... 19 i

NEW... 19 NULL... 20 PROGRAMMING COMMANDS... 22 PROG and FPROG... 22 PROG1 and FPROG1... 22 PROG2 and FPROG2... 23 PROG3 and FPROG3... 23 PROG4 and FPROG4... 23 PROG5 and FPROG5... 24 PROG6 and FPROG6... 24 MEMORY ALLOCATION VARIABLES... 26 FREE... 26 LEN... 26 MTOP... 27 OPERATORS... 28 Precedence of Operators... 28 ARITHMETIC OPERATORS... 29 =... 29 +... 29 -... 29 *... 29 /... 29 **... 30 SQR... 30 LOGARITHMIC OPERATORS... 31 EXP... 31 LOG... 31 TRIGONOMETRIC OPERATORS... 32 SIN... 32 COS... 32 TAN... 32 ATN... 33 RELATIONAL OPERATORS... 34 =... 34 <>... 34 <... 34 >... 34 <=... 35 >=... 35 BITWISE LOGICAL OPERATORS... 36.AND.... 36.OR.... 36.XOR.... 36 NOT... 36 STRING OPERATORS... 38 STRING... 38 ASC... 40 CHR... 41 VALUE OPERATORS... 42 ABS... 42 INT... 42 PI... 42 RND... 42 SGN... 42 SPECIAL OPERATORS... 43 XTAL... 43 IE... 44 IP... 45 PCON... 46 PORT1... 48 RCAP2... 49 T2CON... 50 TCON... 52 TMOD... 54 ii

TIME... 56 TIMER0... 57 TIMER1... 58 TIMER2... 59 INSTRUCTIONS... 60 LOOPING, SUBROUTINES, BRANCHING AND CONTROL... 60 DO - UNTIL... 61 DO - WHILE... 62 FOR - TO - STEP - NEXT... 63 GOSUB - RETURN... 64 ON - GOSUB - RETURN... 65 CALL... 67 GOTO... 68 ON - GOTO... 69 IF - THEN - ELSE... 70 RROM... 71 STOP... 73 END... 74 REM... 75 INPUT/OUTPUT... 76 BAUD... 76 GET... 77 INPUT... 78 PWM... 79 UI1... 81 UI0... 81 UO1... 82 UO0... 82 PRINTING... 83 PRINT or P. or?... 83 PRINT# or P.# or?#... 83 PH0. and PH1.... 85 PH0.# and PH1.#... 85 PRINT@ or P.@ or?.@... 86 PH0.@ or PH1.@... 86 PRINT FORMATTING... 86 CR... 86 SPC... 87 TAB... 87 USING or U.... 88 DATA CONTROL AND STORAGE... 89 DBY... 89 CBY... 91 XBY... 92 ST@... 93 LD@... 94 CLEAR... 95 CLEARS... 96 DATA... 97 READ... 97 RESTORE... 97 DIM... 98 LET... 99 PGM... 100 PUSH... 101 POP... 102 INTERRUPTS AND REAL-TIME CLOCK... 103 CLEARI... 103 ONERR... 104 ONEX1... 105 ONTIME... 106 IDLE... 107 RETI... 108 CLOCK1... 109 iii

CLOCK0... 109 APPENDIX A - ERROR MESSAGES... 110 A-STACK... 111 ARITH. UNDERFLOW... 111 ARITH. OVERFLOW... 111 ARRAY SIZE... 111 BAD ARGUMENT... 112 BAD SYNTAX... 112 C-STACK... 112 CAN'T CONTINUE... 112 DIVIDE BY ZERO... 112 I-STACK... 112 MEMORY ALLOCATION... 113 NO DATA... 113 PROGRAMMING... 113 PROM MODE... 113 APPENDIX B - RUN-TIME, STARTUP and RESET OPTIONS... 114 IMPLEMENTING "PSEUDO DMA"... 114 RUN TRAP OPTION... 115 CUSTOM RESET ROUTINES... 116 DISABLING CONTROL-C... 117 APPENDIX C - MEMORY USAGE AND STORAGE FORMATS... 118 SPECIAL FUNCTION REGISTERS... 118 PROGRAM MEMORY... 118 DATA MEMORY... 119 OVERLAID PROGRAM AND DATA MEMORY... 119 EA PIN (PIN 31)... 120 INTERNAL AND EXTERNAL MEMORY USAGE... 121 Bit and Byte Addressing Conventions... 121 Internal Data Memory Allocation... 121 External Data Memory Allocation... 123 Internal Program Memory Allocation... 124 External Program Memory Allocation... 124 STRING AND VARIABLE STORAGE... 126 String Storage... 127 Variable Storage... 127 FLOATING-POINT FORMAT... 128 PROGRAM STORAGE FORMAT - RAM... 128 PROGRAM STORAGE FORMAT - EPROM... 129 STACK LOCATION AND USE... 130 Control Stack... 130 Argument Stack... 130 Internal Stack... 130 APPENDIX D - BAUD RATE GENERATION OPTIONS... 131 EXTERNAL CLOCKING OF BAUD RATE GENERATORS... 131 TIMER2 BAUD RATE GENERATION... 131 Internal Clock... 131 External Clock... 132 TIMER1 BAUD RATE GENERATION... 132 Internal Clock... 132 External Clock... 132 EXAMPLE OF BAUD RATE CALCULATION... 133 EXAMPLE OF TIMER1 AND TIMER2 BAUD RATE GENERATION... 133 APPENDIX E - ASSEMBLY LANGUAGE INTERFACE... 134 iv

Shared Processor Resources... 134 Register Availability... 134 Internal Stack Availability... 135 Calling BASIC-52 Routines from Assembly Language... 135 CONTROL and SYSTEM OPERATIONS... 137 Return to Command Mode, Opbyte 00H... 137 Enter Run mode, Opbyte 42H... 137 Crystal Dependent Calculations, Opbyte 3AH... 137 Program an EPROM, Opbyte 04H... 138 SYSTEM CONTROL VALUES... 139 FREE, Opbyte 29H... 139 LEN, Opbyte 2AH... 139 MTOP, Opbyte 2CH... 139 XTAL, Opbyte 2BH... 139 DATA CONVERSION... 139 Convert Floating-point Value to Integer, Opbyte 01H... 139 Convert Integer Value to Floating-point, Opbyte 9AH... 140 BASIC and ASSEMBLY LANGUAGE DATA TRANSFER... 140 PUSH Floating-point Value onto Argument Stack, Opbyte 02H... 140 POP Floating-point Value from Argument Stack, Opbyte 03H... 141 CONSOLE I/O... 141 String Input, Opbyte 05H... 141 String Output, Opbyte 06H... 142 Output a Carriage Return - Line Feed, Opbyte 07H... 142 Output Character, Opbyte 80H... 142 Output Floating-point Value, Opbyte 90H... 142 Output Integer in HEX Format, Opbyte 98H... 143 Get a Character, Opbyte 41H... 143 GET, Opbyte 28H... 143 SPECIAL OPERATORS... 143 CBY operator, Opbyte 20H... 143 DBY Operator, Opbyte 24H... 144 XBY Operator, Opbyte 25H... 144 IE, Opbyte 2EH... 144 IP, Opbyte 2FH... 144 PCON, Opbyte 38H... 144 PORT1, Opbyte 37H... 145 RCAP2, Opbyte 36H... 145 T2CON, Opbyte 33H... 145 TCON, Opbyte 34H... 145 TIME, Opbyte 2DH... 145 TIMER0, Opbyte 30H... 145 TIMER1, Opbyte 31H... 145 TIMER2, Opbyte 32H... 146 TMOD, Opbyte 35H... 146 ARITHMETIC OPERATORS... 146 ADD, Opbytes 0BH and 82H... 146 DIVIDE, Opbytes 0CH and 8AH... 147 MULTIPLY, Opbytes 0AH and 88H... 147 SUBTRACT, Opbytes 0DH and 84H... 147 ** - Exponentiation, Opbyte 09H... 147 SQR - Square Root, Opbyte 1FH... 147 LOGARITHMIC OPERATORS... 148 EXP - Logarithmic Exponentiation e ARG, Opbyte 21H... 148 LOG - Natural Logarithm, Opbyte 23H... 148 TRIGONOMETRIC OPERATORS... 148 ATN - Arc Tangent, Opbyte 22H... 148 COS - Cosine, Opbyte 1CH... 148 SIN - Sine, Opbyte 1EH... 148 TAN - Tangent, Opbyte 1DH... 148 RELATIONAL OPERATORS... 149 = Equality, Opbyte 12H... 149 >= Greater Than or Equal, Opbyte 13H... 149 <= Less Than Or Equal, Opbyte 14H... 149 v

<> Not Equal, Opbyte 15H... 149 < Less Than, Opbyte 16H... 149 > Greater Than, Opbyte 17H... 149 LOGICAL OPERATORS... 150 Logical AND, Opbyte 0FH... 150 Logical OR, Opbyte 10H... 150 Logical XOR, Opbyte 0EH... 150 NOT - One's Complement, Opbyte 1BH... 150 BASIC-52 TEXT STRING OPERATIONS... 150 Evaluate an Expression, Opbyte 39H... 150 Get Text String Character, Opbyte 3FH... 151 Get Text Character and Advance Pointer, Opbyte 40H... 151 VALUE OPERATORS... 152 ABS - Absolute value, Opbyte 18H... 152 INT - Integer, Opbyte 19H... 152 PI - 3.1415926, Opbyte 26H... 152 RND - Random Number, Opbyte 27H... 152 SGN - Sign of a Number, Opbyte 1AH... 152 INTERRUPTS... 153 APPENDIX F - COMMAND and INSTRUCTION EXTENSIONS... 155 ADDING BASIC-52 COMMANDS and INSTRUCTIONS... 155 BASIC-52 TOKENS AND KEYWORDS... 157 Index... 158 vi