Just to get out in the air, I AM A NEWBIE to ASM. I have many years experience with VB and others, but no ASM.
I have been given the task to convert a 16-bit DLL to a 32-bit DLL. The source code is in assembler and is very small. 4 macros and 4-5 procedures.
Where can I find info on how to convert 16-bit instructions to 32-bit instructions easily??
I converted the DllEntry procedure and got rid of the WEP at the end, but get the error:
"Cannot use 16-bit instruction with 32-bit addressing"
I understand this, but do not know how to convert the instructions.
I am using MASM32... I got it from Iczelions. Is this a good suite to use??
This DLL is only about 400 lines long...it has no complex instructions either. VERY SIMPLE... I am just very inexperienced!
ANY leads are GREALTY appreciated.
I have been given the task to convert a 16-bit DLL to a 32-bit DLL. The source code is in assembler and is very small. 4 macros and 4-5 procedures.
Where can I find info on how to convert 16-bit instructions to 32-bit instructions easily??
I converted the DllEntry procedure and got rid of the WEP at the end, but get the error:
"Cannot use 16-bit instruction with 32-bit addressing"
I understand this, but do not know how to convert the instructions.
I am using MASM32... I got it from Iczelions. Is this a good suite to use??
This DLL is only about 400 lines long...it has no complex instructions either. VERY SIMPLE... I am just very inexperienced!
ANY leads are GREALTY appreciated.
Your biggest problem will be around memory referencing, ie stuff
like
mov eax, ... you'll basically have to convert the register references
to their extended parts (si->esi, di->edi, ax->eax, and so on). And
you must make sure that they are loaded with 32bit pointers ;).
like
mov eax, ... you'll basically have to convert the register references
to their extended parts (si->esi, di->edi, ax->eax, and so on). And
you must make sure that they are loaded with 32bit pointers ;).
Yes, THAT IS IT!!!! :)
That is the only trouble I have... where can I find this info. I have looked at some VxD examples, but they are too complex for me yet. This DLL is super small... only a few instructions per proc... and the macros are like 4 instructions each.
I read Iczelions DLL tutorial and folowed it to a T... no problems except for my 16bit registers in a 32bit address!
Thanks again!!
That is the only trouble I have... where can I find this info. I have looked at some VxD examples, but they are too complex for me yet. This DLL is super small... only a few instructions per proc... and the macros are like 4 instructions each.
I read Iczelions DLL tutorial and folowed it to a T... no problems except for my 16bit registers in a 32bit address!
Thanks again!!
These are my 4 macros. Also, 3 of the routines only are a call to one or more of these macros. It is simple but I AM NEWBIE!!
Advice, direction, leads, info needed. Also hysterical laughter is appreciated to "Ease the tension baby!"
thanks!!
;*****************************
;Macro routines
;*****************************
P2L16 Macro local16,passedptr
push ds
LDS si,passedptr
MOV AX,
pop ds
MOV local16,AX
Endm
L2P16 Macro passedptr,local16
mov AX,local16
push ds
lds SI,passedptr
mov ,AX
pop DS
Endm
P2L32 Macro local32,passedptr
push ds
LDS si,passedptr
MOV AX,
MOV CX,
pop ds
MOV local32,AX
MOV local32+2,CX
Endm
L2P32 Macro passedptr,local32
mov AX,local32
mov CX,local32+2
push ds
lds SI,passedptr
mov ,AX
mov ,CX
pop DS
Endm
Advice, direction, leads, info needed. Also hysterical laughter is appreciated to "Ease the tension baby!"
thanks!!
;*****************************
;Macro routines
;*****************************
P2L16 Macro local16,passedptr
push ds
LDS si,passedptr
MOV AX,
pop ds
MOV local16,AX
Endm
L2P16 Macro passedptr,local16
mov AX,local16
push ds
lds SI,passedptr
mov ,AX
pop DS
Endm
P2L32 Macro local32,passedptr
push ds
LDS si,passedptr
MOV AX,
MOV CX,
pop ds
MOV local32,AX
MOV local32+2,CX
Endm
L2P32 Macro passedptr,local32
mov AX,local32
mov CX,local32+2
push ds
lds SI,passedptr
mov ,AX
mov ,CX
pop DS
Endm
okay, you'll need a few explanations I guess :).
lds si, loads DS:SI with the four bytes from .
Under win32, you have a flat memory model, and thus do NOT want
to mess with segment registers ;). And all pointers are 32 (but linear,
not seg:ofs).
I'll convert P2L16 for you...
As you can see, the code is actually simpler :).
And it uses less registers :).
lds si, loads DS:SI with the four bytes from .
Under win32, you have a flat memory model, and thus do NOT want
to mess with segment registers ;). And all pointers are 32 (but linear,
not seg:ofs).
I'll convert P2L16 for you...
P2L16 Macro local16,passedptr
mov eax, passedptr
mov ax, [eax]
MOV local16, AX
Endm
As you can see, the code is actually simpler :).
L2P32 Macro passedptr,local32
push local32
mov eax, passeptr
pop [eax]
And it uses less registers :).
I was about to post a general posting on Intel Architecture, but this post seems to have alot of the overtones :)
Im in a course at Universtiy right now that study's this, and (since i never opened the notes till yesterday (exam was today), i never knew what resources are provided :) )
The notes are simple but to the point. They do a decent job of describing the 16 bit and 32 bit modes for both real and protected. Thus, why the DS is "NOT" to be used in 32 bit protected mode is also described to you. There may be some worth in looking at the frist 40 odd slides for you problem. (which describes the ins and outs of what you want to do).
You can download them from the University web page HERE.
As well, for anyone else in general, wanting to know more about protected mode, descripter tables, and segment selectors, with out pouring thu the Intel manuals, you might want to take a look at them.
Enjoy...
NaN
Im in a course at Universtiy right now that study's this, and (since i never opened the notes till yesterday (exam was today), i never knew what resources are provided :) )
The notes are simple but to the point. They do a decent job of describing the 16 bit and 32 bit modes for both real and protected. Thus, why the DS is "NOT" to be used in 32 bit protected mode is also described to you. There may be some worth in looking at the frist 40 odd slides for you problem. (which describes the ins and outs of what you want to do).
You can download them from the University web page HERE.
As well, for anyone else in general, wanting to know more about protected mode, descripter tables, and segment selectors, with out pouring thu the Intel manuals, you might want to take a look at them.
Enjoy...
NaN
Thanks, NaN - there are some nice bits of code there as well.
Glad to help...
BTW: Those code snippets are flawed. Prof intentionally placed bugs in the source to "challenge" us. Hehehe, like:
As well, some of those files will work on a PC, but some wont. We do our assembly tests on an 8086 evaluation board. Like a custom motherboard with extra wing dings like D/A converters etc. etc. As well, there is an LED display on the board (since there is no monitor) and its port and chip info will definitely NOT apply to a PC.
NaN
BTW: Those code snippets are flawed. Prof intentionally placed bugs in the source to "challenge" us. Hehehe, like:
LOOP:
mov al, 0
...
je LOOP
As well, some of those files will work on a PC, but some wont. We do our assembly tests on an 8086 evaluation board. Like a custom motherboard with extra wing dings like D/A converters etc. etc. As well, there is an LED display on the board (since there is no monitor) and its port and chip info will definitely NOT apply to a PC.
NaN
Thanks for the GREAT help and leads. I am now fully aware of what is expected. I DID need some explanations... being a NEWBIE and all! :grin:
hey f0dder.... you seem to be quite intelligent... to tell you the truth, if I cannot get to work, I am supposed to outsource it. I have placed a project on ANTS.com... and will be taking bids for 5 days...then if I don't have it working, I will need to pick someone..... you care to be that someone??
thanks again for everything..
hey f0dder.... you seem to be quite intelligent... to tell you the truth, if I cannot get to work, I am supposed to outsource it. I have placed a project on ANTS.com... and will be taking bids for 5 days...then if I don't have it working, I will need to pick someone..... you care to be that someone??
thanks again for everything..
Ok, I have completed converting the other 2 macros with your help. Thanks.
Now I have a different problem that is probably pretty easy.
When I compile now I get an error in the following sub on the line with the arrow.
;**********************************
trinfo PROC FAR EXPORT USES SI DI ES AX BX CX DX ,drvrevptr:FAR PTR DWORD
;**********************************
L2P16 drvrevptr,drvrev <---------
ret
trinfo endp
The error is the following:
error A2070: invalid instruction operands
L2P16(2): Macro Called From
C:\WINDOWS\Desktop\tracker\newtrackdll2.asm(116): Main Line Code
What am I doing wrong here. I tried it with the USES = ESI EDI EAX EBX ECX EDX... but same problem.
Any help or leads appreciated. Thanks again!:alright:
Now I have a different problem that is probably pretty easy.
When I compile now I get an error in the following sub on the line with the arrow.
;**********************************
trinfo PROC FAR EXPORT USES SI DI ES AX BX CX DX ,drvrevptr:FAR PTR DWORD
;**********************************
L2P16 drvrevptr,drvrev <---------
ret
trinfo endp
The error is the following:
error A2070: invalid instruction operands
L2P16(2): Macro Called From
C:\WINDOWS\Desktop\tracker\newtrackdll2.asm(116): Main Line Code
What am I doing wrong here. I tried it with the USES = ESI EDI EAX EBX ECX EDX... but same problem.
Any help or leads appreciated. Thanks again!:alright:
First of all, you should indeed be USES'ing the 32bit registers, as
you'll save yourself from 66h opcode prefixes...
I think it might be the "far ptr". In dos mode, a far ptr means you
have both a segment and an offset in your pointer. In win32, with
the flat memory model, you don't need segments (well, selectors),
and thus you use *near* pointers, *always*. So, try declaring it as
and see what happens :)
you'll save yourself from 66h opcode prefixes...
I think it might be the "far ptr". In dos mode, a far ptr means you
have both a segment and an offset in your pointer. In win32, with
the flat memory model, you don't need segments (well, selectors),
and thus you use *near* pointers, *always*. So, try declaring it as
trinfo PROC USES ESI EDI EAX EBX ECX EDX ,drvrevptr:DWORD
and see what happens :)
f0dder,
to change the parameter type to dword is ok, but the assembling error comes from within macro L2P16 (line 2).
mikef, I think you will need to replace all instances of L16xx or P16xx stuff to L32xx/P32xx. I am not sure, I simply guess it from the name "passedptr" because in Win32 there normally isn't any 16 bit pointer.
japheth
to change the parameter type to dword is ok, but the assembling error comes from within macro L2P16 (line 2).
mikef, I think you will need to replace all instances of L16xx or P16xx stuff to L32xx/P32xx. I am not sure, I simply guess it from the name "passedptr" because in Win32 there normally isn't any 16 bit pointer.
japheth
Changed all of them to what you specified f0dder.... AND IT WORKED!!! I assembled the file with NO errors reported.
Now I just have to figure out how to LINK it.
Is there not certain switches... etc I have to specify for a DLL??
Anyone know where I can find some info to research??
THANKS TO EVERYONE FOR ALL THE HELP!!!!!
:alright:
Now I just have to figure out how to LINK it.
Is there not certain switches... etc I have to specify for a DLL??
Anyone know where I can find some info to research??
THANKS TO EVERYONE FOR ALL THE HELP!!!!!
:alright:
Yeah, using "whatever"16"whatever" for pointer stuff under win32
is a baaaad idea :).
As for DLLs... lemme look up some stuff... yep. There.
is a baaaad idea :).
As for DLLs... lemme look up some stuff... yep. There.
I have completed the assmeble and link... and with no errors, but when I try to call the function from VB I get ERROR 48: File not found, but when I use the same command on a know working DLL I get a diferent error: DllEntry point not found...
I think there is still something wrong
here is my full code... any guesses would be great... otherwise I think I need to hire some help!! :-)
;* Assembly-language source for tracker DLL. trackw.DLL contains several
;* library routines, which any Windows process can call.
;*
;*****************************************************************************
;
; Examples of how to compile
;
;
;MASM /c /W3 Trackw03.asm;
;masm /c /W3 dllentry.asm;
;link dllentry Trackw03,trackw.dll,, libw.lib mnocrtdw.lib,trackw.def
;*****************************************************************************
; rev 2.2 Mar 4, 1995
; rev 2.3 Mar 21,1995 fixed trsts command
; rev 3.0 Oct 22, 2001 converted to 32-bit instructions
;*****************************************************************************
.386
.MODEL flat,stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
;;INCLUDE trdll2.inc
;;INCLUDE win.inc
;*****************************
;Macro routines
;*****************************
;P2L16 converted
P2L16 Macro local16,passedptr
mov eax, passedptr
mov ax,
MOV local16, AX
Endm
;L2P16 converted
L2P16 Macro passedptr,local16
mov AX,local16
mov eax, passedptr
mov ,AX
;push ds
;lds SI,passedptr
;mov ,AX
;pop DS
Endm
P2L32 Macro local32,passedptr
mov eax, passedptr
pop
push local32
;push ds
;LDS si,passedptr
;MOV AX,
;MOV CX,
;pop ds
;MOV local32,AX
;MOV local32+2,CX
Endm
;L2P32 converted
L2P32 Macro passedptr,local32
push local32
mov eax, passedptr
pop
Endm
;***************************
.DATA
TaskHead BYTE 16 DUP(0) ; 1st paragraph reserved
; for Windows task header
countenable equ 0Ch
auxinputs equ 0Ch
drvrev dw (23) ;revision * 10
returncode dw (0)
counter dw (0)
newcount dw 2 dup (0)
count dw 2 dup (0)
disable dw (3)
Ipstatus dw (0)
bitnum dw (0)
polarity dw (1)
syncsignal db (0)
M1count dw 2 dup (?)
M2count dw 2 dup (?)
M3count dw 2 dup (?)
M4count dw 2 dup (?)
otbaseadr DW 0280h ;control card base address
; Array of processor types
;;procs BYTE WF_CPU086, WF_CPU186, WF_CPU286, WF_CPU386, WF_CPU486
.CODE
DllEntry proc hInstDLL:HINSTANCE, reason:DWORD, reserved1:DWORD
mov eax,TRUE
ret
DllEntry Endp
;**********************************
;trinfo PROC FAR EXPORT USES SI DI ES AX BX CX
;DX ,drvrevptr:FAR PTR DWORD
trinfo PROC USES ESI EDI EAX EBX ECX EDX,drvrevptr:dword
;**********************************
L2P16 drvrevptr,drvrev
ret
trinfo endp
; *********************************
;trsetadr PROC FAR EXPORT USES ESI EDI ES EAX EBX ECX
;EDX ,otbaseadrptr:far Ptr
trsetadr PROC USES ESI EDI EAX EBX ECX EDX,otbaseadrptr:DWORD
;************************************
P2L16 otbaseadr,otbaseadrptr
ret
trsetadr endp
; *********************************
;trchk PROC FAR EXPORT USES ESI EDI ES EAX EBX ECX
;EDX ,otbaseadrptr:far Ptr, returncodeptr:far Ptr
trchk PROC USES ESI EDI EAX EBX ECX EDX,otbaseadrptr:DWORD,returncodeptr:DWORD
;************************************
P2L16 otbaseadr,otbaseadrptr
mov dx,otbaseadr
in al,dx
mov cl,al ;store what was in counter
mov dx,otbaseadr
mov al,0A5h
out dx,al ;write A5h
in al,dx ;read A5h
cmp al,0A5h
je doublecheck
mov returncode,0
jmp chkend
doublecheck:
mov al,5Ah ;write 5Ah
out dx,al
in al,dx ;read 5Ah
cmp al,5Ah
je otfound
mov returncode,0
jmp chkend
otfound:
mov returncode,1
mov al,cl
out dx,al ;restore counter to pretest value
chkend:
L2P16 returncodeptr,returncode
ret
trchk endp
;**************************************************************************
;trclrpos PROC FAR EXPORT USES ESI EDI ES EAX EBX ECX
;EDX ,counterptr:far Ptr
trclrpos PROC USES ESI EDI EAX EBX ECX EDX,counterptr:DWORD
;***************************************************************************
P2L16 counter,counterptr
mov dx,otbaseadr
mov al,0
cmp counter,1
je clear
cmp counter,2
je clear2
cmp counter,3
je clear3
cmp counter,4
je clear4
jmp clearend
clear2: add dx,3
jmp clear
clear3: add dx,6
jmp clear
clear4: add dx,9
jmp clear
clear: out dx,al
inc dx
out dx,al
inc dx
out dx,al
clearend: ret
trclrpos endp
;****************************************************************************
;trsetpos PROC FAR EXPORT USES ESI EDI ES EAX EBX ECX
;EDX ,counterptr:far Ptr, newcountptr:far Ptr
trsetpos PROC USES ESI EDI EAX EBX ECX EDX,counterptr:DWORD,newcountptr:DWORD
;***************************************************************************
P2L16 counter,counterptr
P2L32 newcount,newcountptr
mov dx,otbaseadr
mov ax,newcount
cmp counter,1
je write
cmp counter,2
je write2
cmp counter,3
je write3
cmp counter,4
je write4
jmp writeend
write2: add dx,3
jmp write
write3: add dx,6
jmp write
write4: add dx,9
jmp write
write: out dx,al ;output LSB
mov cl,8
shr ax,cl
inc dx
out dx,al ;output middle SB
mov ax,newcount+2
inc dx
out dx,al ;output MSB
writeend: ret
trsetpos endp
;***************************************************************************
;trreadpos PROC FAR EXPORT USES ESI EDI ES EAX EBX ECX
;EDX ,counterptr:far Ptr, countptr:far Ptr
trreadpos PROC USES ESI EDI EAX EBX ECX EDX,counterptr:DWORD,countptr:DWORD
;***************************************************************************
P2L16 counter,counterptr
reread: mov dx,otbaseadr
cmp counter,1
je read
cmp counter,2
je read2
cmp counter,3
je read3
cmp counter,4
je read4
jmp readend
read2: add dx,3
jmp read
read3: add dx,6
jmp read
read4: add dx,9
jmp read
read: cli
in al,dx ;input LSB
mov cl,al ;store LSB in cl
add dx,2
in al,dx ;input MSB
mov bl,al ;store MSB in bl
dec dx
in al,dx ;input middle SB
mov ch,al ;store middle SB in ch
dec dx ;point to the LSB
in al,dx
cmp al,cl
je readdone ;reread if al = 0 or FF
cmp al,0FFh
je read
cmp al,0
je read
mov cl,al
readdone:
mov count,cx
mov al,bl
cbw
mov count+2,ax
L2P32 countptr,count
readend: sti
ret
trreadpos endp
;***************************************************************************
;trreadall PROC FAR EXPORT USES ESI EDI ES EAX EBX ECX
;EDX ,M1countptr:Far Ptr, M2countptr:Far Ptr, M3countptr:Far Ptr, M4countptr:Far Ptr
trreadall PROC USES ESI EDI EAX EBX ECX EDX,M1countptr:DWORD,M2countptr:DWORD,M3countptr:DWORD,M4countptr:DWORD
;***************************************************************************
readM1: cli ;READ FIRST COUNTER
mov dx,otbaseadr
in al,dx ;input LSB
mov cl,al ;store LSB in cl
add dx,2
in al,dx ;input MSB
mov bl,al ;store MSB in bl
dec dx
in al,dx ;input middle SB
mov ch,al ;store middle SB in ch
dec dx ;point to the LSB
in al,dx
cmp al,cl
je M1done ;reread if al = 0 or FF
cmp al,0FFh
je readM1
cmp al,0
je readM1
mov cl,al
M1done: mov M1count,cx
mov al,bl
cbw
mov M1count+2,ax
readM2: mov dx,otbaseadr ;do counter 2
add dx,3
in al,dx ;input LSB
mov cl,al ;store LSB in cl
add dx,2
in al,dx ;input MSB
mov bl,al ;store MSB in bl
dec dx
in al,dx ;input middle SB
mov ch,al ;store middle SB in ch
dec dx ;point to the LSB
in al,dx
cmp al,cl
je M2done ;reread if al = 0 or FF
cmp al,0FFh
je readM2
cmp al,0
je readM2
mov cl,al
M2done: mov M2count,cx
mov al,bl
cbw
mov M2count+2,ax
readM3: mov dx,otbaseadr ;do counter 3
add dx,6
in al,dx ;input LSB
mov cl,al ;store LSB in cl
add dx,2
in al,dx ;input MSB
mov bl,al ;store MSB in bl
dec dx
in al,dx ;input middle SB
mov ch,al ;store middle SB in ch
dec dx ;point to the LSB
in al,dx
cmp al,cl
je doneM3 ;reread if al = 0 or FF
cmp al,0FFh
je readM3
cmp al,0
je readM3
mov cl,al
doneM3: mov M3count,cx
mov al,bl
cbw
mov M3count+2,ax
readM4: mov dx,otbaseadr ;do counter 4
add dx,9
in al,dx ;input LSB
mov cl,al ;store LSB in cl
add dx,2
in al,dx ;input MSB
mov bl,al ;store MSB in bl
dec dx
in al,dx ;input middle SB
mov ch,al ;store middle SB in ch
dec dx ;point to the LSB
in al,dx
cmp al,cl
je doneM4 ;reread if al = 0 or FF
cmp al,0FFh
je readM4
cmp al,0
je readM4
mov cl,al
doneM4: mov M4count,cx
mov al,bl
cbw
mov M4count+2,ax
L2P32 M1countptr,M1count
L2P32 M2countptr,M2count
L2P32 M3countptr,M3count
L2P32 M4countptr,M4count
readall: sti
ret
trreadall endp
;***************************************************************************
;trhld PROC FAR EXPORT USES ESI EDI ES EAX EBX ECX
;EDX ,disableptr:Far Ptr
trhld PROC USES ESI EDI EAX EBX ECX EDX,disableptr:DWORD
;***************************************************************************
P2L16 disable,disableptr
mov dx,otbaseadr
add dx,countenable
mov ax,disable
out dx,al
ret
trhld endp
;***************************************************************************
;trsts PROC FAR EXPORT USES ESI EDI ES EAX EBX ECX
;EDX ,Ipstatusptr:Far Ptr
trsts PROC USES ESI EDI EAX EBX ECX EDX,Ipstatusptr:DWORD
;***************************************************************************
mov dx,otbaseadr
add dx,auxinputs
; mov al,disable
in al,dx
; xor al,0FFh ;invert input byte
; xor ah,ah
mov cl,al
xor ch,ch
mov Ipstatus,cx
L2P16 Ipstatusptr,Ipstatus
ret
trsts endp
;***************************************************************************
;trsync PROC FAR EXPORT USES ESI EDI ES EAX EBX ECX
;EDX,bitnumptr:Far Ptr, polarityptr:Far Ptr
trsync PROC USES ESI EDI EAX EBX ECX EDX,bitnumptr:DWORD,polarityptr:DWORD
;***************************************************************************
P2L16 bitnum,bitnumptr
P2L16 polarity,polarityptr
dec bitnum ;make 1-8 into 0-7
cmp polarity,1
jne negpolarity
mov syncsignal,0
jmp lookforsync
negpolarity:
mov syncsignal,1
lookforsync:
mov dx,otbaseadr
add dx,auxinputs
retest: in al,dx
mov cx,bitnum ;put bit to be tested in least sig
shr al,cl ; bit
and al,1 ;clear all other bits
cmp al,syncsignal
jne retest
waitforend:
in al,dx
mov cx,bitnum ;put bit to be tested in least sig
shr al,cl ; bit
and al,1 ;clear all other bits
cmp al,syncsignal
je waitforend
ret
trsync endp
End DllEntry
I think there is still something wrong
here is my full code... any guesses would be great... otherwise I think I need to hire some help!! :-)
;* Assembly-language source for tracker DLL. trackw.DLL contains several
;* library routines, which any Windows process can call.
;*
;*****************************************************************************
;
; Examples of how to compile
;
;
;MASM /c /W3 Trackw03.asm;
;masm /c /W3 dllentry.asm;
;link dllentry Trackw03,trackw.dll,, libw.lib mnocrtdw.lib,trackw.def
;*****************************************************************************
; rev 2.2 Mar 4, 1995
; rev 2.3 Mar 21,1995 fixed trsts command
; rev 3.0 Oct 22, 2001 converted to 32-bit instructions
;*****************************************************************************
.386
.MODEL flat,stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
;;INCLUDE trdll2.inc
;;INCLUDE win.inc
;*****************************
;Macro routines
;*****************************
;P2L16 converted
P2L16 Macro local16,passedptr
mov eax, passedptr
mov ax,
MOV local16, AX
Endm
;L2P16 converted
L2P16 Macro passedptr,local16
mov AX,local16
mov eax, passedptr
mov ,AX
;push ds
;lds SI,passedptr
;mov ,AX
;pop DS
Endm
P2L32 Macro local32,passedptr
mov eax, passedptr
pop
push local32
;push ds
;LDS si,passedptr
;MOV AX,
;MOV CX,
;pop ds
;MOV local32,AX
;MOV local32+2,CX
Endm
;L2P32 converted
L2P32 Macro passedptr,local32
push local32
mov eax, passedptr
pop
Endm
;***************************
.DATA
TaskHead BYTE 16 DUP(0) ; 1st paragraph reserved
; for Windows task header
countenable equ 0Ch
auxinputs equ 0Ch
drvrev dw (23) ;revision * 10
returncode dw (0)
counter dw (0)
newcount dw 2 dup (0)
count dw 2 dup (0)
disable dw (3)
Ipstatus dw (0)
bitnum dw (0)
polarity dw (1)
syncsignal db (0)
M1count dw 2 dup (?)
M2count dw 2 dup (?)
M3count dw 2 dup (?)
M4count dw 2 dup (?)
otbaseadr DW 0280h ;control card base address
; Array of processor types
;;procs BYTE WF_CPU086, WF_CPU186, WF_CPU286, WF_CPU386, WF_CPU486
.CODE
DllEntry proc hInstDLL:HINSTANCE, reason:DWORD, reserved1:DWORD
mov eax,TRUE
ret
DllEntry Endp
;**********************************
;trinfo PROC FAR EXPORT USES SI DI ES AX BX CX
;DX ,drvrevptr:FAR PTR DWORD
trinfo PROC USES ESI EDI EAX EBX ECX EDX,drvrevptr:dword
;**********************************
L2P16 drvrevptr,drvrev
ret
trinfo endp
; *********************************
;trsetadr PROC FAR EXPORT USES ESI EDI ES EAX EBX ECX
;EDX ,otbaseadrptr:far Ptr
trsetadr PROC USES ESI EDI EAX EBX ECX EDX,otbaseadrptr:DWORD
;************************************
P2L16 otbaseadr,otbaseadrptr
ret
trsetadr endp
; *********************************
;trchk PROC FAR EXPORT USES ESI EDI ES EAX EBX ECX
;EDX ,otbaseadrptr:far Ptr, returncodeptr:far Ptr
trchk PROC USES ESI EDI EAX EBX ECX EDX,otbaseadrptr:DWORD,returncodeptr:DWORD
;************************************
P2L16 otbaseadr,otbaseadrptr
mov dx,otbaseadr
in al,dx
mov cl,al ;store what was in counter
mov dx,otbaseadr
mov al,0A5h
out dx,al ;write A5h
in al,dx ;read A5h
cmp al,0A5h
je doublecheck
mov returncode,0
jmp chkend
doublecheck:
mov al,5Ah ;write 5Ah
out dx,al
in al,dx ;read 5Ah
cmp al,5Ah
je otfound
mov returncode,0
jmp chkend
otfound:
mov returncode,1
mov al,cl
out dx,al ;restore counter to pretest value
chkend:
L2P16 returncodeptr,returncode
ret
trchk endp
;**************************************************************************
;trclrpos PROC FAR EXPORT USES ESI EDI ES EAX EBX ECX
;EDX ,counterptr:far Ptr
trclrpos PROC USES ESI EDI EAX EBX ECX EDX,counterptr:DWORD
;***************************************************************************
P2L16 counter,counterptr
mov dx,otbaseadr
mov al,0
cmp counter,1
je clear
cmp counter,2
je clear2
cmp counter,3
je clear3
cmp counter,4
je clear4
jmp clearend
clear2: add dx,3
jmp clear
clear3: add dx,6
jmp clear
clear4: add dx,9
jmp clear
clear: out dx,al
inc dx
out dx,al
inc dx
out dx,al
clearend: ret
trclrpos endp
;****************************************************************************
;trsetpos PROC FAR EXPORT USES ESI EDI ES EAX EBX ECX
;EDX ,counterptr:far Ptr, newcountptr:far Ptr
trsetpos PROC USES ESI EDI EAX EBX ECX EDX,counterptr:DWORD,newcountptr:DWORD
;***************************************************************************
P2L16 counter,counterptr
P2L32 newcount,newcountptr
mov dx,otbaseadr
mov ax,newcount
cmp counter,1
je write
cmp counter,2
je write2
cmp counter,3
je write3
cmp counter,4
je write4
jmp writeend
write2: add dx,3
jmp write
write3: add dx,6
jmp write
write4: add dx,9
jmp write
write: out dx,al ;output LSB
mov cl,8
shr ax,cl
inc dx
out dx,al ;output middle SB
mov ax,newcount+2
inc dx
out dx,al ;output MSB
writeend: ret
trsetpos endp
;***************************************************************************
;trreadpos PROC FAR EXPORT USES ESI EDI ES EAX EBX ECX
;EDX ,counterptr:far Ptr, countptr:far Ptr
trreadpos PROC USES ESI EDI EAX EBX ECX EDX,counterptr:DWORD,countptr:DWORD
;***************************************************************************
P2L16 counter,counterptr
reread: mov dx,otbaseadr
cmp counter,1
je read
cmp counter,2
je read2
cmp counter,3
je read3
cmp counter,4
je read4
jmp readend
read2: add dx,3
jmp read
read3: add dx,6
jmp read
read4: add dx,9
jmp read
read: cli
in al,dx ;input LSB
mov cl,al ;store LSB in cl
add dx,2
in al,dx ;input MSB
mov bl,al ;store MSB in bl
dec dx
in al,dx ;input middle SB
mov ch,al ;store middle SB in ch
dec dx ;point to the LSB
in al,dx
cmp al,cl
je readdone ;reread if al = 0 or FF
cmp al,0FFh
je read
cmp al,0
je read
mov cl,al
readdone:
mov count,cx
mov al,bl
cbw
mov count+2,ax
L2P32 countptr,count
readend: sti
ret
trreadpos endp
;***************************************************************************
;trreadall PROC FAR EXPORT USES ESI EDI ES EAX EBX ECX
;EDX ,M1countptr:Far Ptr, M2countptr:Far Ptr, M3countptr:Far Ptr, M4countptr:Far Ptr
trreadall PROC USES ESI EDI EAX EBX ECX EDX,M1countptr:DWORD,M2countptr:DWORD,M3countptr:DWORD,M4countptr:DWORD
;***************************************************************************
readM1: cli ;READ FIRST COUNTER
mov dx,otbaseadr
in al,dx ;input LSB
mov cl,al ;store LSB in cl
add dx,2
in al,dx ;input MSB
mov bl,al ;store MSB in bl
dec dx
in al,dx ;input middle SB
mov ch,al ;store middle SB in ch
dec dx ;point to the LSB
in al,dx
cmp al,cl
je M1done ;reread if al = 0 or FF
cmp al,0FFh
je readM1
cmp al,0
je readM1
mov cl,al
M1done: mov M1count,cx
mov al,bl
cbw
mov M1count+2,ax
readM2: mov dx,otbaseadr ;do counter 2
add dx,3
in al,dx ;input LSB
mov cl,al ;store LSB in cl
add dx,2
in al,dx ;input MSB
mov bl,al ;store MSB in bl
dec dx
in al,dx ;input middle SB
mov ch,al ;store middle SB in ch
dec dx ;point to the LSB
in al,dx
cmp al,cl
je M2done ;reread if al = 0 or FF
cmp al,0FFh
je readM2
cmp al,0
je readM2
mov cl,al
M2done: mov M2count,cx
mov al,bl
cbw
mov M2count+2,ax
readM3: mov dx,otbaseadr ;do counter 3
add dx,6
in al,dx ;input LSB
mov cl,al ;store LSB in cl
add dx,2
in al,dx ;input MSB
mov bl,al ;store MSB in bl
dec dx
in al,dx ;input middle SB
mov ch,al ;store middle SB in ch
dec dx ;point to the LSB
in al,dx
cmp al,cl
je doneM3 ;reread if al = 0 or FF
cmp al,0FFh
je readM3
cmp al,0
je readM3
mov cl,al
doneM3: mov M3count,cx
mov al,bl
cbw
mov M3count+2,ax
readM4: mov dx,otbaseadr ;do counter 4
add dx,9
in al,dx ;input LSB
mov cl,al ;store LSB in cl
add dx,2
in al,dx ;input MSB
mov bl,al ;store MSB in bl
dec dx
in al,dx ;input middle SB
mov ch,al ;store middle SB in ch
dec dx ;point to the LSB
in al,dx
cmp al,cl
je doneM4 ;reread if al = 0 or FF
cmp al,0FFh
je readM4
cmp al,0
je readM4
mov cl,al
doneM4: mov M4count,cx
mov al,bl
cbw
mov M4count+2,ax
L2P32 M1countptr,M1count
L2P32 M2countptr,M2count
L2P32 M3countptr,M3count
L2P32 M4countptr,M4count
readall: sti
ret
trreadall endp
;***************************************************************************
;trhld PROC FAR EXPORT USES ESI EDI ES EAX EBX ECX
;EDX ,disableptr:Far Ptr
trhld PROC USES ESI EDI EAX EBX ECX EDX,disableptr:DWORD
;***************************************************************************
P2L16 disable,disableptr
mov dx,otbaseadr
add dx,countenable
mov ax,disable
out dx,al
ret
trhld endp
;***************************************************************************
;trsts PROC FAR EXPORT USES ESI EDI ES EAX EBX ECX
;EDX ,Ipstatusptr:Far Ptr
trsts PROC USES ESI EDI EAX EBX ECX EDX,Ipstatusptr:DWORD
;***************************************************************************
mov dx,otbaseadr
add dx,auxinputs
; mov al,disable
in al,dx
; xor al,0FFh ;invert input byte
; xor ah,ah
mov cl,al
xor ch,ch
mov Ipstatus,cx
L2P16 Ipstatusptr,Ipstatus
ret
trsts endp
;***************************************************************************
;trsync PROC FAR EXPORT USES ESI EDI ES EAX EBX ECX
;EDX,bitnumptr:Far Ptr, polarityptr:Far Ptr
trsync PROC USES ESI EDI EAX EBX ECX EDX,bitnumptr:DWORD,polarityptr:DWORD
;***************************************************************************
P2L16 bitnum,bitnumptr
P2L16 polarity,polarityptr
dec bitnum ;make 1-8 into 0-7
cmp polarity,1
jne negpolarity
mov syncsignal,0
jmp lookforsync
negpolarity:
mov syncsignal,1
lookforsync:
mov dx,otbaseadr
add dx,auxinputs
retest: in al,dx
mov cx,bitnum ;put bit to be tested in least sig
shr al,cl ; bit
and al,1 ;clear all other bits
cmp al,syncsignal
jne retest
waitforend:
in al,dx
mov cx,bitnum ;put bit to be tested in least sig
shr al,cl ; bit
and al,1 ;clear all other bits
cmp al,syncsignal
je waitforend
ret
trsync endp
End DllEntry
You have to place the dll in the VB project's folder (where the vbp file is), if this doesn't work try the windows\system directory. I haven't checked your code, but the File not found error can only be caused by placing the dll in the wrong folder or something else in your VB code.
That is why I think there is something else wrong with my DLL.
I have put it in the Windows System directory and also in the directory with my project file.
Here is my old declaration for the 16-bit DLL:
Private Declare Sub trinfo Lib "h:\sdev\tracker\trackw.dll" (rev%)
Here is the declaration for my new 32-bit DLL:
Private Declare Sub trinfo Lib "newtrackdll" (rev%)
Also tried:
Private Declare Sub trinfo Lib "newtrackdll.dll" (rev%)
Private Declare Sub trinfo Lib "c:\windows\system\newtrackdll.dll" (rev%)
etc...etc..
I get FILE NOT FOUND error. But when I try the same Declaration statement with a different DLL I get no entry point found for trinfo.
I did it like this:
Private Declare Sub trinfo Lib "c:\windows\system\Danim.dll" (rev%)
That is telling me that the VB code is ok... it is the DLL.....right??
Thanks again for everyone's tremendous help!!!!!
I have put it in the Windows System directory and also in the directory with my project file.
Here is my old declaration for the 16-bit DLL:
Private Declare Sub trinfo Lib "h:\sdev\tracker\trackw.dll" (rev%)
Here is the declaration for my new 32-bit DLL:
Private Declare Sub trinfo Lib "newtrackdll" (rev%)
Also tried:
Private Declare Sub trinfo Lib "newtrackdll.dll" (rev%)
Private Declare Sub trinfo Lib "c:\windows\system\newtrackdll.dll" (rev%)
etc...etc..
I get FILE NOT FOUND error. But when I try the same Declaration statement with a different DLL I get no entry point found for trinfo.
I did it like this:
Private Declare Sub trinfo Lib "c:\windows\system\Danim.dll" (rev%)
That is telling me that the VB code is ok... it is the DLL.....right??
Thanks again for everyone's tremendous help!!!!!
micef, in explorer right click your newly created dll and start "quick view". If signature is 00004550 and you are able to find your function names in export table (with suffix "@xx" appended) everything should be ok.
Since your dll uses in/out instructions, it will not run in WinNT/2k
And it will be better for your new dll having a name with 8 characters maximum.
japheth
Since your dll uses in/out instructions, it will not run in WinNT/2k
And it will be better for your new dll having a name with 8 characters maximum.
japheth
Hi,
Thanks for the new info. I looked at the DLL in the Quick View just like you said. I see the Descriptors that have the @_ and then the names of the routines.
I do not see the 00004550.... The only number I see is 1003852862. This number is seen throughout the Quick View screen.
What does this mean?? Thanks again for your good info.:alright:
Thanks for the new info. I looked at the DLL in the Quick View just like you said. I see the Descriptors that have the @_ and then the names of the routines.
I do not see the 00004550.... The only number I see is 1003852862. This number is seen throughout the Quick View screen.
What does this mean?? Thanks again for your good info.:alright:
00004550 should be in image file header under "signature" and is hexadecimal representation of "PE" (just to ensure that you dont have created a "NE" file with a possibly old linker.