The MASM Forum Archive 2004 to 2012
Welcome, Guest. Please login or register.
March 24, 2023, 12:12:46 PM

Login with username, password and session length
Search:     Advanced search
128553 Posts in 15254 Topics by 684 Members
Latest Member: mottt
* Home Help Search Login Register
+  The MASM Forum Archive 2004 to 2012
|-+  Project Support Forums
| |-+  MASM32
| | |-+  wait_key.asm
« previous next »
Pages: 1 [2] Print
Author Topic: wait_key.asm  (Read 26786 times)
dedndave
Member
*****
Posts: 12523


Re: wait_key.asm
« Reply #15 on: April 29, 2012, 06:24:00 PM »

yah - did some reading
you have to install your own INT 28h handler - something like sinsi did - it is initially just an IRET
the multiplex interrupt might be the way to go - provided the OS is recent enough to support it
Logged
FORTRANS
Member
*****
Gender: Male
Posts: 1147


Imagine


Re: wait_key.asm
« Reply #16 on: April 29, 2012, 09:26:23 PM »

yah - did some reading
you have to install your own INT 28h handler - something like sinsi did - it is initially just an IRET
the multiplex interrupt might be the way to go - provided the OS is recent enough to support it

Hi,

   Int 28H and Int 2FH were introduced in MS-DOS 2.0 to support
the PRINT command.  That was to allow PRINT to operate in the
background.  To limit CPU usage in some of my code I use something
similar to what sinsi posted.  I just put a HLT in the test for a key
loop.  That was done to reduce power usage on the HP 200LX
palmtop.

Regards,

Steve N.
Logged
MichaelW
Global Moderator
Member
*****
Gender: Male
Posts: 5161


Re: wait_key.asm
« Reply #17 on: April 29, 2012, 10:41:28 PM »

Running on a P3, HLT in a loop had no apprent effect under NTVDM.
Logged

eschew obfuscation
dedndave
Member
*****
Posts: 12523


Re: wait_key.asm
« Reply #18 on: April 29, 2012, 11:07:34 PM »

yah - that's what i was afraid of   Tongue
NTVDM probably ignores HLT instructions altogether
Logged
FORTRANS
Member
*****
Gender: Male
Posts: 1147


Imagine


Re: wait_key.asm
« Reply #19 on: April 30, 2012, 01:00:19 PM »

Hi,

   Well a quick test of HLT shows no effect with a Win2k NTVDM
or an OS/2 VDM on my P-III.  Using the graphical CPU meters
of each.  Got a way to measure CPU usage under plain DOS?

   With the MS-DOS 5.0 on the 200LX I used an amp meter.
But I can't find what the actual numbers were anymore...

Regards,

Steve N.
Logged
hutch--
Administrator
Member
*****
Posts: 12013


Mnemonic Driven API Grinder


Re: wait_key.asm
« Reply #20 on: April 30, 2012, 01:19:07 PM »

Illuminate me here, with a non-re-entrant OS like MS-DOS, what is the point of looking for a wait instruction/sequence/interrupt when only one task is running ? Surely you just shove a test in the polling loop for something like a keystroke or mouse event (if I vagely remember int 33h correctly) and let the processor ping its heart out ?
Logged

Regards,



Download site for MASM32
http://www.masm32.com
sinsi
Member
*****
Gender: Male
Posts: 1758


RIP Bodie 1999-2011


Re: wait_key.asm
« Reply #21 on: April 30, 2012, 01:25:35 PM »

From the Intel docs
Quote
The HLT instruction is a privileged instruction. When the processor is running in
protected or virtual-8086 mode, the privilege level of a program or procedure must
be 0 to execute the HLT instruction.
Makes sense I suppose. You don't want a DOS program to halt everything, especially in a single CPU case...
Logged

Light travels faster than sound, that's why some people seem bright until you hear them.
dedndave
Member
*****
Posts: 12523


Re: wait_key.asm
« Reply #22 on: April 30, 2012, 01:38:20 PM »

as i remember, it didn't actually halt anything under DOS, either - lol
the first hardware interrupt that came along caused execution to continue
when you issued a HLT instruction on a 4004 or 8008, the world stopped spinning   Tongue
Logged
sinsi
Member
*****
Gender: Male
Posts: 1758


RIP Bodie 1999-2011


Re: wait_key.asm
« Reply #23 on: April 30, 2012, 01:43:25 PM »

>the first hardware interrupt that came along caused execution to continue
That's the point. This is how you nowadays stop a core that's not needed.
The BSP will send an interrupt to the AP when needed and off it goes.
Logged

Light travels faster than sound, that's why some people seem bright until you hear them.
FORTRANS
Member
*****
Gender: Male
Posts: 1147


Imagine


Re: wait_key.asm
« Reply #24 on: April 30, 2012, 02:08:47 PM »

Illuminate me here, with a non-re-entrant OS like MS-DOS, what is the point of looking for a wait instruction/sequence/interrupt when only one task is running ? Surely you just shove a test in the polling loop for something like a keystroke or mouse event (if I vagely remember int 33h correctly) and let the processor ping its heart out ?

Hi,

   Well in this case, the HP 200LX is a palmtop that can be running
on 2 AA batteries.  So reducing CPU usage prolongs the time between
chargings.

   Thanks for the Intel quote sinsi.  Makes some sense.  Though the
PM OS should process the exception.  But it could possibly wait before
returning to the RM/V86 program.  Seems that these don't.

Regards,

Steve N.
Logged
sinsi
Member
*****
Gender: Male
Posts: 1758


RIP Bodie 1999-2011


Re: wait_key.asm
« Reply #25 on: April 30, 2012, 02:31:55 PM »

>Though the PM OS should process the exception.
"Processes it" as in "ignores it" I guess. It does throw an exception.
Logged

Light travels faster than sound, that's why some people seem bright until you hear them.
MichaelW
Global Moderator
Member
*****
Gender: Male
Posts: 5161


Re: wait_key.asm
« Reply #26 on: April 30, 2012, 09:02:34 PM »

For those running heavily overclocked Pentiums under DOS, it might be useful to keep the CPU from frying, while waiting at maximum speed tgrin

Come to think of it, when I used to routinely run DOS apps I sometimes had problems with the NTVDM CPU usage being so high that everything else slowed to a crawl. Periodic calls to the MS-DOS Idle Call function could have solved this problem, and done right, with no perceptible effect on the speed of the DOS app.
Logged

eschew obfuscation
Pages: 1 [2] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP The MASM Forum Archive 2004 to 2012 | Powered by SMF 1.0.12.
© 2001-2005, Lewis Media. All Rights Reserved.
Valid XHTML 1.0! Valid CSS!