Help with machine instructions 
Author Message
 Help with machine instructions

I am working on an article on "Data Sharing in Windows/32" and would
appreciate some help. To make a point about pre-emptive multi-tasking, I
would like to get the machine instructions (that is, the assembly-language
code) generated by either  PB/CC or PB/DLL (32 bit) for two lines of this
function:

TYPE MemoryFileType
     UserCount  AS LONG
     LastControlNo (1 TO 10) AS LONG
END TYPE

FUNCTION GetNextControlNo (Idx AS LONG) AS LONG
   ' gets LastControlNo(idx)+ 1 from current file mapped object
   ' uses GLOBAL hMemoryFile
   DIM pc AS MemoryFileType PTR
   DIM C  AS MemoryFileType     ' need for SIZEOF, as memoryFileType in
SIZEOF produces error
   DIM LockValue AS LONG
   DIM LastError AS LONG

   DIM hMutex AS LONG
   hMutex = 3000

   LockValue = WaitForSingleObject(hMutex, 60000) ' 60000= 1 minute
%INFINITE)
   SELECT CASE LockValue
     CASE %WAIT_OBJECT_0, %WAIT_ABANDONED             ' it's our turn
      pC = MapViewOfFile (hMemoryFile,  %FILE_MAP_WRITE, 0,0, SIZEOF(C))


       UnmapViewOfFile hMemoryFile
       ReleaseMutex hMutex

  END SELECT

END FUNCTION

This is not the whole function, but it should compile as long as you have
the WIN32API.INC file. All I am interested in are the two marked lines. I
don't care about anything else. Specifically, I want to know if either one
or both of these lines results in two or more machine instructions from
which Windows "might" pre-emptively switch away between those instructions.

First helper gets a credit in the article, so please let me know your
hometown when replying.

Thanks,
Michael Mattias
Tal Systems
Racine WI USA

--
Michael Mattias
Tal Systems
Racine WI USA
The views and opinions expressed herein are my own.
As I am self-employed, they also express the views of my employer.



Mon, 18 Mar 2002 03:00:00 GMT  
 Help with machine instructions
There's an alternative.

If you'll look up the Shell functions in Shell32.dll you discover a function
to share data with.
Never tested, never tried it, don't know on NT.
I even don't know how i got the info, it's some link from a popular VB site
like VBNET or something.
If you're interested in this workaround i could try to get some more info.

Quote:

>I am working on an article on "Data Sharing in Windows/32" and would
>appreciate some help. To make a point about pre-emptive multi-tasking, I
>would like to get the machine instructions (that is, the assembly-language
>code) generated by either  PB/CC or PB/DLL (32 bit) for two lines of this
>function:

>TYPE MemoryFileType
>     UserCount  AS LONG
>     LastControlNo (1 TO 10) AS LONG
>END TYPE

>FUNCTION GetNextControlNo (Idx AS LONG) AS LONG
>   ' gets LastControlNo(idx)+ 1 from current file mapped object
>   ' uses GLOBAL hMemoryFile
>   DIM pc AS MemoryFileType PTR
>   DIM C  AS MemoryFileType     ' need for SIZEOF, as memoryFileType in
>SIZEOF produces error
>   DIM LockValue AS LONG
>   DIM LastError AS LONG

>   DIM hMutex AS LONG
>   hMutex = 3000

>   LockValue = WaitForSingleObject(hMutex, 60000) ' 60000= 1 minute
>%INFINITE)
>   SELECT CASE LockValue
>     CASE %WAIT_OBJECT_0, %WAIT_ABANDONED             ' it's our turn
>      pC = MapViewOfFile (hMemoryFile,  %FILE_MAP_WRITE, 0,0, SIZEOF(C))


>       UnmapViewOfFile hMemoryFile
>       ReleaseMutex hMutex

>  END SELECT

>END FUNCTION

>This is not the whole function, but it should compile as long as you have
>the WIN32API.INC file. All I am interested in are the two marked lines. I
>don't care about anything else. Specifically, I want to know if either one
>or both of these lines results in two or more machine instructions from
>which Windows "might" pre-emptively switch away between those instructions.

>First helper gets a credit in the article, so please let me know your
>hometown when replying.

>Thanks,
>Michael Mattias
>Tal Systems
>Racine WI USA

>--
>Michael Mattias
>Tal Systems
>Racine WI USA
>The views and opinions expressed herein are my own.
>As I am self-employed, they also express the views of my employer.



Mon, 18 Mar 2002 03:00:00 GMT  
 Help with machine instructions

Quote:

> I am working on an article on "Data Sharing in Windows/32" and would
> appreciate some help. To make a point about pre-emptive multi-tasking, I
> would like to get the machine instructions (that is, the assembly-language
> code) generated by either  PB/CC or PB/DLL (32 bit) for two lines of this
> function:

> TYPE MemoryFileType
>      UserCount  AS LONG
>      LastControlNo (1 TO 10) AS LONG
> END TYPE

> FUNCTION GetNextControlNo (Idx AS LONG) AS LONG
>    ' gets LastControlNo(idx)+ 1 from current file mapped object
>    ' uses GLOBAL hMemoryFile
>    DIM pc AS MemoryFileType PTR
>    DIM C  AS MemoryFileType     ' need for SIZEOF, as memoryFileType in
> SIZEOF produces error

I think you can use LEN(MemoryFileType) without having to declare a
variable.

Quote:
>    DIM LockValue AS LONG
>    DIM LastError AS LONG

>    DIM hMutex AS LONG
>    hMutex = 3000

>    LockValue = WaitForSingleObject(hMutex, 60000) ' 60000= 1 minute
> %INFINITE)
>    SELECT CASE LockValue
>      CASE %WAIT_OBJECT_0, %WAIT_ABANDONED             ' it's our turn
>       pC = MapViewOfFile (hMemoryFile,  %FILE_MAP_WRITE, 0,0, SIZEOF(C))

The code posted below starts here and contains all remaining lines.
You'll have to figure out what it all means. I compiled with PB/DLL6.0

Quote:


>        UnmapViewOfFile hMemoryFile
>        ReleaseMutex hMutex

>   END SELECT

> END FUNCTION

00401264   mov       ebx,dword ptr [ebp-7c]
00401267   mov       dword ptr [ebp-2c],ebx
0040126a   mov       ebx,dword ptr [ebp+08]
0040126d   mov       eax,dword ptr [ebx]
0040126f   sub       eax,00000001
00401272   shl       eax,02
00401275   mov       ebx,dword ptr [ebp-2c]
00401278   add       ebx,eax
0040127a   inc       dword ptr [ebx+04]
0040127d   mov       ebx,dword ptr [ebp-7c]
00401280   mov       dword ptr [ebp-2c],ebx
00401283   mov       ebx,dword ptr [ebp+08]
00401286   mov       eax,dword ptr [ebx]
00401288   sub       eax,00000001
0040128b   shl       eax,02
0040128e   mov       ebx,dword ptr [ebp-2c]
00401291   add       ebx,eax
00401293   mov       eax,dword ptr [ebx+04]
00401296   mov       dword ptr [ebp-78],eax
00401299   lea       ebx,dword ptr [ebp-000000b4]
0040129f   push      ebx
004012a0   call      dword ptr [0040317c]
004012a6   push      dword ptr [ebp-000000b8]
004012ac   call      dword ptr [00403178]
004012b2   mov       eax,dword ptr [ebp-78]
004012b5   lea       esp,dword ptr [ebp-0c]
004012b8   pop       edi
004012b9   pop       esi
004012ba   pop       ebx
004012bb   pop       ebp
004012bc   ret       0004

--
Peter Manders.
Please remove the 'u' to reply.



Mon, 18 Mar 2002 03:00:00 GMT  
 Help with machine instructions
Actually, I do not have to figure it out. That it's more than two machine
instructions (no kidding!) is all I need to know. In fact, it's so many
instructions (some of which, I'm almost ashamed to admit I understand) that
it makes my point far more dramatically than I had dared dream!

Than you very much for the prompt reply.
--
Michael Mattias
Tal Systems
Racine WI USA

PS: Let me know your hometown. You are about to have your name published in
22 countries.

Quote:

>00401264   mov       ebx,dword ptr [ebp-7c]
>00401267   mov       dword ptr [ebp-2c],ebx
> [beaucoup snippage]



Tue, 19 Mar 2002 03:00:00 GMT  
 Help with machine instructions

Quote:

>There's an alternative.

>If you'll look up the Shell functions in Shell32.dll you discover a
function
>to share data with.
>If you're interested in this workaround i could try to get some more info.


>>I am working on an article on "Data Sharing in Windows/32" and would

I know there are alternatives. But the first article in the series is about
THIS alternative.

Make sure your subscription to "BASICally Speaking" is current!

MCM



Tue, 19 Mar 2002 03:00:00 GMT  
 Help with machine instructions

Quote:

> Than you very much for the prompt reply.

You're welcome.

Quote:

> PS: Let me know your hometown. You are about to have your name published in
> 22 countries.

Oss, the Netherlands.

Could you send me a screenshot of that please?
Just remove the "u" from my email address.

--
Peter Manders.
Please remove the 'u' to reply.



Tue, 19 Mar 2002 03:00:00 GMT  
 Help with machine instructions

Quote:
>Make sure your subscription to "BASICally Speaking" is current!

Where to find it?


Quote:

>>There's an alternative.

>>If you'll look up the Shell functions in Shell32.dll you discover a
>function
>>to share data with.
>>If you're interested in this workaround i could try to get some more info.


>>>I am working on an article on "Data Sharing in Windows/32" and would

>I know there are alternatives. But the first article in the series is about
>THIS alternative.

>Make sure your subscription to "BASICally Speaking" is current!

>MCM



Wed, 20 Mar 2002 03:00:00 GMT  
 Help with machine instructions

Quote:


>>>>I am working on an article on "Data Sharing in Windows/32"...>>
>>I know there are alternatives. But the first article in the series is
about
>>THIS alternative.

>>Make sure your subscription to "BASICally Speaking" is current!

>Where to find it?

BASICally Speaking is published by:
Information Management Systems
8034 Appleton St.
Dearborn Heights MI 48127-1402
Voice: 313-730-1861
Fax:   313-730-0678
Sales: 1-800-750-6390


www.infoms.com

At the web site, select "powerbasic add-ons" (or maybe it's "add -ins"); or
go directly to the BASICally Speaking page at www.infoms.com/bsp.htm

(I have no financial interest in IMS or BASICally Speaking)

Michael Mattias
Racine WI



Wed, 20 Mar 2002 03:00:00 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. Embedded Machine Instructions

2. 486 machine code instructions?

3. Specific Machine Instructions in GNAT

4. Instruction Speed and instruction availability

5. Help with an instruction

6. CW4 - Error in online Help instructions

7. Instruction SUM is very late Help me!!!!

8. cmp instruction- please help

9. Need help with i486 instructions...

10. HELP: CLI and STI instructions

11. Please help with some assembly instructions

12. help : CASE instruction behaviour

 

 
Powered by phpBB® Forum Software