4.4. YOUR FIRST PROGRAM 51
3. If the instruction is a RMB instruction, then add the value after the mnemonic
to the location counter.
4. If the instruction is a FCB command, then a sequence of comma-separated
values following mnemonic are stored in consecutive locations starting from
the address given in the location counter. The location counter is incre-
mented by the amount of memory needed to store these bytes. FCC is a
convenient way to specify a sequence of ASCII characters. Thus the follow-
ing two statements are equivalent
FCB 72, 69, 76, 76, 79
FCC /HELLO/
The FDB instruction is similar to FCB, except the values are interpreted as 16-
bit numbers. These initializations are done in your PC and then transferred
to the HC11 via the S19 file. If these memory locations in your HC11 are
modified after the transfer, either by your program or by accident, then you
have to reload your S19 file! Also, DO NOT use these commands to initialize
variables. Your program will work only once. If you rerun your program,
the variables will not be reinitialized!
Here is an example of defining variables and constants (variables that your pro-
gram will not modify).
ORG $3000 ;Start of data section.
V1 RMB 4 ; set aside 4 bytes. EQUate V1 to first address
V2 RMB 11; set aside 11 bytes
THOU FCB 3, $E8 ; Initialize 16-BIT variable called THOU
BUFF FILL $22,18 ; same as fcb with $22 repeated 18 times
BUF2 RMB 20
OPT s ; turn on symbol dump option
It is a good idea to turn on the symbol dump option. This will cause assembler
to print all the symbols at the end of your program listing. Type in the above
sequence of instructions and assemble it. Look at the LST file and write down
what the symbols V1, V2 etc., are EQUated to and explain the results.
4.4 Your first program
We will now write the first program. When writing assembly code, a convenient
way to document your code is to write the pseudocode. Rather than invent another
Comentarios a estos manuales