Assembler code




org 00h

mov a,#34 ;put 34 in acc

clr a ;clear the acc


asm51 test


1. There are three types of instructions:

assembler controls

$MOD2051 tells the assembler to read predefined

register names from the file mod2051

assembler directives or pseudo-operations

cseg, org these do not generate machine code

real instructions

mov, clr these do generate machine code

2. The assembler produces test.lst:

0000 7422 mov a,#34

0002 e4 clr a

The numbers in the 1st column are the address where the machine code (2nd column) is stored.

and test.hex, which contains machine code in hexadecimal format. It is read by the simulator.

3. The first instruction generates 2 bytes of code. The second only one.

4. We can include comments in our code by inserting a semicolon.

All text after a ; to the end of the line is ignored.

5. We format assembler programs so that they line up on tab stops.

6. We can use either upper or lower case

7. The program does not stop cleanly. Location 3 can contain anything and will be executed after the clr instruction

8. There are 256 instructions!

The first byte is different for different instructions

There may be 1 or 2 more bytes, depending on the instruction.

9. The second instruction could have been

mov a,#00

This takes the same time as clr (1 cycle)

but is a 2 byte instruction!

10. Assembler programs should be as concise (small) and as fast as possible.

Sometimes these requirements conflict. We may need to trade space for speed or vice-versa.

159.33 Assembler 2 - 1