Looking at a comment on this question, it reminded me of how there are two memory locations in the Apple II zero page that are used for random number generation: 0x4E and 0x4F (78 and 79, respectively).

How are the values in this field maintained so that it is always able to help produce a somewhat useful random number seed? Is it ticked or mathematically changed as part of an GETCH / keyboard input call, or is it manipulated during some other blocking call?

  • 2
    Remember that RND is basically broken. Bob Sander-Cederlof created a replacement that can be called from Basic linked in my answer here. See Fadden's answer (and my comment) to understand why RND is broken. Commented Jan 13, 2023 at 1:01
  • @NickWestgate: those answers appear to be talking about Applesoft's RND function, which is completely independent of the ROM RNDL/RNDH values.
    – Chris Dodd
    Commented Feb 12 at 10:33

1 Answer 1


It's incremented while waiting for keyboard input.

The 16-bit random seed (RNDL and RNDH) is updated by the KEYIN routine as it spins while waiting for a key press. KEYIN is used by the Monitor ROM's keyboard input routines like GETLN and RDKEY.

Apple II+ Monitor ROM Listing:

fd1b: e6 4e        KEYIN       inc     RNDL
fd1d: d0 02                    bne     KEYIN2          ;incr rnd number
fd1f: e6 4f                    inc     RNDH
fd21: 2c 00 c0     KEYIN2      bit     IOADR           ;key down?
fd24: 10 f5                    bpl     KEYIN           ;  loop
fd26: 91 28                    sta     (BASL),y        ;replace flashing screen
fd28: ad 00 c0                 lda     IOADR           ;get keycode
fd2b: 2c 10 c0                 bit     KBDSTRB         ;clr key strobe
fd2e: 60                       rts
  • 1
    Great first answer. Welcome to the site! Commented Jan 13, 2023 at 2:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .