This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

IF statement in assembly

I'm wondering, Does assembler support if staments? (like a C program) Tried something very simple:

org 0h
sjmp BEGIN

org 50h
BEGIN:
	IF R0 == #45
		MOV A, #54
		CPL A
	ELSE
		MOV A, #45
		CPL A
	ENDIF
END

After building and enter debug mode I found this code seems to be a #ifdef like statement instead of a C like if-then-else statement. Did I do something wrong or the assembler does no support if statement?

Parents
  • "I think writing in C would make the program too big for 4kbytes of ROM."

    Not necessarily.
    Sure, if you write bad, inefficient 'C' it will be bloated - but if you write it carefully, with due consideration for the underlying architecture, and take full advantage of all the optimisation options, there is absolutely no reason at all why you shouldn't use C51 to write useful programs in under 4K.

    Search this forum, and the C51 Manual for tips on writing efficient 'C' for the 8051.

Reply
  • "I think writing in C would make the program too big for 4kbytes of ROM."

    Not necessarily.
    Sure, if you write bad, inefficient 'C' it will be bloated - but if you write it carefully, with due consideration for the underlying architecture, and take full advantage of all the optimisation options, there is absolutely no reason at all why you shouldn't use C51 to write useful programs in under 4K.

    Search this forum, and the C51 Manual for tips on writing efficient 'C' for the 8051.

Children
No data