added full protection against illegal IEC device numbers

This commit is contained in:
FeralChild64 committed 2019-07-20 16:30:58 +02:00
1 parent f26431b502
commit 2613553ef3
5 files changed
+49 -2

No files matched your search

+24
View File
@@ -0,0 +1,24 @@
;;
;; Checks whether device numbe (in .A) is a correct IEC device number
;;
;; Preserves .A, .X and .Y
;;
iec_devnum_check:
;; 0, 1, 2, or 3 are illegal - reserved for non-IEC devices on Commodore
cmp #$03
bpl +
bcs +
;; FALLTROUGH
iec_devnum_check_failed:
sec
rts
*
;; 30 and above are illegal too, due to IEC command encoding scheme,
;; see https://www.pagetable.com/?p=1031
cmp #$1E
bpl iec_devnum_check_failed
bcs iec_devnum_check_failed
clc
rts