Add overflow_error
This commit is contained in:
1 parent
a5f32a48e8
commit
9fb88c4348
5 files changed
+36
-3
No files matched your search
@@ -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
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
@@ -11,6 +11,6 @@ mul10_FAC1_mul2:
|
||||
; Increment the exponent
|
||||
|
||||
inc FAC1_exponent
|
||||
+beq set_FAC1_max
|
||||
+beq overflow_error
|
||||
|
||||
rts
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in new issue
Block a user