• AVR Freaks

Helpful ReplyHot!need help on a assembly code

Author
soleil_sword
Starting Member
  • Total Posts : 47
  • Reward points : 0
  • Joined: 2009/03/12 14:03:59
  • Location: 0
  • Status: offline
2019/05/25 19:40:16 (permalink)
0

need help on a assembly code

Hi all,
 
It's been ages since I touched upon assembly, I appreciate if you expert could help me ...
I'm converting a 8-bit PIC (PIC16F) assembly code to PIC24 (P24FJ64GA702).
The original code looks like this:
Symbol : 64
movlw b'00010001'
movwf Symbol
movwf Symbol + 1
movwf Symbol + 2

and my code looks like this:
    
asm volatile (
".equ Symbol, 64 \n"
"MOV.b #0b00010001, W0 \n"
"MOV W0, Symbol \n"
"MOV W0, Symbol + 1 \n"
);

However, the last line "MOV W0, Symbol + 1 \n" is giving me trouble, the error looks like this:
        Error: Invalid operands specified ('mov W0,Symbol+1').
        Check operand #2.
post edited by soleil_sword - 2019/05/25 19:41:42
#1
1and0
Access is Denied
  • Total Posts : 9495
  • Reward points : 0
  • Joined: 2007/05/06 12:03:20
  • Location: Harry's Gray Matter
  • Status: offline
Re: need help on a assembly code 2019/05/25 20:22:35 (permalink)
0
First, for the PIC16 code, is "Symbol : 64" located between CBLOCK and ENDC? If so, Symbol does NOT have a value of 64.
 
Second, for the PIC24 code, the second operand must be an even number.
#2
soleil_sword
Starting Member
  • Total Posts : 47
  • Reward points : 0
  • Joined: 2009/03/12 14:03:59
  • Location: 0
  • Status: offline
Re: need help on a assembly code 2019/05/25 20:47:41 (permalink)
0
1and0
First, for the PIC16 code, is "Symbol : 64" located between CBLOCK and ENDC? If so, Symbol does NOT have a value of 64.
 
Second, for the PIC24 code, the second operand must be an even number.


thanks.
I didn't write the PIC16 code, but I understood that Symbol is declared as a address register, and the following  lines is just moving the value 0b0001001 to the registers.
 
iF PIC24 must have an even number to the second operand, how could I achieve the same functionality as the PIC16 code?
#3
dan1138
Super Member
  • Total Posts : 3166
  • Reward points : 0
  • Joined: 2007/02/21 23:04:16
  • Location: 0
  • Status: offline
Re: need help on a assembly code 2019/05/25 23:08:13 (permalink) ☄ Helpfulby wenly_yang 2019/05/27 08:58:30
4 (2)
soleil_sword
If PIC24 must have an even number to the second operand, how could I achieve the same functionality as the PIC16 code?

The approach you are using is impossibly naive.
 
The architecture  of the PIC16F is so different from the PIC24F that a slavish port of the PIC16F assembly code to a PIC24F target as shown by the code in post #1 would be foolish.
 
Your best choice is to rewrite the functionality of the PIC16F application for a PIC24F target.
#4
soleil_sword
Starting Member
  • Total Posts : 47
  • Reward points : 0
  • Joined: 2009/03/12 14:03:59
  • Location: 0
  • Status: offline
Re: need help on a assembly code 2019/05/26 09:39:10 (permalink)
0
dan1138
soleil_sword
If PIC24 must have an even number to the second operand, how could I achieve the same functionality as the PIC16 code?

The approach you are using is impossibly naive.
 
The architecture  of the PIC16F is so different from the PIC24F that a slavish port of the PIC16F assembly code to a PIC24F target as shown by the code in post #1 would be foolish.
 
Your best choice is to rewrite the functionality of the PIC16F application for a PIC24F target.


Doing what you suggested. my question is, in the PIC16F code, it used "movlb BANK1"
however, bank select register doesnt exist in PIC24F, and I can't find anything related to bank in PIC24F.
could you please tell me what I could do?
#5
1and0
Access is Denied
  • Total Posts : 9495
  • Reward points : 0
  • Joined: 2007/05/06 12:03:20
  • Location: Harry's Gray Matter
  • Status: offline
Re: need help on a assembly code 2019/05/26 12:18:37 (permalink)
4.67 (3)
I suggest you to try to understand what the PIC16 code is doing, and then rewrite the functionality using the PIC24 architecture and instruction set. Code it in C instead of embedded assembly.
#6
dan1138
Super Member
  • Total Posts : 3166
  • Reward points : 0
  • Joined: 2007/02/21 23:04:16
  • Location: 0
  • Status: offline
Re: need help on a assembly code 2019/05/26 21:49:30 (permalink)
0
soleil_sword
... My question is, in the PIC16F code, it used "movlb BANK1" however, bank select register doesn't exist in PIC24F, and I can't find anything related to bank in PIC24F. Could you please tell me what I could do?

That you need to ask this kind of question suggests that you have not yet gained the needed experience with PIC devices to realize your goals.
 
What you should do is to implement about 20 different projects using at least 5 different controller architectures and chip vendors. Should this not appeal to you then be prepared to pay someone that has this kind of experience to code your project for you.
#7
wenly_yang
New Member
  • Total Posts : 12
  • Reward points : 0
  • Joined: 2013/04/27 10:34:21
  • Location: 0
  • Status: offline
Re: need help on a assembly code 2019/05/27 08:58:15 (permalink)
0
dan1138
soleil_sword
... My question is, in the PIC16F code, it used "movlb BANK1" however, bank select register doesn't exist in PIC24F, and I can't find anything related to bank in PIC24F. Could you please tell me what I could do?

That you need to ask this kind of question suggests that you have not yet gained the needed experience with PIC devices to realize your goals.
 
What you should do is to implement about 20 different projects using at least 5 different controller architectures and chip vendors. Should this not appeal to you then be prepared to pay someone that has this kind of experience to code your project for you.


this has been of tremendous help. 
thank you so much genius!
#8
wenly_yang
New Member
  • Total Posts : 12
  • Reward points : 0
  • Joined: 2013/04/27 10:34:21
  • Location: 0
  • Status: offline
Re: need help on a assembly code 2019/05/27 08:59:07 (permalink)
0
dan1138
soleil_sword
If PIC24 must have an even number to the second operand, how could I achieve the same functionality as the PIC16 code?

The approach you are using is impossibly naive.
 
The architecture  of the PIC16F is so different from the PIC24F that a slavish port of the PIC16F assembly code to a PIC24F target as shown by the code in post #1 would be foolish.
 
Your best choice is to rewrite the functionality of the PIC16F application for a PIC24F target.


thank you, I'm rewriting the code per your suggestion.
#9
soleil_sword
Starting Member
  • Total Posts : 47
  • Reward points : 0
  • Joined: 2009/03/12 14:03:59
  • Location: 0
  • Status: offline
Re: need help on a assembly code 2019/05/27 13:57:52 (permalink)
0
1and0
I suggest you to try to understand what the PIC16 code is doing, and then rewrite the functionality using the PIC24 architecture and instruction set. Code it in C instead of embedded assembly.


A question I have is: 
in the 8-bit assembly code, File select register (FSR) and INDF0 has been used to access different address indirectly.
I couldn't find either of these registers.
How am I supposed to do pointer and indirect addressing in assembly in 16-bit PIC ?
thanks
#10
1and0
Access is Denied
  • Total Posts : 9495
  • Reward points : 0
  • Joined: 2007/05/06 12:03:20
  • Location: Harry's Gray Matter
  • Status: offline
Re: need help on a assembly code 2019/05/27 21:11:21 (permalink) ☄ Helpfulby soleil_sword 2019/05/28 18:28:26
5 (2)
soleil_sword
 
A question I have is: 
in the 8-bit assembly code, File select register (FSR) and INDF0 has been used to access different address indirectly.
I couldn't find either of these registers.
How am I supposed to do pointer and indirect addressing in assembly in 16-bit PIC ?

That is because, as we have already told you, the PIC16 and PIC24 are of different architectures and they have different instruction sets.
 
Teaching you to convert 8-bit assembly to 16-bit assembly step-by-step is difficult when you're a beginner in both worlds.

Anyway, try reading the XC16 Assembler User's Guide and the 16-bit Programmer's Reference Manual. As I said earlier, why not code it completely in C instead of mixing assembly with C?
#11
mpgmike
Super Member
  • Total Posts : 212
  • Reward points : 0
  • Joined: 2014/01/23 17:27:06
  • Location: NJ
  • Status: online
Re: need help on a assembly code 2019/05/29 01:46:50 (permalink)
0
Do you understand the PIC16 ASM code well enough to translate it to a block diagram?  What is it actually doing?  If you can figure that out, then use the block diagram to create the PIC24 code in C (which I assume you are familiar with).  You are taking on a career move trying it your way; You'll be at it for years (I speak from similar attempts at diving in, biting off way more than I'm ready for).

I don't need the world to know my name, but I want to live a life so all my great-grandchildren proudly remember me.
#12
Jump to:
© 2019 APG vNext Commercial Version 4.5