what's wrong with this code and why PC goes up by 2?

Discussion in 'Embedded Systems and Microcontrollers' started by PG1995, Mar 30, 2012.

  1. PG1995

    Thread Starter Active Member

    Apr 15, 2011
    753
    5
    Hi

    I'm using MCU 8051. Please have a look on the video and please help me with the queries below (you can also queries embedded in the video): http://www.youtube.com/watch?v=RKn9tEpM5XE

    Code ( (Unknown Language)):
    1.  
    2. ORG 0H
    3.  
    4.     MOV A, 80H
    5.     MOV R0, 81H
    6.  
    7.     ORG 80H
    8.     DB  10
    9.     DB  12
    10.  
    11. END
    12.  
    Q1: There is some problem with the code because see the value "A" has taken on. The value for R0 is also wrong.

    Q2: The value of PC goes up by 2 for every line. I have read that this instruction MOV A, 80H occupy two bytes instead of one and that's the reason PC goes up by '2' for every line of the code. But can't that instruction be saved on a single byte so that the PC goes up by only '1' byte?

    Regards
    PG
     
  2. nigelwright7557

    Senior Member

    May 10, 2008
    487
    71
    A should now hold 10 and R0 12.

    There is an opcode and an operand, this takes two bytes not one.
     
Loading...