CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

dsPIC33CK support for advanced instructions?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
laser_scientis



Joined: 12 Apr 2025
Posts: 1

View user's profile Send private message

dsPIC33CK support for advanced instructions?
PostPosted: Tue Jul 08, 2025 11:45 am     Reply with quote

Hello. I am using the 5.115 compiler with a dsPIC33CK64MC105. I need to optimize various math processing routines, so I drop into assembly for that. I wanted to take advantage of the fast division instructions that are implemented on this chip, but apparently, the compiler doesn't support these. For example, this is the normal code produced by the compiler for a 16 bit / 16 bit signed division operation:
Code:
    # mc = ma / mb
    MOV ma,W4
    MOV mb,W3
    REPEAT  #11
    DIV.S  W4,W3
    MOV W0,mc

which requires 18 cycles for the division, as per the datasheet. This code works fine if I include it as an assembly block.
There is a DIV2 instruction group (DIV2.S, DIV2.U) which is supposed to complete in only 6 cycles, but if I try to introduce that instruction:
Code:
    // mc = ma / mb
    MOV ma,W4
    MOV mb,W3
    REPEAT  #5
    DIV2.S  W4,W3
    MOV W0,mc

the compiler gives an error Error#95 Expecting an opcode mnemonic DIV2:
There are other instructions that appear in the datasheet, such as DIVF and DIV2F (fractional divide) that are also flagged by the compiler as nonexistent.
Am I missing something, or is there any way of working around this?
Thanks for any advice.
Ttelmah



Joined: 11 Mar 2010
Posts: 19892

View user's profile Send private message

PostPosted: Wed Jul 09, 2025 12:44 am     Reply with quote

Big answer here is talk to CCS.

You can bodge round a non existent instruction, by manually placing the
required bytes in the assembler. Years ago, there was a single instruction
and I generated macros to produce the correct bytes, with variables coded
into the bytes as well, but it is a lot of work, and I'd expect CCS to offer
a better workaround, or even add the instructions for you. They may well
already exist, but need sneaky coding.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group