'=========================================================================== ' Subject: MILLISECOND DELAY FOR PB Date: 06-24-98 (05:10) ' Author: Don Schullian Code: Text, PB ' Origin: d83@ath.forthnet.gr Packet: DATETIME.ABC '=========================================================================== >>>>>>>>>>>>>>>> !!WARNING!! <<<<<<<<<<<<<<<<<< This atricle contains a shameless, commercial plug. >>>>>>>>>>>>>>>> !!WARNING!! <<<<<<<<<<<<<<<<<< Hi, Here's one for you that seems to pop up now and agian. It is just one of the hundreds of little goodies you can find in my library "Nutz 'n Boltz". MicroDelay works on 1/1000ths of a second (997 to be exact). To delay the program by 1/3 of a second CALL MilliDelay( 333) To delay the program by 1 full second CALL MilliDelay(1000) There are 2 versions of the same routine below. One uses PowerBASIC's REG/CALL INTERRUPT the other uses ASM code. You'll note that the PB version costs 112 bytes more code than the ASM version. That is an additional 25% to do the _SAME_ job. NOTE: This puppy may not work on XT's but should be OK for AT's and above. Have fun, Don '------------------------------------------------------------- '---------- start code ------------------------------------- '------------------------------------------------------------- $if 1 SUB MilliDelay( BYVAL Millis% ) LOCAL PUBLIC ' CODE 448 BYTES LOCAL Msec& Msec& = ( Millis% * 1000 ) REG 1, &h8600 REG 3, ( Msec& \ 65536 ) REG 4, ( Msec& AND 65535 ) CALL INTERRUPT &h15 END SUB $else SUB MilliDelay( BYVAL Millis% ) LOCAL PUBLIC ' CODE 336 BYTES ! mov ax,1000 ; ! mul Millis% ; DX:AX = Micros ! mov cx,dx ; ! mov dx,ax ; CX:DX = Micros ! mov ax,&h8600 ; Wait Interval ! int &h15 ; BIOS system services END SUB $endif