Just another update

This commit is contained in:
Ingy döt Net 2015-02-20 00:35:01 -05:00
parent a25938f123
commit 00a190b0a6
6591 changed files with 94363 additions and 23227 deletions

View file

@ -0,0 +1,106 @@
START
PRINT DATA,GEN
YREGS , REGISTER EQUATES (e.g. 0 = R0)
SLEEP CSECT
SLEEP AMODE 31 addressing mode 31 bit
SLEEP RMODE ANY loader determines 31 or 24
***********************************************************************
* REENTRANT. Logically swap out a task for a number of seconds
* specified in PARM. Minimum 0, maximum 60 seconds
*
* MVS rexx (the original rexx) does not have a sleep function. This
* program can be called from rexx, assuming this program is in
* LINKLIST, as follows:
*
* /* rexx */
* wait_time = '6' /* number of seconds to sleep */
* say 'Sleeping...'
* address LINKMVS "SLEEP wait_time" /* invoke SLEEP */
* say 'Awake!
***********************************************************************
PROLOG BAKR R14,0 satck caller's registers
LR R4,R1 save parm pointer
LR R12,R15 entry point addr to R12
USING SLEEP,R12 tell assembler about that
B AROUND avoid abend S0C1
DC C'SLEEP ' CSECT NAME
DC C'C=2014.05.10 ' CHANGE DATE
DC C'A=&SYSDATE ' ASSEMBLY DATE
DC C'T=&SYSTIME ' CHANGE TIME
DC C'MarcvdM. ' PROGRAMMER NAME
AROUND L R10,0(0,R4) load parm address in R10
XR R15,R15 clear R15
LH R15,0(0,R10) load parm length in R15
LR R6,R15 save length in R6
LTR R15,R15 parm length 0?
BZ NOPARM yes, exit before getmain
C R6,F2 parmlength > 2 ?
BH NOPARM yes, exit before getmain
STORAGE OBTAIN,LENGTH=WALEN,LOC=ANY get some storage
LR R9,R1 address of storage in R9
USING WAREAX,R9 base for data section (DSECT)
MVC EYECAT,=C'**MARC**' make storage easy to find in dump
MVC SECONDS,C00 set field to F0F0
C R6,F1 parmlength = 1?
BNE COPYSECS no, copy both bytes
MVC SECONDS+1(1),2(R10) yes, just copy one byte.
B TRTEST
COPYSECS MVC SECONDS,2(R10)
* test supplied parameter for valid integer values
TRTEST TRT SECONDS(1),VALINT6 first parm byte no higher as 6?
BNZ NOPARM_REL higher, release storage and return
TRT SECONDS+1(1),VALINT9 second byte valid?
BNZ NOPARM_REL no, release storage and return
CLC SECONDS(1),=C'6' first parm byte < 6?
BNE DOWAIT yes, do wait
CLC SECONDS+1(1),=C'0' first eq. 6, second > 0?
BNE NOPARM_REL yes, release storage and return
DOWAIT DS 0H
MVC WAWTO(DWTOL),DWTO copy WTO list form to obtained st.
MVC WAWTO+18(2),SECONDS copy in nr. of seconds
WTO MF=(E,WAWTO) issue WTO, execute form
MVC HOURS,C00 zero out hours
MVC MINUTS,C00 and minutes
MVC REST,C00 and milliseconds
STIMER WAIT,DINTVL=TIMEVAL SVC 47: logical swap out (sleep)
B EXIT done
NOPARM_REL DS 0H
STORAGE RELEASE,ADDR=(R9),LENGTH=WALEN free obtained storage
LA R15,4 set return code 4
B RETURN return to caller
EXIT DS 0H
STORAGE RELEASE,ADDR=(R9),LENGTH=WALEN free obtained storage
WTO ' Awake!',ROUTCDE=11 fixed wake-up string
NOPARM EQU *
RETURN PR , return to caller
*
* --------------------------------------------------------------------
* CONSTANTS
* --------------------------------------------------------------------
DWTO WTO ' Sleeping... (XX seconds)',ROUTCDE=11,MF=L
DWTOL EQU *-DWTO length of WTO list form
F1 DC F'1'
F2 DC F'2'
C00 DC C'00'
VALINT6 DC 256XL1'01'
ORG *-16
VALOK6 DC 7XL1'00' F0-F6: OFFSETS 240-246
VALINT9 DC 256XL1'01'
ORG *-16
VALOK9 DC 10XL1'00' F0-F9: OFFSETS 240-249
DS 0D
LTORG , FORCE DISPLACEMENT LITERALS
* --------------------------------------------------------------------
* DSECT (data section)
* --------------------------------------------------------------------
WAREAX DSECT ,
WAWTO DS CL(DWTOL) reentrant WTO area
EYECAT DS CL8
TIMEVAL DS 0CL8
HOURS DS CL2 will be zeroed
MINUTS DS CL2 will be zeroed
SECONDS DS CL2 from parm
REST DS CL2 will be zeroed
WALEN EQU *-WAREAX length of DSECT
* --------------------------------------------------------------------
END SLEEP

View file

@ -0,0 +1,8 @@
# using ping to sleep #
INT milliseconds = read int; # ping uses milliseconds #
print ("Sleeping...");
VOID (system ("ping 0.0.0.1 -n 1 -w " + whole (milliseconds, 0) + " >NUL"));
# 0.0.0.1 is an invalid IP address and cannot be used, so this will never conflict with a real IP address #
# ping -n gives number of tries, -w timeout, and >NUL deletes output so the user does not see it #
print (new line);
print ("Awake!")

View file

@ -0,0 +1,3 @@
say "Sleeping...";
select undef, undef, undef, 0.5;
say "Awake!";

View file

@ -1,6 +1,7 @@
/*REXX program to sleep x seconds (base in the argument). */
/*REXX program sleeps X seconds (the # of seconds supplied by the arg.*/
parse arg secs . /*get a (possible) argument. */
secs=word(secs 0,1) /*if not present, assume 0 (zero)*/
say 'Sleeping' secs "seconds." /*tell 'em what's happening. */
call delay(secs) /*snooze. Hopefully, a short nap*/
call delay secs /*snooze. Hopefully, a short nap*/
say 'Awake!' /*and tell 'em we're running. */
/*stick a fork in it, we're done.*/

View file

@ -0,0 +1,54 @@
/*REXX program delays (or SLEEPS) a number of whole seconds. */
trace off /*suppress REXX error msgs.*/
parse arg ! /*obtain all the arguments.*/
if !all(arg()) then exit /*documentation requested? */
if !cms then address '' /*if CMS, use fast cmd path*/
signal on halt /*handle HALT gracefully.*/
signal on noValue /*handle REXX noValue error*/
signal on syntax /*handle REXX syntax errors*/
/*┌────────────────────────────────────────────────────────────────────┐
The DELAY function is used to delay (wait) a specific amount of
(wall-clock) time specified in seconds. Any fraction part is ignored.
If the REXX program invoking DELAY function is running under PC/REXX
or Personal REXX, this REXX program should never be invoked as those
REXXes have their own built-in function (BIF) named "DELAY".
*/
@cpsleep = 'CP SLEEP' /*point to (CP) SLEEP cmd*/
@ping = 'PING' /*point to the DOS PING cmd*/
parse var ! n _ /*parse argument from parms*/
if _\=='' | arg()>1 then call er 59 /*are there too many args? */
if n=='' then n=1 /*no arg? Then assume 1 sec*/
if \isNum(n) then call er 53,n 'delay-seconds' /*is n numeric? */
n=n%1 /*elide any fractional part*/
if n<=0 then return 0
/* ┌────────────────────┐ */
/* │ delay n seconds. │ */
/* └────────────────────┘ */
select
when !cms then @cpsleep n%1 "SEC" /*CMS? Use CP SLEEP*/
when !tso then call sleep n%1 /*TSO? Use SLEEP*/
when !regina then call sleep n%1 /*Regina? Use SLEEP*/
when !dos then @ping '-n' n "127.0.0.1 > NUL" /*DOS? use PING */
otherwise nop
end /*select*/
return 0 /*return a zero value. */
/*═════════════════════════════general 1-line subroutines═══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════*/
!all: !!=!;!=space(!);upper !;call !fid;!nt=right(!var('OS'),2)=='NT';!cls=word('CLS VMFCLEAR CLRSCREEN',1+!cms+!tso*2);if arg(1)\==1 then return 0;if wordpos(!,'? ?SAMPLES ?AUTHOR ?FLOW')==0 then return 0;!call=']$H';call '$H' !fn !;!call=;return 1
!cal: if symbol('!CALL')\=="VAR" then !call=; return !call
!env: !env='ENVIRONMENT'; if !sys=='MSDOS' | !brexx | !r4 | !roo then !env='SYSTEM'; if !os2 then !env='OS2'!env; !ebcdic=1=='f0'x; if !crx then !env='DOS'; return
!fid: parse upper source !sys !fun !fid . 1 . . !fn !ft !fm .; call !sys; if !dos then do; _=lastpos('\',!fn); !fm=left(!fn,_); !fn=substr(!fn,_+1); parse var !fn !fn '.' !ft; end; return word(0 !fn !ft !fm, 1+('0'arg(1)))
!rex: parse upper version !ver !vernum !verdate .; !brexx='BY'==!vernum; !kexx='KEXX'==!ver; !pcrexx='REXX/PERSONAL'==!ver | 'REXX/PC'==!ver; !r4='REXX-R4'==!ver; !regina='REXX-REGINA'==left(!ver,11); !roo='REXX-ROO'==!ver; call !env; return
!sys: !cms=!sys=='CMS'; !os2=!sys=='OS2'; !tso=!sys=='TSO' | !sys=='MVS'; !vse=!sys=='VSE'; !dos=pos('DOS',!sys)\==0 | pos('WIN',!sys)\==0 | !sys=='CMD'; !crx=left(!sys,6)=='DOSCRX'; call !rex; return
!var: call !fid; if !kexx then return space(dosenv(arg(1))); return space(value(arg(1),,!env))
er: parse arg _1,_2; call '$ERR' "14"p(_1) p(word(_1,2) !fid(1)) _2; if _1<0 then return _1; exit result
p: return word(arg(1),1)
halt: call er .1
isNum: return datatype(arg(1),'N')
noValue: !sigl=sigl; call er 17,!fid(2) !fid(3) !sigl condition('D') sourceline(!sigl)
syntax: !sigl=sigl; call er 13,!fid(2) !fid(3) !sigl !cal() condition('D') sourceline(!sigl)

View file

@ -0,0 +1,4 @@
input "Enter the number of seconds to sleep: ";s
sleep s
print "I'm awake I think..."
input "Press enter to quit";a$

View file

@ -1,9 +1,8 @@
import java.util.Scanner
object Sleeper extends Application {
val input = new Scanner(System.in)
val ms = input.nextInt
System.out.println("Sleeping...")
Thread.sleep(ms)
System.out.println("Awake!")
object Sleeper extends App {
print("Enter sleep time in milli sec: ")
val ms = scala.io.StdIn.readInt()
println("Sleeping...")
val sleepStarted = scala.compat.Platform.currentTime
Thread.sleep(ms)
println(s"Awaked after [${scala.compat.Platform.currentTime - sleepStarted} ms]1")
}