1

We're tasked to identify the problem in next code:

ORG 0000H
MAIN:
    CLR A
    MOV A, FFFFH
    MOV B, FFH
AGAIN: DEC A
    DJNZ B, AGAIN
END

On MOV A, FFFFH and MOV B, FFH EdSim51 is having an

unknow label on both FFFFH and FFH.

I don't have any experience on this type of code. I think it's on the amount of bits each register holds, but I'm not sure. Can someone explain it to me.

Sep Roland
  • 33,889
  • 7
  • 43
  • 76
Araine
  • 15
  • 4
  • 2
    That's not 8086 / x86 code at all. 8051 I think, based on the EdSim51 name. – Peter Cordes Jun 06 '20 at 03:12
  • 1
    The "unknown label" problem is a duplicate of [MASM for 8086, symbol not defined: ffh](https://stackoverflow.com/q/42800933) / [How to represent hex value such as FFFFFFBB in x86 assembly programming?](https://stackoverflow.com/q/11733731) / [How do I write letter-initiated hexadecimal numbers in masm code?](https://stackoverflow.com/q/33276232). FFH is assumed to be a label name because it doesn't start with a *decimal* digit like `0FFh` – Peter Cordes Jun 06 '20 at 03:13
  • But yes, I think 8051 registers are only 8 bit, so your assembler would warn about truncation of 0FFFFh. – Peter Cordes Jun 06 '20 at 03:17
  • Sorry for the confusion, it my first time doing this. And thank you for the responds. – Araine Jun 06 '20 at 03:33

1 Answers1

3

The instruction MOV can be used with different operands. In your case, the assembler looks for an "immediate value". This could be given as a label or a literal number.

For us humans, both FFFFH and FFH look as literal numbers because we recognize the hexadecimal digits and the "H" at the end.

But the software uses a most simple method: If the first character is a decimal digit, the operand is a literal number. If it is a letter, it is a label.

That's why EdSim51 (or its assembler, respectively) takes them as labels. And since none of the labels is defined, it reports the error you get.

However, if you put a zero "0" in front of both, resulting in 0FFFFH and 0FFH, the first instruction might give you another error: The value is too large for the instruction, which expects an 8-bit width.

the busybee
  • 10,755
  • 3
  • 13
  • 30