"BIL" assembler instraction

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

"BIL" assembler instraction

3,728 Views
Tzvi
Contributor I
Hi,
How do i write in C style the "BIL" assembler instraction ?
Labels (1)
Tags (1)
0 Kudos
15 Replies

971 Views
Alban
Senior Contributor II
Hello,

You forgot THE important information: what is the target microcontroller ?

If I look at S12X CPU, the BIL instruction is not in the list.

Generally speaking you have many threads on the forum which explains how to integrate ASM code within C.
Please search these.

Regards,
Alban.


0 Kudos

971 Views
CrasyCat
Specialist III
Hello
 
Are you using CodeWarrior for HC08 V5.x?
HC08 compiler supports some intrinsic functions allowing to check state of bits in the CCR.
 
The intrinsic function __isflag_int() allows to test the state of the IRQ flag.
 
Please refer to {Install}\Help\PDF\Compiler_HC08.pdf, chapter "Using the Compiler", section "ANSI-C Frontend" -> "Implementation Features" -> "Intrinsic Functions" for more information on available intrinsics.
 
CrasyCat
0 Kudos

971 Views
Tzvi
Contributor I
thanks CrasyCat ,
 
but How i use the intrinsic function __isflag_int() ?
Do i need to add a H file ?
I read the PDF file but it's not say how to use it!
when i write
if (__isflag_int() )  XX++;
 i got compiler Error!
 
Tzvi
0 Kudos

971 Views
CompilerGuru
NXP Employee
NXP Employee
Which CW version do you use?
Which compiler errors do you get? Do you have a declaration of the function? You need one.
For HC08 V6.0 there is a "intrinsics_hc08.h".

Here's a snippet which works for me for the HC08 V6.0 release.

Code:
#include "intrinsics_hc08.h"char x;void main(void) {  for(;;) {    if (__isflag_int()) { x++; }  }}

 

--
Alban Edit: code format via SRC to avoid smileys


Message Edited by Alban on 2007-07-24 12:15 PM
0 Kudos

971 Views
Tzvi
Contributor I
I use CW 5.7.0 version , and in that version there is no "intrinsics_hc08.h" include file familiar !
can you send me the files ?
 
Tzvi
0 Kudos

971 Views
CrasyCat
Specialist III
Hello
 
To retrieve the actual CodeWarrior version info, follow these steps:
  - Start CodeWarrior
  - Select Help -> About Freescale CodeWarrior
  - Click on "Install Products"
  - CodeWarrior version used is displayed on top in the Installed Products dialog.
 
That is the version number we need.to identify the release you are using.
 
CrasyCat
0 Kudos

971 Views
Tzvi
Contributor I
I probably use CW version 5.1 , But for be sure I add the sreensave of the Installed Products
 
Tzvi
0 Kudos

971 Views
CompilerGuru
NXP Employee
NXP Employee
For HC08 V5.1.
possibilities:
- upgrade :smileyhappy:
- put the declarations of the methods in some header file.
Here are the declarations (basically also what's in intrinsics_hc08.h):

char __isflag_carry(void);
char __isflag_half_carry(void);
char __isflag_int(void);
char __isflag_int_enabled(void);

There is also one bug in this area fixed in the compiler in HC08 V6.0 (not sure about state of V5.1 compiler),
out of the compiler release notes:

>- MTWX22355: HC08 intrinsics not working with the -Ont switch.

Basically the compiler did not recognice them with -Ont, so with an older compiler, so can either not use -Ont with intrinsics, or you have to actually define somewhere as real functions. The library does not contain defintions of those functions, so they are either recognices as intrinsics and expanded to a BIL (or whatever), or the linking does fail. Note that suboptions of -ont like -ont=a did actually work with older compilers, just plain -ont did not.

Daniel

0 Kudos

971 Views
CrasyCat
Specialist III
Hello
 
Yes you are using V5.1.
 
With this version there is no need to specify any include file.
Writing  following code works for me.
 
I get a warning message that there is no prototype available, but disassembly code shows BIL instruction.
 
Code:
if (__isflag_int()) {  Data=0;}

 
If you want to remove the warning, you need to define a prototype for the function __isflag_int.
Prototype will look as follows:
    char __isflag_int(void);
CrasyCat
0 Kudos

971 Views
Tzvi
Contributor I
Thanks guys,
 
As i say when i write
 
Code:
if (__isflag_int()) {  Data=0;}

 
I get Error Message :
ERROR  : C1801:  Implicit parameter-declaration for '__isflag_int'
 
But when i add the Prototype it's work OK.
0 Kudos

971 Views
bigmac
Specialist III
Hello,
 
I question whether the __isflag_int() function can do the same job as the BIH or BIL assembly instructions.  My understanding is that the function returns the state of the I-bit within the CCR.  If so, this is not the same as the assembly instructions, that read the state of the INT pin.
 
Depending on the MCU type in use, if the INT pin is a dedicated pin, I don't see an alternative to the use of inline assembly code.  However, if the INT pin is a secondary use of a port pin, the state of the port pin might be read instead.
 
Regards,
Mac
 
0 Kudos

971 Views
CrasyCat
Specialist III
Hello
 
Compiling the following ANSI C code with CodeWarrior for HC08
Code:
if (__isflag_int()) {  data++ ;}

 
You get following code generated:
Code:
   38:  if (__isflag_int()) {  0004 2e06     [3]             BIL   LC ;abs = 000c   39:    data++ ;  0006 3c01     [4]             INC   data:1  0008 2602     [3]             BNE   LC ;abs = 000c  000a 3c00     [4]             INC   data  000c          [5]     LC:     

 
So this should be equivalent to using BIL directly in inline assembler.
 
CrasyCat
0 Kudos

971 Views
Alban
Senior Contributor II
Bonjour Cat,

You know what "BIL" instruction is ?
I'm curious.

Cheers,
Alban.
0 Kudos

971 Views
Tzvi
Contributor I
BIL - Branch if IRQ Pin Low
BIH - Branch if IRQ Pin High
 
I use HCS08 Family microcontroller
0 Kudos

971 Views
Alban
Senior Contributor II
Thanks Tzvi,

I didn't know these instructions !
Compiler Guru answer is spot on.... once again !!!

Alban.
0 Kudos