home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!paladin.american.edu!gatech!usenet.ins.cwru.edu!agate!ucbvax!tchden.org!lbmoore
- From: lbmoore@tchden.org ("Louis B. Moore")
- Newsgroups: comp.os.vms
- Subject: RE: comp.os.vms.flame, never ending story...
- Message-ID: <00965DB1.3FA57140.6066@tchden.org>
- Date: 30 Dec 92 16:57:16 GMT
- Sender: daemon@ucbvax.BERKELEY.EDU
- Distribution: world
- Organization: The Internet
- Lines: 116
-
-
- >with MOVE, indeed: Carl. He took the time to send me a kind question, just
-
- Nobody pointed out that Carl had politely responded to requests for help
- from Egypt before, again politely, suggesting an interpreter. Carl's flames
- have been much flamed, but Carl's patience has been ignored.
-
- I ignore most posts on INFO-VAX, but usually read those of Arne, Carl,
- and Ehud.
-
- >Oscar.
-
-
- Louis B. Moore Internet: lbmoore@tchden.org
- Systems Programmer Phone: +1 303 837 2513
- The Children's Hospital of Denver Denver, Colorado USA 80218
-
- With thanks to Ehud for the concept, what follows is some actual
- technical content:
-
- ------------------------------------------------------------------
-
- .Title RANDOM_INT
- .Subtitle RANDOM_INT - Program Header
- .Ident 'V1.0-001'
- .Library 'Sys$library:LIB.MLB'
- ;
- .Subtitle RANDOM_INT - Declarations and Equates
- .Page
-
- .Macro SDESC LEN, ADDR ;Fixed
- .WORD LEN
- .BYTE DSC$K_DTYPE_T
- .BYTE DSC$K_CLASS_S
- .ADDRESS ADDR
- .Endm SDESC
-
-
- .Subtitle RANDOM_INT - Read/Write Data
- .Page
- .Psect RANDOM_INT$RW_DATA Pic,Page,Noexe,Rd,Wrt
-
-
- SEED: .BLKQ 1
- MAXINT: .BLKL 1
-
- RANDOM: .BLKL 1
-
-
- RANDOM_DSC: SDESC MAXINT_SIZ,RANDOM_TXT
- RANDOM_TXT: .BLKB 8
- MAXINT_SIZ = . - RANDOM_TXT
-
-
- MAXINT_DSC: SDESC MAXINT_SIZ,MAXINT_TXT
- MAXINT_TXT: .BLKB MAXINT_SIZ
-
- MAXINT_FIXED: .ASCID "99999999"
-
- SYMBOL: .ASCID "RAND_INT"
- LOCAL_SYM: .LONG 1
-
- RND_D_PROMPT: .ASCID "Maximum integer to generate for: "
-
-
-
- .Subtitle RANDOM_INT - Program Code
- .Page
- .Psect RANDOM_INT$code Pic,long,exe,rd,nowrt
-
- ;
-
- .ENTRY RANDOM_INT, ^M<>
-
- INIT: PUSHL #0 ;flag (no prompting)
- PUSHAL (SP) ;Address of flags
- PUSHAW MAXINT_DSC ;resultant length
- PUSHAQ RND_D_PROMPT ;prompt string
- PUSHAQ MAXINT_DSC ;result string
- CALLS #4,G^LIB$GET_FOREIGN ;get data
- ADDL2 #4,SP ;fix SP
- BLBS R0,10$ ;Ok? Yes, branch
- MOVQ MAXINT_FIXED,MAXINT_DSC ; No, put in our own value
- 10$: PUSHL #4 ;Size of output
- PUSHAL MAXINT ; Location of output
- PUSHAQ MAXINT_DSC ; source text
- CALLS #3,G^OTS$CVT_TU_L ; convert
- 20$: BLBC R0,30$ ; error
- $GETTIM_S TIMADR=SEED ;Get Time to use as seed
- BLBS R0,40$ ;Branch if OK.
- 30$: PUSHL R0 ;Error
- CALLS #1,G^LIB$STOP ;If not
- 40$: PUSHAL SEED ;Address of Seed
- CALLS #1,G^MTH$RANDOM ;get a random number F_Float
- CVTLF MAXINT,R1 ;Convert Max Integer to F_Float
- MULF2 R1,R0 ;Multiply Max int time random
- CVTFL R0,RANDOM ;Convert back to integer
-
- PUSHL #MAXINT_SIZ ;MAXINT_SIZ digits
- PUSHAQ RANDOM_DSC ;For text version of RANDOM
- PUSHAL RANDOM ;Binary version
- CALLS #3,G^OTS$CVT_L_TU ;Convert
- 50$: BLBC R0,30$ ;Yuck!
- PUSHAL LOCAL_SYM ;Local Symbol Table
- PUSHAQ RANDOM_DSC ;Value
- PUSHAQ SYMBOL ;Symbol
- CALLS #3,G^LIB$SET_SYMBOL ;Do it
- BLBC R0,50$ ;mumble
-
- EXIT: MOVL #SS$_NORMAL,R0
- $EXIT_S R0
-
- .END RANDOM_INT
-
-
-
-