Electronic Circuits and Projects Forum



Mov r1, r0, mcu 8051

« First 12
  1. #11
    duffy duffy is offline
    Quote Originally Posted by Ian Rogers View Post
    You've got me at it now.... I posted wrong..
    MOV A, 80H ; Move contents of A to 0x80H
    No, you had it right the first time - Intel's the one that's backasswards, so MOV A, 80H moves the contents of 80H into A.
    0
    Last edited by duffy; 31st March 2012 at 01:56 PM.
    Please respond to items in forum, not in private messages.

  2. #12
    Ian Rogers Ian Rogers is offline
    Super Moderator
    Thanks..... Its a long time since I have done "movc a,@a+dptr" with tables... I'm revisiting it now.
    0
    Last edited by Ian Rogers; 31st March 2012 at 02:07 PM.
    I'd give my left arm to be ambidextrous
    Nigel's tutorials in asm... http://www.winpicprog.co.uk/
    Nigel's tutorials.. re-written in C. http://www.electro-tech-online.com/c...torials-c.html

  3. #13
    Jon Wilder Jon Wilder is offline
    I see EXACTLY what is going wrong. You're storing the values in code memory, and code memory cannot be directly addressed by the code.

    The only way to read data values that are stored in code memory (such as you have with the db statements) is via indirect addressing by using "MOVC" instruction to read them from code memory. This is how we do look up tables on the 8051 -

    Code :
     		org		0x0080
     
    Value		movc		A, @A+PC
    		ret
     
    		db		10
    		db		12

    Then to call the table, you load the table line value into the accumulator, then call the subroutine -

    Code :
    		mov		A,0x01
    		acall		Value

    You can also use DPTR as the offset register for this as well -

    Code :
    		org		0x0080
     
    Value		movc		A, @DPTR+PC
    		ret
     
    		db		10
    		db		12

    When it returns from the subroutine, the table line value will be stored in the accumulator.

    In regards to your question regarding if instruction and data can fit in one byte. These are not PICs. They don't have a "long instruction word" like a PIC does. Instructions are 8 bit instructions and data is 8 bit data. 8051 uses what is called a "modified Harvard architecture". It's not a true Harvard processor like the PIC is.

« First 12
Tags
Similar Threads
Thread Starter Forum Replies Last Post
MCU 8051 family why don't we discuss giaosucan 8051/8951 7 30th July 2006, 08:02 PM
spec sheet for the 8051 MCU mugzzzzy Electronic Projects Design/Ideas/Reviews 2 18th February 2004, 04:13 AM
need the 8051 instruction sheet sinan mohammed Datasheets, Manuals or Parts 5 16th September 2003, 01:30 AM
8051 and it`s family (8951,2051,......)and ADC0804 massoti General Electronics Chat 2 1st April 2003, 03:14 PM
using 8051 as pulse counter waqar Electronic Projects Design/Ideas/Reviews 0 13th March 2003, 04:06 PM
Electronic Circuits  |  Learning Electronics

Join our community with over 100,000 Members! It's free, easy and when you're logged in you have many more features! Click to register.
Page Time: 0.06488 seconds      Memory: 7,298 KB      Queries: 17      Templates: 0