• AVR Freaks

Helpful ReplyHot!dsPIC DSC ASM Q?

Author
mpgmike
Super Member
  • Total Posts : 302
  • Reward points : 0
  • Joined: 2014/01/23 17:27:06
  • Location: NJ
  • Status: offline
2019/10/20 11:09:25 (permalink)
0

dsPIC DSC ASM Q?

I'm working through Microchip's DSP/DSC Online Tutorial.  I've worked with 8-bit PICs for about 8 years and have become quite functional at Assembly on them.  There is something in this Tutorial I just don't get:

SAC A, #4, W5       ;Right shift ACCAH, store into W5

SAC.R A, #-4, [W5]   ;Left shift ACCAH, store
;rounded result into [W5]
[/code]
 
How is #4 translated into Right Shift, or conversely #-4 to Left Shift?  Is this a shift by >>4/<<4?
 
Next, in the first line, W5 is just "W5", but in the second line it is bracketed "[W5]".  What is the significance of the brackets?  Thanks in advance.

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.
#1
1and0
Access is Denied
  • Total Posts : 9854
  • Reward points : 0
  • Joined: 2007/05/06 12:03:20
  • Location: Harry's Gray Matter
  • Status: offline
Re: dsPIC DSC ASM Q? 2019/10/20 11:19:10 (permalink) ☄ Helpfulby mpgmike 2019/10/21 06:25:35
5 (1)
mpgmike
How is #4 translated into Right Shift, or conversely #-4 to Left Shift?  Is this a shift by >>4/<<4?

Positive value is right shift, and negative value is left. ;)
 

Next, in the first line, W5 is just "W5", but in the second line it is bracketed "[W5]".  What is the significance of the brackets?  Thanks in advance.

No bracket is direct addressing, and bracket is indirect addressing.
#2
du00000001
Just Some Member
  • Total Posts : 3144
  • Reward points : 0
  • Joined: 2016/05/03 13:52:42
  • Location: Germany
  • Status: offline
Re: dsPIC DSC ASM Q? 2019/10/20 11:32:31 (permalink) ☄ Helpfulby mpgmike 2019/10/21 06:25:27
5 (2)
Hello Mike,
just learned about another resource (the training site)  :)
 
1and0 already gave the explanations, but let me add my own little bit:
the "Programmer's Reference Manual" (DS70000157G - links e.g. on the product pages) is quite exhaustive about all this. Ease of readability somewhat depends on your education and experience, but everything is explained and well-structured.
SAC to be found on page 401.

PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
#3
JPortici
Super Member
  • Total Posts : 808
  • Reward points : 0
  • Joined: 2012/11/17 06:27:45
  • Location: Grappaland
  • Status: offline
Re: dsPIC DSC ASM Q? 2019/10/20 13:14:59 (permalink)
0
Yes, those websites are not well publicized... i found about them just before masters (MCHP sent the links to pre-courses materials)
#4
mpgmike
Super Member
  • Total Posts : 302
  • Reward points : 0
  • Joined: 2014/01/23 17:27:06
  • Location: NJ
  • Status: offline
Re: dsPIC DSC ASM Q? 2019/10/20 18:03:22 (permalink)
0

Positive value is right shift, and negative value is left.

So shifting is by >>4?

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.
#5
1and0
Access is Denied
  • Total Posts : 9854
  • Reward points : 0
  • Joined: 2007/05/06 12:03:20
  • Location: Harry's Gray Matter
  • Status: offline
Re: dsPIC DSC ASM Q? 2019/10/20 18:12:01 (permalink) ☄ Helpfulby mpgmike 2019/10/21 06:24:21
4 (1)
mpgmike

Positive value is right shift, and negative value is left.

So shifting is by >>4?

Yes, it shifts the Acc by that number of bits, and then store Acc[31:16] or ACCH to the destination. But notice the Acc itself is not shifted.
 
Edit: Mike, take a look to the examples in the Reference Manual mentioned by Du.
post edited by 1and0 - 2019/10/20 18:54:59
#6
1and0
Access is Denied
  • Total Posts : 9854
  • Reward points : 0
  • Joined: 2007/05/06 12:03:20
  • Location: Harry's Gray Matter
  • Status: offline
Re: dsPIC DSC ASM Q? 2019/10/20 19:00:56 (permalink) ☄ Helpfulby mpgmike 2019/10/21 06:24:04
4.5 (2)
SAC A, #4, W5       ;Right shift ACCAH, store into W5
 

is equivalent to 
 
  W5 = ((ACCA >> 4) >> 16) & 0xFFFF;

SAC.R A, #-4, [W5] ;Left shift ACCAH, store
;rounded result into [W5]

is equivalent to 
 
  W5 = pointer to an address
  *W5 = (((ACCA << 4) + 0x8000) >> 16) & 0xFFFF;
 
#7
Jump to:
© 2019 APG vNext Commercial Version 4.5