Reply
Newbie
meko
Posts: 1
Registered: ‎11-20-2007

asm51.exe

I found out that the MOV R4,#FF is assembled as 7504FF instead of 7CFF.
Is there a better assembler which will assemble my *.asm sources for the 8051 microprocessor correctly.

best regards, meko
Contributor
dan_z80
Posts: 21
Registered: ‎01-19-2006

Re: asm51.exe

What ASM version you use?

[This message has been edited by dan_z80 (edited November 20, 2007).]
dan_z80
Contributor
dan_z80
Posts: 21
Registered: ‎01-19-2006

Re: asm51.exe

For Keil: C:\Keil\C51\BIN\A51.EXE

MOV R4,#0FFh - > 7C FF

[This message has been edited by dan_z80 (edited November 20, 2007).]
dan_z80
Esteemed Contributor
erikm
Posts: 6,313
Registered: ‎08-13-2003

Re: asm51.exe

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

Erik
erik
Valued Contributor
worknhard9062
Posts: 1,090
Registered: ‎09-23-2002

Re: asm51.exe

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 /.


------------------
Regards,
Steve C.
Regards,
Steve C.