News:

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

Invalid symbol type in expression

Started by Magnum, May 26, 2010, 01:19:45 AM

Previous topic - Next topic

Magnum

I am getting "invalid symbol type in expression" when I assemble this.

include \masm32\source\timers.asm
include \masm32\include\windows.inc

    .code

start:
    call counter_begin   
    invoke Beep, 1200, 300 ; Sound duration and the frequency, in hertz, of the sound
    invoke ExitProcess,0
    call counter_end

end start
Have a great day,
                         Andy

sinsi

counter_begin is a macro, not a proc, so you shouldn't 'call' it.
Light travels faster than sound, that's why some people seem bright until you hear them.

Magnum

Quote from: sinsi on May 26, 2010, 01:44:59 AM
counter_begin is a macro, not a proc, so you shouldn't 'call' it.

I tried this and get an endless beeping. :-)


start:
   
counter_begin 10000000, HIGH_PRIORITY_CLASS

invoke Beep, 1200, 300 ; Sound duration and the frequency, in hertz, of the sound
   
counter_end
   
print chr$(" cycles",13,10)
mov   eax, input(13,10,"Press enter to exit...")
invoke ExitProcess,0

Have a great day,
                         Andy

sinsi

Maybe try a few less than 10 million beeps?  :lol
Light travels faster than sound, that's why some people seem bright until you hear them.

clive

Quote from: Magnum on May 26, 2010, 01:52:54 AM
I tried this and get an endless beeping. :-)

No shit, maybe you you should do about 10 iterations. The counters are going to be pretty meaningless over a period of 12 seconds. a) 32-bit values only hold 4 billions cycles (and you are clocking at maybe 3 GHz), b) the cycles are being burned in other tasks.
It could be a random act of randomness. Those happen a lot as well.

Magnum

Quote from: clive on May 26, 2010, 02:37:26 AM
Quote from: Magnum on May 26, 2010, 01:52:54 AM
I tried this and get an endless beeping. :-)

No shit, maybe you you should do about 10 iterations. The counters are going to be pretty meaningless over a period of 12 seconds. a) 32-bit values only hold 4 billions cycles (and you are clocking at maybe 3 GHz), b) the cycles are being burned in other tasks.

That kind of language is quite unnecessary.

Have a great day,
                         Andy

oex

Quote from: Magnum on May 26, 2010, 02:46:36 AM
Quote from: clive on May 26, 2010, 02:37:26 AM
4 billions cycles
That kind of language is quite unnecessary.

Yeah phrases like this have no place on this board :bg
We are all of us insane, just to varying degrees and intelligently balanced through networking

http://www.hereford.tv

GregL


Magnum

Quote from: Greg Lyon on May 27, 2010, 06:40:52 PM
I've seen a lot worse on here.


The point is this.

If someone can't cheerfully answer me, then I would rather they not answer.
It'll keep their blood pressure down too.  :bg

I try to treat others like I would want them to treat me.

Have a great day,
                         Andy

clive

Apologies, I will keep that in mind.
It could be a random act of randomness. Those happen a lot as well.

dedndave

did you get your code working Magnum ?

Ghandi

Quote
If someone can't cheerfully answer me, then I would rather they not answer.

Not trying to start a debate, but i thought this was a forum where people could express thoughts? Personally i actually lauged at Clives comment, because i took it lightheartedly, but i guess everybody is different. I can understand where the comment came from though, if i may say.

As we all know, assembler requires us to read and pay attention to all of the small details, else it blows up in our faces.

Let's take this case for example:


BOOL WINAPI Beep(
  __in          DWORD dwFreq,
  __in          DWORD dwDuration
);

Parameters
dwFreq
The frequency of the sound, in hertz. This parameter must be in the range 37 through 32,767 (0x25 through 0x7FFF).

Windows Me/98/95:  The Beep function ignores this parameter.
dwDuration
The duration of the sound, in milliseconds.

Windows Me/98/95:  The Beep function ignores this parameter.



So, we pass the duration and frequency to the API. Seems pretty straightforward, lets apply it to the code example given:


counter_begin 10000000, HIGH_PRIORITY_CLASS

invoke Beep, 1200, 300 ; Sound duration and the frequency, in hertz, of the sound
   
counter_end


We have a macro which will repeat the enclosed code X amount of times, setting the thread priority as well.

The code itself is a call to Beep, with a frequency of 1200hz and a duration of 300ms (unless this code is run on win 9x, where it is ignored) and looking at the variable for the repeat count, it says 10 million. I'm not a mathemetician, but for every 10 calls to Beep the duration amounts to 3 seconds, so 10 million iterations will mean 3 million seconds for the code to complete. If it is run on 9x however, it will be the same formula but with the default value that the OS uses for its Beep API. This is not counting any overhead from the OS, etc.

Either way, the projected running time for this code is not short and with no pause between calls to Sleep, it will be like one continuous (and annoying) drone.

HR,
Ghandi

Magnum

Quote from: dedndave on May 28, 2010, 06:40:07 AM
did you get your code working Magnum ?

Yes, this is one example.



start:
             ; run 5 times
counter_begin 10, HIGH_PRIORITY_CLASS ; loopcount and priority

; create a 0 byte files
invoke CreateFile,ADDR fname1,
GENERIC_READ,
0,
NULL,
CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL,
NULL
invoke CloseHandle,eax
test eax, eax
jnz next
print SADD("CloseHandle failed")

next:
LEA EAX , TheStruct
  ; Caller HWND - Can be zero
  MOV DWORD PTR [EAX], 0b
  ; The Shell Function , Here we wanna delete
  MOV DWORD PTR [EAX+4] , FO_DELETE
  ; The address of the file to get deleted
  MOV DWORD PTR [EAX+8] , OFFSET TheFile
  ; The destination address, the delete operation accepts no destination
  MOV DWORD PTR [EAX+12] , 0b
  ; The flags, we wanna do this silently and without any confirmations to the user
  MOV DWORD PTR [EAX+16] , FOF_NOCONFIRMATION or FOF_SILENT
  PUSH EAX
  CALL SHFileOperation

counter_end
   
print ustr$(eax)

print chr$(" cycles",13,10)

mov   eax, input(13,10,"Press ENTER to exit...")
invoke ExitProcess,0

Have a great day,
                         Andy