Adding data to an "array" in ASM


Closed Thread
Results 1 to 12 of 12

Hybrid View

  1. #1
    Join Date
    Jun 2007
    Location
    Mansfield, UK
    Posts
    697


    Did you find this post helpful? Yes | No

    Default

    Theres 2 reasons.

    1) For a while now ive been wanting to learn ASM. By learning ASM a lot of things in other languages like PBP and even C are starting to make sense. I think its a very usefull thing to learn. It helps to understand how things are actually working inside the chip

    2) Probably the most important one. This section of code is only part of a much bigger program. Its actually the same one from my other thread which is titled "PBP Using too many instructions". ASM uses a lot less instructions so i can finally add in the extra features that i wanted to do in PBP but couldnt because the code was running too slow.

  2. #2
    Join Date
    Jun 2007
    Location
    Mansfield, UK
    Posts
    697


    Did you find this post helpful? Yes | No

    Default

    Im having a bit of trouble getting this code working.

    Heres some test code i wrote
    Code:
    	MOVLW	38
    	MOVWF	FSR0
    	
    	MOVLW	57
    	MOVWF	38
    	MOVFF	INDF0,TXREG
    This code should set W to 38 then move that value to FSR0.

    It then sets W to 57 (my test value) and moves W to memory location 38. Then it sends INDF0 over serial to the PC. I would expect INDF0 to reference memory location 38 and send 57 but it doesnt. I keep getting random values (a different one each time i reset the PIC asif its an uninitialized memory location). Its not a serial problem. MOVWF TXREG sends the correct value.

    I know im writing data to memory location 38 and if i read FSR0 back it also says 38. Did i miss something obvious? It seems like both are accessing memory location 38 but in 2 different blocks of memory (im not sure if thats possible)

  3. #3
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    FSR0 is a constant that equates to 0.
    It's for use with the LFSR opcode, LFSR FSR0, 38

    The address for the FSR0 is 2 bytes, FSR0L and FSR0H.
    So with your example, it could be one of these ...
    Code:
    	LFSR  FSR0, 38
    	
    	MOVLW	57
    	MOVWF	38
    	MOVFF	INDF0,TXREG
    ... OR ...
    Code:
    	MOVLW	38
    	MOVWF	FSR0L
    	CLRF	FSR0H
    	
    	MOVLW	57
    	MOVWF	38
    	MOVFF	INDF0,TXREG
    hth,
    DT

  4. #4
    Join Date
    Jun 2007
    Location
    Mansfield, UK
    Posts
    697


    Did you find this post helpful? Yes | No

    Default

    Thanks. Thats working perfectly now

Similar Threads

  1. Using Nokia LCD
    By BobP in forum mel PIC BASIC Pro
    Replies: 300
    Last Post: - 3rd May 2018, 04:47
  2. Read/Write Problem
    By Tobias in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 10th February 2010, 01:51
  3. Big characters on HD44780 4x20
    By erpalma in forum mel PIC BASIC Pro
    Replies: 23
    Last Post: - 7th January 2007, 02:21
  4. LCD + bar graph
    By DynamoBen in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 5th October 2005, 14:50
  5. Sinus calculating !
    By Don Mario in forum mel PIC BASIC Pro
    Replies: 29
    Last Post: - 28th November 2004, 23:56

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts