USER_ENTER_CRITICAL()

Discussion to talk about software related topics only.
Post Reply
User avatar
mike
Posts: 20
Joined: Thu Oct 29, 2015 10:25 am

USER_ENTER_CRITICAL()

Post by mike »

My hardware platform is MOD54415.
Environment is NBEclipse 2.7.3

from "ucosmcfc.h"
macro:
"USER_ENTER_CRITICAL()"

asm(" nop"); \
asm(" move.w #0x2700,%sr "); \
asm(" addq.l #1,critical_count ");\

I place that macro name in my code
I build "myproject"
I create a listing of "myproject"
(I used: m68k-elf-objdump -S -G myproject.elf > myproject.txt)
I find the actual code is:

400119c0: 4e71 nop
400119c2: 46fc movew %d4,%sr
400119c4: 2700 movel %d0,%a3@-
400119c6: 52b9 8000 0650 addql #1,80000650 <critical_count>

I could be wrong, but I don't think the assembler is doing what 'they' think it will do.
("They" being whoever wrote that macro.)

I have written other assembly routines and have noticed similar behavior.

Questions:
1. The actual executed code is NOT what was expected - right ??
2. Does that macro need to be fixed ??
3. Am I doing something wrong ??

Thanks for looking.
User avatar
TomNB
Posts: 538
Joined: Tue May 10, 2016 8:22 am

Re: USER_ENTER_CRITICAL()

Post by TomNB »

Hello,

My understanding is that the asm() command does not interpret anything, it just passes the assy code to the assembler. Just did a quick test with 2.8.4 (I do not have the older versions). The list file output is:

USER_ENTER_CRITICAL();
40000630: 4e71 nop
40000632: 46fc 2700 movew #9984,%sr
40000636: 52b9 8000 064c addql #1,8000064c <critical_count>

In this case the commands are identical. I would try making the smallest possible application as a test to make sure your looking at the right code.
User avatar
mike
Posts: 20
Joined: Thu Oct 29, 2015 10:25 am

Re: USER_ENTER_CRITICAL()

Post by mike »

Thank you for checking this with your version.
After looking into this some more, I'm thinking the problem is in my disassembler.
I wonder if and how hard it will be to update my toolset (?).
User avatar
TomNB
Posts: 538
Joined: Tue May 10, 2016 8:22 am

Re: USER_ENTER_CRITICAL()

Post by TomNB »

Hi,

It is dependent on how close to the standards you wrote your code. The latest release updates the gcc compiler to 5.2, which is much more strict about coding standards. You may get a few warnings/errors, but in my experience all have been indications of problems that should be addresses, such as memory leaks, incorrect type casting, etc.
User avatar
pbreed
Posts: 1080
Joined: Thu Apr 24, 2008 3:58 pm

Re: USER_ENTER_CRITICAL()

Post by pbreed »

try..
from a command line
m68k-elf-objdump -d your_project.elf >list

or

m68k-elf-objdump -d -S your_project.elf >list
User avatar
mike
Posts: 20
Joined: Thu Oct 29, 2015 10:25 am

Re: USER_ENTER_CRITICAL() - Disassembler bug

Post by mike »

I tried the "-d" option. I tried "-d -S" options. Unfortunately, they didn't help.
I'm pretty sure all the disassembly outputs look the same.

From the disassembler:
400057a6: 46fc movew %d4,%sr
400057a8: 2700 movel %d0,%a3@-

From the ColdFire Reference Manual; chapter 8; Supervisor (Privileged) Instructions:
opcode 0x46FC is an immediate data move, word size, to the status register, the data to be moved is the word following the opcode.
I conclude this is a bug in the disassembler.

Thanks for the help.
Post Reply