News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Sound synth system

Started by gabor, June 07, 2009, 06:39:14 PM

Previous topic - Next topic

dedndave

lol Jochen - good afternoon (i think that's right)
i am surprised to see you count bytes instead of clock ticks
which is fastest ?

jj2007

Quote from: dedndave on July 02, 2009, 12:43:19 PM
lol Jochen - good afternoon (i think that's right)
i am surprised to see you count bytes instead of clock ticks
which is fastest ?

In case of doubt, the shorter one - less cache pollution. In any case, there is not much to gain from removing the frame, as mov [esp+X] needs one byte more than mov [ebp+X] - see below...

004010A0      /$ 55                    push ebp
004010A1      |. 8BEC                  mov ebp, esp
004010A3      |. 83C4 F4               add esp, -0C
004010A6      |. C745 F8 02000000      mov dword ptr [ebp-8], 2
004010AD      |. C745 F4 03000000      mov dword ptr [ebp-C], 3
004010B4      |. 90                    nop
004010B5      |. 83C4 80               add esp, -80
004010B8      |. 8BC4                  mov eax, esp
004010BA      |. 90                    nop
004010BB      |. C740 04 01000000      mov dword ptr [eax+4], 1
004010C2      |. C740 08 01000000      mov dword ptr [eax+8], 1
004010C9      |. 90                    nop
004010CA      |. C74424 04 01000000    mov dword ptr [esp+4], 1
004010D2      |. C74424 08 01000000    mov dword ptr [esp+8], 1
004010DA      |. 83EC 80               sub esp, -80
004010DD      |. C9                    leave
004010DE      \. C3                    retn



MyProc proc
LOCAL v1, v2, v3
  mov v2, 2
  mov v3, 3
  nop
  add esp, -128
  mov eax, esp
  nop
  mov dword ptr [eax+4], 1
  mov dword ptr [eax+8], 1
  nop
  mov dword ptr [esp+4], 1
  mov dword ptr [esp+8], 1
  sub esp, -128
  ret
MyProc endp

dedndave

ok - now you have confused me again
i was all nice and level until i tried to read and understand that post - lol
is it me or are you hitting the vino ?
remember, it's 6 AM, here - i am only on my 2nd cup of coffee

jj2007

I thought it was simple, but 6 AM is indeed very early :bg

In short: removing the stack frame is fine if you don't need local variables, but replacing it with a hand-made substitute

add esp, -80
mov [esp], SomeWeirdFigure
sub esp, -80


is simply a bad option. The stack frame itself costs 7 bytes, the substitute costs at least 6 bytes, plus one byte more for every usage because [esp] is a byte longer than [ebp].

Now theoretically we could embark on some timings... :bg

dedndave

it isn't any worse than letting masm make the frame - lol
(no ebp register involved)
these guys were talking about using stack space as temporary storage
the alternative is some kind of Alloc/Free function
adjusting the esp register seems the simplest way

jj2007

Quote from: dedndave on July 02, 2009, 03:45:21 PM
it isn't any worse than letting masm make the frame - lol
(no ebp register involved)

Sure a frame blocks ebp, but if you want to use ebp in a non-frame function, you need additional code anyway.

gabor

Hi!

Please test the last version. I heard it had problems under Vista...

Thanks and greets!
Gábor

Biterider


dedndave

seems to work fine here, Gabor (small, too   :U )
XP MCE SP2
snappy tune ! - lol   :boohoo:

rags

God made Man, but the monkey applied the glue -DEVO

elegem

Quote from: gabor on September 13, 2009, 05:43:28 PM
Hi!

Please test the last version. I heard it had problems under Vista...

Thanks and greets!
Gábor
Catchy...ye, you need to run as administrator under Vista. Must be a permission error of some sort.

dedndave

Gabor,
  if you figure out which API function requires elevated permissions, I'd like to know which one it is - lol
i try to write code that works under vista without uac problems, as well
thanks

gabor

Thanks for your help!

I cannot think of any parts of the code except the sound play component.
There are the following API calls:
  • GetTickCount
  • Sleep
  • LoadLibrary
  • GetProcAddress
  • GetDesktopWindow
  • GetProcessHeap
  • HeapAlloc
  • HeapFree
  • CreateThread
  • FreeLibrary
None of these seems suspicious to me. In general, I'd need a list of API changes between XP and Vista, and maybe Win7...
I'll try to find an explanation.

Greets
Gábor

dedndave

wellllllll
the only one i see that might be a prob is CreateThread - that should be allowed
hmmmmmmmmmm
it would be much easier for someone running vista to troubleshoot it

elegem

#44
Quote from: gabor on September 14, 2009, 02:46:29 PM
Thanks for your help!

I cannot think of any parts of the code except the sound play component.
There are the following API calls:
  • GetTickCount
  • Sleep
  • LoadLibrary
  • GetProcAddress
  • GetDesktopWindow
  • GetProcessHeap
  • HeapAlloc
  • HeapFree
  • CreateThread
  • FreeLibrary
None of these seems suspicious to me. In general, I'd need a list of API changes between XP and Vista, and maybe Win7...
I'll try to find an explanation.

Greets
Gábor

Well..the one you provided in  ssn_m.zip (125.51 KB - downloaded 64 times.) runs fine without UAC. You must have changed something.

I tried debugging it and it breaks at 40120C with the error "Unhandled exception at 0x0040120c in testbed.exe: 0xC0000005: Access violation reading location 0x00000018."

0040119F  ret             
004011A0  ret             
004011A1  push        ebx 
004011A2  push        edi 
004011A3  movzx       ebx,word ptr [eax]
004011A6  inc         eax 
004011A7  cmp         bl,0FFh
004011AA  je          004011BB
004011AC  inc         eax 
004011AD  mov         edi,ebx
004011AF  and         bh,0Fh
004011B2  shr         edi,0Ch
004011B5  mov         word ptr [edx+edi*4],bx
004011B9  jmp         004011A3
004011BB  pop         edi 
004011BC  pop         ebx 
004011BD  ret             
004011BE  lea         edx,[ecx+18h]
004011C1  call        004011A1
004011C6  ret             
004011C7  pushad           
004011C8  test        byte ptr [ecx+0Dh],1
004011CC  jne         004012A8
004011D2  or          byte ptr [ecx+0Dh],1
004011D6  cmp         byte ptr [ecx+0Ch],0
004011DA  je          004011E6
004011DC  cmp         byte ptr [ecx+0Ch],1Ch
004011E0  jbe         004012A8
004011E6  mov         ebx,7
004011EB  push        ecx 
004011EC  mov         eax,dword ptr ds:[0040450Eh]
004011F1  cmp         dword ptr [ecx+ebx*4+18h],eax
004011F5  je          00401283
004011FB  movzx       esi,byte ptr [ecx+ebx*4+18h]
00401200  movzx       edi,byte ptr [ecx+ebx*4+19h]
00401205  mov         ebp,dword ptr [ecx+8]
00401208  or          esi,esi
0040120A  jne         0040121B
0040120C  movzx       esi,byte ptr [ebp+edi*4+18h]
00401211  movzx       edi,byte ptr [ebp+edi*4+19h]
00401216  mov         ebp,dword ptr [ebp+8]
00401219  jmp         00401208
0040121B  push        ecx 
0040121C  mov         ecx,ebp
0040121E  mov         eax,esi
00401220  call        00401418
00401225  mov         ecx,eax
00401227  or          eax,eax
00401229  jne         00401237
0040122B  pop         ecx 
0040122C  mov         eax,dword ptr ds:[0040450Eh]
00401231  mov         dword ptr [ecx+ebx*4+18h],eax
00401235  jmp         00401283
00401237  cmp         byte ptr [ecx+0Ch],0
0040123B  jne         0040125B
0040123D  call        004011C7
00401242  mov         edx,edi
00401244  movzx       edi,byte ptr [ecx+edx*4+39h]
00401249  movzx       eax,byte ptr [ecx+edx*4+38h]
0040124E  call        00401418
00401253  or          eax,eax
00401255  je          0040122B
00401257  mov         ecx,eax
00401259  jmp         00401237
0040125B  call        004011C7
00401260  pop         edx 
00401261  mov         ebp,ecx
00401263  cmp         byte ptr [edx+0Ch],0
00401267  je          00401283
00401269  or          edx,edx
0040126B  je          00401283

I've attatched a dump file...not sure if its of any use...let me know how I can help further=P.