Post Reply 
4K HP 67 Games rom attached for testing
11-12-2016, 02:27 AM
Post: #124
RE: 4K HP 67 Games rom attached for testing
(11-11-2016 07:12 PM)Dieter Wrote:  That's what I also suggested earlier.

Ángel: if implementing a buffer that holds the seed is too complicated, would you say that using R00 with an MCode RNG that does the 9821x+0,211327 thing is a possible option?

Sorry, I must have missed your earlier suggestion. Writing a buffer based solution would be a lot more work, but a version that uses R00 is pretty simple:
Code:
;**********************************************************
; RRAN function
; Takes a seed from R00 and generates the next random number,
; placing the new seed back in R00 and returning it in X.
; Adapted from MCode for Beginners, Ken Emery.
;**********************************************************
.NAME "RRAN"
[RRAN]          C=REG   13/c            ; Get status reg c (contains address of R00)
                RCR     3               ; move into C:X
                RAMSLCT                 ; Select the RAM register of the pointer in C:X
                RDATA                   ; Read the data
                NCXQ    14D8            ; [CHK#S] Checks C for alpha, SETDEC. So C contains seed
                A=0     ALL             ; 
                A<>C    ALL             ; Save seed into A for multiply later
                PT=     12              ; Set the pointer to the first digit of the mantissa
                LC      9               ; Load in bcd rep of 9821
                LC      8
                LC      2
                LC      1
                LDI     003             ; C now contains 9.821E3
                NCXQ    [MP2_10]        ; Multiplies C=C*A
                A=C     ALL             ; Save into A 
                C=0     ALL             
                PT=     12              ; Load C with .211321
                LC      2
                LC      1
                LC      1
                LC      3
                LC      2
                LC      7
                C=C-1   X               ; Load the exponent
                CXQ     [AD2_10]        ; C=C+A (carry is set by the previous line)
                CF      5               ; Use the OS routine as FRC (not INT)
                NCXQ    [INTFRC]        ; C=FRC(C)
                WDATA                   ; Write back the new seed
                A=0     ALL
                A<>C    ALL
                RAMSLCT                 ; select chip 0
                A<>C    ALL
                REG=C   3/X             ; Write it (the random number) to X
                RTN

Might want to add stack lift handling instead of just overwriting X, but that wouldn't take much either. This does take a few more words of ROM (maybe 40 instead of maybe 25, but executes much faster.
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
HP-67 AOS program to debug - Gene - 10-30-2016, 02:11 AM
RE: 4K HP 67 Games rom attached for testing - RobertM - 11-12-2016 02:27 AM



User(s) browsing this thread: 1 Guest(s)