LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Why LabVIEW crashes when I'm trying to use "in" and "out" in my DLL?

Calling function from DLL using Call Library Function.
Function source:

extern "C" __declspec(dllexport) long ReadPort(long base, long off)
{
unsigned char c;
long d;
__asm
{
push eax
push dx
push ax
mov eax, base
add eax, off
mov dx, ax
in al, dx
mov c, al
pop ax
pop dx
pop eax
}
d = c;
return d;
}

Using LabVIEW 5.0 and MSVC 6
OS: Win2k
0 Kudos
Message 1 of 5
(2,518 Views)
Hi AK,

Make sure you are using the proper calling convention.
This can be configured when you pop-up on the call library function node.

When this is set incorrectly LV will crash.

Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 2 of 5
(2,518 Views)
I am sure... When I delete "in" command from DLL source, it works... but when I use "in" or "out" assembler command, LV crashes (sometimes without any error message)...
0 Kudos
Message 3 of 5
(2,518 Views)
> I am sure... When I delete "in" command from DLL source, it works...
> but when I use "in" or "out" assembler command, LV crashes (sometimes
> without any error message)...
>

Windowd 2000, and most of the more modern MS OSes do not allow direct
access to HW. That means that applications do not have permission to
call in and out instructions. Those instructions are protected and any
app calling them will be terminated because it did something illegal.

To get direct I/O to work, you should look for the driver on the NI web
site that will redirect it for you.

Greg McKaskle
0 Kudos
Message 5 of 5
(2,518 Views)
Hi,

I do not understand a lot of DLL's, but I expect you have not installed accesshw on your PC. This is the "door" for Hardware-access in case you use "In-Port" and "Out Port" (needed for WinNT & W2k).
Find it @: http://zone.ni.com/devzone/explprog.nsf/webmain/49664743DED6F1DA862564BC004E3A7F?opendocument

In case there are still open questions - post it.
regards
wha
0 Kudos
Message 4 of 5
(2,518 Views)