int e l 9.2 GENERAL PURPOSE ROUTINES Accessing MCS BASIC-52 routines with assembly language is easy. The user just loads the ACCUMU- LATOR with a specific value and CALLS LOCATION 48 (30H). The value placed in the ACCUMULATOR determines what operation will be performed. Unless otherwise stated, the CONTENTS of the DPTR and REGISTER BANK 0 (RB0) will ALWAYS be altered when calling these routines. The generalized form for accessing MCS BASlC-52's routines is as follows: ANL PSW,#11100111B ; make sure RB0 is selected MOV A,#OPBYTE ; load the instruction CALL 30H ; execute the instruction The value of OPBYTE determines what operation will be performed. The following operations can be performed:
OPBYTE = 0 (00H) RETURN TO COMMAND MODE This instruction causes MCS BASIC-52 to enter the COMMAND MODE. Control of the CPU is handed back to the MCS BASIC-52 interpreter and BASIC will respond by outputting a READY and a PROMPT character (>). OPBYTE = 1 (01H) POP ARGUMENT STACK AND PUT VALUE IN R3:R1 This instruction converts the value that is on the ARGUMENT STACK to a 16 BIT BINARY INTEGER and returns the BINARY INTEGER in registers R3 (high byte) and R1 (low byte) of REGISTER BANK 0 (RB0). The ARGUMENT STACK gets popped after this instruction is executed. If the value on the ARGUMENT STACK cannot be represented by a 16-BIT BINARY NUMBER (i.e.
it is NOT between 0 and 65535 (0FFFFH) inclusive), BASIC WILL TRAP THE ERROR and print a BAD ARGUMENT ERROR MESSAGE. The BINARY VALUE returned is TRUNCATED, NOT ROUNDED. EXAMPLE: BASIC PROGRAM - 10 PUSH 20 20 CALL 5000H ASSEMBLY LANGUAGE PROGRAM - ORG 5000H MOV A.#01H ; load opbyte CALL 30H ; RB0 still selected ; ; at this point R3 (of RB0) = 01H ; and R1 (of RB0) = 04H ; so, R3:R1 = 260, which was the value ; that was placed on the ARGUGENT STACK - 106 -