Intel mcs-48 manual ADD A, # ALFA*BETA/2, Cpla ADD A, REG, SUB R7

Models: mcs-48

1 478
Download 478 pages 26.88 Kb
Page 21
Image 21

INTRODUCTION

allows instructions to be added or deleted throughout the program during debugging without requiring that any jump addresses be changed.

The next instruction MOV @RO, A can be verbalized as, Move to the data memory location addressed by RO, the contents of the accumulator. The @ sign indicates an indirect operation whereby the contents of either register 0 or register 1 acts as a pointer to the data memory location to be operated on.

The last instruction is a Decrement and Jump if Not Zero instruction which acts in combination with the specified register as a loop counter. In this case register 2 is loaded with 5 initially and then decremented by one each time the loop is executed. If the result of the decrement is not zero, the program jumps to INP and executes another input operation. The fifth time thru the loop the result is zero and execution falls through to whatever routine follows the DJNZ instruction.

In addition to the normal features provided by assemblel'3,more advanced assemblers such as that for the MCS-48 offer such things as evaluation of expressions at assembly time, conditional assembly, and macro capability.

1.Evaluation of Expressions - Certain assemblers allow the use of arithmetic expressions and multiple symbols in the operand portion of instructions. For instance the MCS-48 assembler accepts instructions such as:

ADD A, # ALFA*BETA/2

ALFA and BETA are two previously defined symbols. At assembly time the expression ALFA*BETA/2 will be evaluated and the resulting number (which is the average of ALFA and BETA) will be treated as immediate data and .designated as the second byte of the ADD immediate instruc- tion. This expression has allowed the immediate data of this instruction to be defined in a single statement and eliminated the need for a third symbol .equal to ALFA*BETA/2.

2.Conditional Assembly - Conditional as- sembly allows the programmer to select only certain portions of his assembly language (source) program for conversion to machine (object) code at assembly time. This allows for instance, the inclusion of various "debug" routines to be included in the program during development. Using conditional assembly, they can then be left out when the final assembly is done.

Conditional assembly also allows several versions of one basic program to be generated by selecting various portions of a larger program at assembly time.

3.Macro's- A macro instruction is essen- tially a symbol which is recognized by the

assembler to represent a specific sequence of several standard instructions. A macro is a shorthand way of generating the same sequence of instructions at several locations in a program without having to rewrite the sequence each time it is used. For example, a typical macro instruction might beonewhich performs a subtract operation. The 8048 does not have a subtract instruction as such but the operation can be performed easily with three instructions:

CPLA

ADD A, REG

CPLA

This routine subtracts a register from the accumulator and leaves the result in the accumulator. This sequence can be defined as a macro with the name SUB and an operand which can be RO to R7. To subtract R7 from the accumulator then, the program- mer merely has to write:

SUB R7

and the assembler will automatically insert the three instructions above with R7 substi- tuted for REG.

Once the assembly language source code is written it can be converted to machine executable object code by passing it through an assembler program. The MCS-48 assem- bler is a program which runs on the 8080- based Intellec MDS system explained in the next section.

1-12

Page 21
Image 21
Intel mcs-48 manual ADD A, # ALFA*BETA/2, Cpla ADD A, REG, SUB R7