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
counter_begin is a macro, not a proc, so you shouldn't 'call' it.
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
Maybe try a few less than 10 million beeps? :lol
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.
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.
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
I've seen a lot worse on here.
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.
Apologies, I will keep that in mind.
did you get your code working Magnum ?
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
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