NO

Author Topic: asm error  (Read 4654 times)

mechanic

  • Guest
asm error
« on: March 25, 2007, 06:04:40 PM »
I've been using PellesC for a while now and love it. I have a program that gives me an error message I have not seen before. Maybe someone will have seen this and know what I can look for in my program.

I get the following error message:

error #3114: [asm] Invalid combination of opcode and operands.

for the line of C code below:

void PrepCache (int iFrom, int iTo)

I have scanned the program, including the lines before this one, with no luck.
Thanks for any info.

Doyle Whisenant

Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2266
    • http://www.smorgasbordet.com
Re: asm error
« Reply #1 on: March 25, 2007, 08:56:54 PM »
If you have any inline assembly code in your program (__asm ...), I would check that first. If you don't, it sounds like a compiler bug. In that case, I would like to look at the C source file that gives you this error. If you can narrow the problem down to a few lines of C code would be nice, but otherwise if you can just post or mail me the C file, I will look at it...
/Pelle

mechanic

  • Guest
Re: asm error
« Reply #2 on: March 25, 2007, 10:39:54 PM »
Thanks for the reply. The reason it took so long to trace this is because the error was indicated at the start of the function, not at the error lines. I finally tracked the error down to the following C code.

            if(nSubItem==0)
              {
                ListView_GetItemRect(hWndGrid,nItem, &rc,LVIR_LABEL);
              }
            else
              {
                ListView_GetSubItemRect(hWndGrid,nItem,nSubItem,LVIR_BOUNDS, &rc);
              }

If I use SendMessage instead of the macros, then I don't get the error message. Strange stuff. Below is the code which compiled with no errors.

            if(nSubItem==0)
              {
                SendMessage(hWndGrid,(UINT)LVM_GETITEMRECT,(WPARAM)LVIR_BOUNDS,(LPARAM) &rc);
              }
            else
              {
                SendMessage(hWndGrid,(UINT)LVM_GETSUBITEMRECT,(WPARAM)LVIR_LABEL,(LPARAM) &rc);
              }
 
Thanks, maybe this will help someone else.

Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2266
    • http://www.smorgasbordet.com
Re: asm error
« Reply #3 on: March 25, 2007, 11:55:19 PM »
You get an error when you really shouldn't, so the line numbers can be a bit off.

I don't think it's anything special about those lines, it has more to do with the context in which they are used. You could try this with the faulty program:

1) Compile as usual, but request output as an assembly file ( /Tx86-asm ) - let's call this file "output.asm".
2a) Either edit "output.asm" by hand (can be tedious), using any text editor, and remove all lines starting with: #line ...
2b) ...or write a little program to do it... ;)
3) Feed the modified "output.asm" back to the compiler: POCC output.asm
4) Now you should still get the same error, but the line numbers should be counted sequentially from 1 - from the first line. If it says for example error in line 497, line 497 in "output.asm" should be faulty. It would be interesting to know what is on your "problematic" line...
/Pelle

mechanic

  • Guest
Re: asm error
« Reply #4 on: March 26, 2007, 01:29:22 AM »
You get an error when you really shouldn't, so the line numbers can be a bit off.

I don't think it's anything special about those lines, it has more to do with the context in which they are used. You could try this with the faulty program:

1) Compile as usual, but request output as an assembly file ( /Tx86-asm ) - let's call this file "output.asm".


Sorry, but how do I do this exactly? Below is my pocc flags:

 -W0 -Ot -Go -Gd -Ze -Zx -Tx86-asm

I still get an object file and the following error:

fatal error: Invalid machine type in object 'md_listview.obj'.

I've tried removing different flags but nothing seems to work.

Thanks.

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2155
Re: asm error
« Reply #5 on: March 26, 2007, 08:02:06 AM »
This example:
Code: [Select]
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <commctrl.h>

HWND hWndGrid;
RECT rc;
int nItem, nSubItem;

//#define ListView_GetItemRect(hwnd,i,prc,code)  (BOOL)SNDMSG((hwnd),LVM_GETITEMRECT,(WPARAM)(int)(i),((prc)?(((RECT*)(prc))->left = (code),(LPARAM)(RECT*)(prc)):(LPARAM)(RECT*)NULL))

void LVTest(void)
{
if (nSubItem == 0)
{
ListView_GetItemRect(hWndGrid, nItem, &rc, LVIR_LABEL);
}
else
{
ListView_GetSubItemRect(hWndGrid, nItem, nSubItem, LVIR_BOUNDS, &rc);
}

//If I use SendMessage instead of the macros, then I don't get the error message. Strange stuff. Below is the code which compiled with no errors.

if (nSubItem == 0)
{
SendMessage(hWndGrid, (UINT)LVM_GETITEMRECT, (WPARAM)LVIR_BOUNDS, (LPARAM) & rc);
}
else
{
SendMessage(hWndGrid, (UINT)LVM_GETSUBITEMRECT, (WPARAM)LVIR_LABEL, (LPARAM) & rc);
}
}
Gives this error:
LVTest.c(11): error #3114: [asm] Invalid combination of opcode and operands.
LVTest.c(11): error #3114: [asm] Invalid combination of opcode and operands.
May the source be with you

Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2266
    • http://www.smorgasbordet.com
Re: asm error
« Reply #6 on: March 26, 2007, 07:04:11 PM »
OK, thanks, I will look at it...
/Pelle