Is there a better assembler which will assemble my *.asm sources for the 8051 microprocessor correctly Why would you want one that assembles faulty source correctly, I know of none such. It would, of course, be wonderful if someone could make an assembler that understood what we ment, not what we said.
MOV R4,#FF you should get an error FF symbol not found.
you are stating load the address of symbol FF, NOT load 0xff
meko wrote MOV R4,#FF which I'm sure was meant to be MOV R4,#0FFh to indicate a constant value of FFh rather that a symbol name of FF. The assembled code for this bears out this conclusion.
Opcode 75 04 FF is a MOV dir,#data instruction, which results in loading the constant 0FFh into RAM location 0004h which just happens to also correspond to register R4 in register bank 0.
Opcode 7C FF is a MOV Rn,#data instruction, which results in loading the constant 0FFh into register R4 in the currently selected register bank.
If register bank 0 is selected then the two opcodes are functionally equivalent, the main difference being their corresponding opcode length and execution time. If, however, a different register bank was selected then the two opcodes result in significantly different results.
In Keil land, specifying a register name using the following syntax: MOV R4,#0FFh results in 7C FF
Specifying thus: MOV AR4,#0FFh results in
75 04 FF if bank 0 selected 75 0C FF if bank 1 selected 75 14 FF if bank 2 selected 75 1C FF if bank 3 selected
How, you ask, does the assembler know which bank you've selected? Well you have to give it a little hint with the USING directive. You also have to make sure you've actually programmed the PSW register to correctly select the register bank you've intended. Otherwise your correctly assembled code won't produce correct results .