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

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

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

Добавлен: 15.06.2025

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

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

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

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


Chapter 5

ONERR line number

R

Passes control to line number following an arithmetic error. Arithmetic errors in-

clude ARITH. OVERFLOW, ARITH. UNDERFLOW, DIVIDE BY ZERO, and

BAD ARGUMENT.

ONEX1 line number

R

On interrupt 1 (pin 13), BASIC-52 finishes executing the current statement, and

then passes control to an interrupt routine beginning at line number. The interrupt

routine must end with RETI.

ONTIME number of seconds, line number

R

When TIME = number of seconds, BASIC-52 passes control to an interrupt rou-

tine beginning at line number. The interrupt routine must end with RETI.

CLOCK1 starts the timer.

expression .OR. expression

C,R

Logical OR

P.

same as PRINT

PCON

C,R

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

PGM

C,R

Programs an EPROM, EEPROM, or NV RAM with data from memory. The fol-

lowing data must be stored in internal data memory in the locations listed:

1Bh,19h

High byte, low byte of first address of data to program

1Ah,18h

High byte, low byte of first address to be programmed - 1

1Fh,1Eh

High byte, low byte indicating number of bytes to program

40h,41h

High byte, low byte indicating width of programming pulse.

High byte = ((65536 - pulse width in seconds * XTAL/12) / 256.

Low byte = ((65536 - pulse width in seconds * XTAL/12) .AND. 0FFh.

26h

For Intelligent programming, set bit 3.

For 50-millisecond programming, clear bit 3.

PH0.

C,R

Same as PRINT, but displays values in hexadecimal format. Uses two digits to

display values less than 0FFh.

PH0.#

C,R

Same as PRINT#, but displays values in PH0. hexadecimal format

80

The Microcontroller Idea Book


Programming

PH0.@

C,R

Same as PRINT@, but outputs values in PH0. hexadecimal format.

PH1.

C,R

Same as PRINT, but displays values in hexadecimal format. Always displays

four digits.

PH1.#

C,R

Same as PRINT#, but displays values in PH1. hexadecimal format.

PH1.@

C,R

Same as PRINT@, but outputs values in

PH1. hexadecimal format.

PI

C,R

Constant equal to 3.1415926.

POP variable [,...variable]

C,R

Assigns the value of the top of the argument stack to variable.

PORT1

C,R

Retrieves or assigns a value to PORT1 (pins 1-8).

PRINT [expression] [,...expression] [,]

C,R

Displays the value of expression(s) on the host computer. A comma at the end of the statement suppresses the CARRIAGE RETURN/LINEFEED. Values are separated by two spaces. Additional PRINT options are CR, SPC, TAB, USING.

PRINT#

C,R

Same as PRINT, but outputs to LPT (pin 8). BAUD and XTAL values affect the

PRINT# rate.

PRINT@

C,R

Same as PRINT, but outputs to a user-defined output driver. Requires an assem-

bly-language output routine at 403Ch in external program memory. Setting bit 7

of internal data memory location 24h enables the output routine.

PROG

C

Stores the current RAM program in the EPROM space.

The Microcontroller Idea Book

81