• AVR Freaks

Helpful ReplyHot!Accessing PIC32MK/MZ Accumulators

Author
Sal Ammoniac
Super Member
  • Total Posts : 216
  • Reward points : 0
  • Joined: 2011/11/27 14:04:14
  • Location: 0
  • Status: offline
2019/07/17 09:49:15 (permalink)
0

Accessing PIC32MK/MZ Accumulators

Anyone know how to access the accumulators (AC0-AC3) in assembly code? I can't find any reference code that does this.
 
These accumulators are alternately known as HI (0), LO (0), HI (1), LO (1)... I thought I could just write a C function with the interrupt attribute (so the compiler generates code to save these registers) and disassemble it in MPLAB X, but that didn't work. Yes, the compiler generates code to save all these registers, but the disassembly looks like this, which isn't very helpful:
 
0x9D000A54: MFLO V0
0x9D000A58: SW V0, 300(SP)
0x9D000A5C: MFHI V1
0x9D000A60: SW V1, 296(SP)
0x9D000A64: MFLO V0
0x9D000A68: SW V0, 292(SP)
0x9D000A6C: MFHI V1
0x9D000A70: SW V1, 288(SP)
0x9D000A74: MFLO V0
0x9D000A78: SW V0, 284(SP)
0x9D000A7C: MFHI V1
0x9D000A80: SW V1, 280(SP)
0x9D000A84: MFLO V0
0x9D000A88: SW V0, 276(SP)
0x9D000A8C: MFHI V1
0x9D000A90: SW V1, 272(SP)

#1
jdeguire
Super Member
  • Total Posts : 467
  • Reward points : 0
  • Joined: 2012/01/13 07:48:44
  • Location: United States
  • Status: offline
Re: Accessing PIC32MK/MZ Accumulators 2019/07/17 10:06:20 (permalink) ☄ Helpfulby Sal Ammoniac 2019/07/18 12:14:40
0
If you have the DSP extension enabled (the startup code should do this for you), you give the accumulator number 0-3 as a second parameter to the MTLO/MTHI and MFLO/MFHI instructions, such as "MTLO v0, 1".
#2
Sal Ammoniac
Super Member
  • Total Posts : 216
  • Reward points : 0
  • Joined: 2011/11/27 14:04:14
  • Location: 0
  • Status: offline
Re: Accessing PIC32MK/MZ Accumulators 2019/07/18 12:14:33 (permalink)
0
Thanks. I'll give that a try.
#3
Sal Ammoniac
Super Member
  • Total Posts : 216
  • Reward points : 0
  • Joined: 2011/11/27 14:04:14
  • Location: 0
  • Status: offline
Re: Accessing PIC32MK/MZ Accumulators 2019/08/01 09:34:32 (permalink)
0
Gave it a try and am getting errors. For eaxmple,
 

    MFLO  v0,1

 
Generates these errors:
Error: Invalid dsp acc register
Error: Illegal operands `mflo $2,1'
 
Do I need to tell the assembler this is a microAptiv processor? How do I do that?
#4
Sal Ammoniac
Super Member
  • Total Posts : 216
  • Reward points : 0
  • Joined: 2011/11/27 14:04:14
  • Location: 0
  • Status: offline
Re: Accessing PIC32MK/MZ Accumulators 2019/08/01 10:59:31 (permalink)
0
Found the answer. The syntax accepted by the XC32 assembler is:
 

    MFLO v0,$ac1

#5
simong123
Lab Member No. 003
  • Total Posts : 1305
  • Reward points : 0
  • Joined: 2012/02/07 18:21:03
  • Location: Future Gadget Lab (UK Branch)
  • Status: offline
Re: Accessing PIC32MK/MZ Accumulators 2019/08/01 10:59:43 (permalink)
0
Try
    mflo    $v0,$ac1

#6
Jump to:
© 2019 APG vNext Commercial Version 4.5