.title p6main ; ; This program is mostly for demonstration purposes - to demonstrate ; the use of your macros. However, it does do something - it makes a ; suggestion on what numbers to play in the Cash 5 Lottery. It also ; creates a formatted display of text and numeric information to ; exercise the formatting macros. ; ; Written by Jim Wolfe (but not useful for anything) ; .library /project:iopack/ cr = 13 lf = 10 .library /macs/ ; These are your macros easyio ; why: .blkb 8 ; A descriptor for a text reason day: .blkb 11 ; To hold the date prompt: .ascii /Who is this for/ ; Prompt for a name plen = . - prompt reason: .ascii /Reason for request: / ; Prompt for a purpose rlen = . - reason crlf: .ascii ; For line spacing spacing: .ascii / / splen = . - spacing discl: .ascid /Disclaimer: Not responsible for outcome./ ; sd: .quad 0 ; Seed for random numbers thirty9: .long 39 ; Maximum Cash 5 number ran: .blkl 1 ; A random number name: .blkb 8 ; Descriptor for person's name group: .blkl 10 ; An array of random numbers five: .long 5 ; Number of random numbers used .show meb .entry start,^m<> getday day ; Get the date cout prompt, #plen ; Ask for an name readnmake #30, name ; Read it in and make a descriptor cout reason, #rlen ; Ask for a purpose readnmake #-50, why ; Read it in and make a descriptor cout crlf, #4 right day, #11 ; Display the date on the right left day, #11 ; and the left center day, #11 ; and the center cout crlf, #2 ; center <"Suggested numbers to play for"> ; Center the title cout crlf, #3 center name ; Center the name cout crlf, #3 cout spacing, #splen ; Spacing for number display ng: clrl r6 top: call random sd, thirty9, ran ; Get a random number addl3 #1, ran, group[r6] ; Put it in the array aoblss five, r6, top call sort group, five ; Sort the numbers clrl r6 moval group, r7 ; Check for duplicate number check: cmpl (r7)+,(r7) beql ng ; If one found, start over aoblss five, r6, check clrl r6 again: showi group[r6], #10 ; Display the random numbers aoblss five, r6, again cout crlf, #3 right discl ; Display disclaimer on right ; left <"Cash 5 Lottery"> ; Display title on left cout crlf, #1 cout crlf, #4 ; cout <"Purpose: "> ; Introduce purpose cout why ; Display purpose $exit_s ; ; ; .psect random ; Procedure to make a random # seed = 4 range = 8 rnum = 12 problem: .ascii /Error in GETTIM/ ; Error message (not expected) .byte 13,10 pblen = . - problem .entry random,^m tstl @seed(ap) ; See if seed is 0 bneq ready $gettim_s timadr=@seed(ap) ; Yes, get system time for seed blbs r0,ready brw error ready: movl @seed(ap), r6 ; Make seed positive bgtr skip mnegl r6, r6 skip: mull3 r6,#1194211693,r7 ; Multiply and add standards addl2 #12345,r7 movl r7,@seed(ap) ; Make result the new seed and bgtr hop ; make sure it is positive mnegl r7,r7 hop: ashl #-10,r7,r7 ; Throw away low order bits divl3 @range(ap),r7,r8 ; Compute remainder to get mull2 @range(ap),r8 ; number in proper range subl3 r8,r7,@rnum(ap) ret error: movab problem, r0 ; Display the crude error msg movl #pblen, r1 jsb writestr ret ; .end start