Add overflow_error

This commit is contained in:
Rikard Nordgren authored and FeralChild64 committed 2026-03-29 21:45:24 +02:00
1 parent a5f32a48e8
commit 9fb88c4348
5 files changed
+36 -3

No files matched your search

+4
View File
@@ -8,7 +8,11 @@
!addr memmove__size = RESHO+2
!addr memmove__tmp = RESHO+4
;
; Error codes
;
err_overflow = $0F
;
; Helper aliases to make the code more readable
+12
View File
@@ -0,0 +1,12 @@
;; #LAYOUT# STD * #TAKE
;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000
;; #LAYOUT# * BASIC_0 #TAKE
;; #LAYOUT# * * #IGNORE
; XXX provide documentation and implementation
error:
+STUB_IMPLEMENTATION
+17
View File
@@ -0,0 +1,17 @@
;; #LAYOUT# STD * #TAKE
;; #LAYOUT# X16 BASIC_0 #TAKE-OFFSET 2000
;; #LAYOUT# * BASIC_0 #TAKE
;; #LAYOUT# * * #IGNORE
; This file is under the MIT license, it contains code released by Microsoft Corporation.
; See LICENSE for more information.
; Math package - overflow error
;
; This is verified to be identical to the original Microsoft implementation where it was named OVERR.
;
overflow_error:
ldx #err_overflow
jmp error
+1 -1
View File
@@ -11,6 +11,6 @@ mul10_FAC1_mul2:
; Increment the exponent
inc FAC1_exponent
+beq set_FAC1_max
+beq overflow_error
rts
+2 -2
View File
@@ -64,7 +64,7 @@ mul_FAC2_FAC1:
sta RESHO+1
@2:
lda RESHO+1
+bne set_FAC1_max ; overflow
+bne overflow_error ; overflow
lda RESHO+0
sta FAC1_exponent
@@ -124,7 +124,7 @@ mul_FAC2_FAC1:
lda FAC1_exponent
clc
adc #$08
+bcs set_FAC1_max ; branch if overflow
+bcs overflow_error ; branch if overflow
sta FAC1_exponent
jmp normal_FAC1