]> git.sur5r.net Git - cc65/commitdiff
Protect random counter against ProDOS.
authorOliver Schmidt <ol.sc@web.de>
Sat, 8 Sep 2018 21:29:59 +0000 (23:29 +0200)
committerOliver Schmidt <ol.sc@web.de>
Sat, 8 Sep 2018 21:29:59 +0000 (23:29 +0200)
Although documented nowhere (!!!) ProDOS trashes the random counter locations $4E/$4F. Is discovered this because my TCP connections didn't have random local ports.

It's a really funny coincidence that David Finnigan discovered only 3 years ago the very same issue because of the very same reason: https://groups.google.com/forum/#!topic/comp.sys.apple2.programmer/1ciep_Oetvo

libsrc/apple2/mli.s

index 3e4771400fd5eac939f262b3f46be7dbab063e2e..891cbaa6bf8c1324f76f4d205f1fb0d10817c458 100644 (file)
@@ -6,6 +6,7 @@
 
         .import         __dos_type
 
+        .include        "apple2.inc"
         .include        "mli.inc"
 
         .bss
@@ -23,10 +24,24 @@ callmli:
         lda     __dos_type
         beq     oserr
 
-        ; Call MLI and return
+        ; Save random counter
+        lda     RNDL
+        pha
+        lda     RNDH
+        pha
+
+        ; Call MLI
         jsr     $BF00           ; MLI call entry point
 call:   .byte   $00
         .addr   mliparam
+
+        ; Restore random counter and return
+        tax
+        pla
+        sta     RNDH
+        pla
+        sta     RNDL
+        txa
         rts
 
         ; Load oserror code and return