ВУЗ: Не указан

Категория: Не указан

Дисциплина: Не указана

Добавлен: 15.06.2025

Просмотров: 2093

Скачиваний: 0

ВНИМАНИЕ! Если данный файл нарушает Ваши авторские права, то обязательно сообщите нам.

Chapter 5

CBY(expression)

C,R

Retrieves the value at expression in program, or code, memory.

CHR(expression)

C,R

Converts expression to its ASCII character.

CLEAR

C,R

Sets all variables to 0, resets all stacks and interrupts evoked by BASIC.

CLEARI

C,R

Clears all interrupts evoked by BASIC. Disables

ONTIME, ONEX1.

CLEARS

C,R

Resets BASIC-52’s stacks. Sets control stack = 0FEh, argument stack = 1FEh, in-

ternal stack = value in 3Eh in internal RAM.

CLOCK0

C,R

Disables the real-time clock.

CLOCK1

C,R

Enables the real-time clock.

CONT

C

Continues executing program after STOP or CONTROL+C.

COS(expression)

C,R

Returns the cosine of expression

CR

PRINT option. Causes a carriage return, but no line feed, on the host display.

DATA expression [,...,expression]

R

Specifies expressions to be retrieved by a READ statement.

DBY(expression)

C,R

Retrieves or assigns a value at expression in internal data memory.

DIM array name [(size)] [,...array name(size)]

C,R

Reserves storage for an array. Default size is 11 (0-10). Size limits are 0-254.

Example:

DIM B(100)

Reserves storage for 100-element array B

76

The Microcontroller Idea Book


Programming

DO: [program statements]: UNTIL relational expression

R

Executes all statements between DO and UNTIL until relational expression is

true.

DO: [program statements]: WHILE relational expression

R

Executes all statements between DO and WHILE until relational expression is

false.

END

R

Terminates program execution.

EXP (expression)

C,R

Raises e (2.7182818) to the power of expression

FOR counter variable = start-count expression

C,R

TO end-count expression [

STEP count-increment expression]: [program statements]:

NEXT [counter variable]

Executes all statements between FOR and NEXT the number of times specified by

the counter and step expressions.

FPROG, FPROG1-FPROG6

C

Like PROG, PROG1-PROG6, but using Intelligent programming algorithm.

FREE

C,R

Returns the number of bytes of unused external data RAM.

GET

R

Contains the ASCII code of a character received from the host computer’s key-

board. After a program reads the value of GET (For example, G=GET), GET re-

turns to 0 until a new character arrives.

GOSUB line number

R

Causes BASIC-52 to transfer program control to a subroutine beginning at line

number. A RETURN statement returns control to the line number following the

GOSUB statement.

GOTO line number

C,R

Causes BASIC-52 to jump to line number in the current program.

IDLE

R

Forces BASIC-52 to wait for ONTIME or ONEX1 interrupt.

The Microcontroller Idea Book

77


Chapter 5

IE

C,R

Retrieves or assigns a value to the 8052’s special function register IE.

IF relational expression

R

THEN program statements

[ELSE] [program statements]

If relational expression is true, executes program statements following THEN. If

relational expression is false, executes program statements following ELSE, if

used.

INPUT [“Prompt message”][,] variable [,variable] [,...variable]

R

Displays a question mark and optional prompt message on the host computer and

waits for keyboard input. Stores input in variable(s). A comma before the first

variable suppresses the question mark.

INT(expression)

C,R

Returns integer portion of expression.

IP

C,R

Retrieves or assigns a value to the 8052’s special function register IP.

LD@ expression

C,R

Retrieves a 6-byte floating-point number and places it on the argument stack. Ex-

pression points to the most significant byte of the number.

LEN

C,R

Returns the number of bytes in the current program

[LET] variable = expression

C,R

Assigns a variable to the value of expression. Use of LET is optional.

LIST[line number][-line number]

C,R

Displays the current program on the host computer.

LIST# [line number][-line number]

C,R

Writes the current program to LPT (pin 8).

LIST@ [line number][-line number]

C,R

Writes the current program to a user-written assembly-language output driver at

40C3h. Setting bit 7 of internal data memory location 27H enables the driver.

78

The Microcontroller Idea Book


Programming

LOG(expression)

C,R

Returns natural logarithm of expression.

MTOP [=highest address in RAM program space]

C,R

Assigns or reads the highest address BASIC-52 will use to store variables,

strings, and RAM programs. Usually 7FFFh or lower, since EPROM space be-

gins at 8000h.

NEW

C

Erases current program in RAM; clears all variables.

NOT (expression)

C,R

Returns 1’s complement (inverse) of expression.

NULL [integer]

C

Sets the number (0-255) of NULL characters (ASCII 00) that BASIC-52 sends

automatically after a carriage return. Only very slow printers or terminals need

these extra nulls.

ON expression GOSUB line number [,line number] [,...,line number]

R

Transfers program control to a subroutine beginning at one of the line numbers in

the list. The value of expression matches the position of the line number selected,

with the first line number at position 0.

Examples:

X=1

ON X GOSUB 100,200,400

Transfers program control to a subroutine at line 200 (position 1 in the list)

X=0

ON X GOSUB 800,300

Transfers program control to a subroutine at line 800 (position 0 in the list)

ON expression GOTO line number [,line number] [,...,line number]

R

Transfers program control to one of the line numbers in a list of numbers. The

value of expression matches the position of the line number selected, with the first line number at position 0.

Example:

X=0

ON X GOTO 800,300

Transfers program control to line 800 (position 0 in the list)

The Microcontroller Idea Book

79