mirror of
https://github.com/dschmenk/PLASMA.git
synced 2025-02-02 16:34:26 +00:00
Consistent SANE API naming
This commit is contained in:
parent
b6d7986249
commit
35da78ce92
@ -138,8 +138,8 @@ def str2ext(str, ext)
|
||||
decrec.sig.1 = '0'
|
||||
fin
|
||||
//putc(decrec.sgn ?? '-' :: '+'); puts(@decrec.sig); putc('e'); puti(decrec:exp); putln
|
||||
sane:zpSave()
|
||||
return sane:zpRestore(sane:fpOp2(FFEXT|FOD2B, ext, @decrec))
|
||||
sane:saveZP()
|
||||
return sane:restoreZP(sane:op2FP(FFEXT|FOD2B, ext, @decrec))
|
||||
end
|
||||
def ext2str(ext, str, intdigits, fracdigits, format)
|
||||
byte d, i, sigdigits, numdigits
|
||||
@ -150,8 +150,8 @@ def ext2str(ext, str, intdigits, fracdigits, format)
|
||||
numdigits = intdigits + fracdigits
|
||||
decform:style = format & $01
|
||||
decform:digits = decform:style ?? fracdigits :: numdigits
|
||||
sane:zpSave()
|
||||
sane:zpRestore(sane:fpOp3(FFEXT|FOB2D, @decrec, ext, @decform))
|
||||
sane:saveZP()
|
||||
sane:restoreZP(sane:op3FP(FFEXT|FOB2D, @decrec, ext, @decform))
|
||||
^(str+1) = decrec.sgn ?? '-' :: ' '
|
||||
if decrec.sig.1 == 'I'
|
||||
^(str+2) = 'I'
|
||||
@ -269,9 +269,9 @@ def divstri(strNum, denom, format)#0
|
||||
// Convert string to and from SANE
|
||||
//
|
||||
str2ext(strNum, @xResult)
|
||||
sane:zpSave()
|
||||
sane:fpOp2(FFINT|FODIV, @xResult, @denom) // Div int denom into ext Result
|
||||
sane:zpRestore(0)
|
||||
sane:saveZP()
|
||||
sane:op2FP(FFINT|FODIV, @xResult, @denom) // Div int denom into ext Result
|
||||
sane:restoreZP(0)
|
||||
ext2str(@xResult, @strResult, 6, 4, format)//format & $05 ?? 1 :: 6, 4, format)
|
||||
puts(strNum); putc('/'); puti(denom); putc('='); puts(@strResult); putln
|
||||
end
|
||||
@ -279,7 +279,7 @@ end
|
||||
// My custom SANE exception handler
|
||||
//
|
||||
def myException(pstatus)
|
||||
sane:zpRestore(0)
|
||||
sane:restoreZP(0)
|
||||
puts("Floating point exception:")
|
||||
if pstatus->8 & FBINVALID; puts(" INVALID"); fin
|
||||
if pstatus->8 & FBUFLOW; puts(" UNDERFLOW"); fin
|
||||
@ -287,7 +287,7 @@ def myException(pstatus)
|
||||
if pstatus->8 & FBDIVZER; puts(" DIV_BY_ZERO"); fin
|
||||
if pstatus->8 & FBINEXACT; puts(" INEXACT"); fin
|
||||
putln
|
||||
sane:zpSave()
|
||||
sane:saveZP()
|
||||
return pstatus=>4
|
||||
end
|
||||
|
||||
@ -297,40 +297,40 @@ iB = 4
|
||||
iC = -1
|
||||
zero = 0
|
||||
puts("SANE sanity test...\n")
|
||||
sane.fpInit()
|
||||
sane:zpSave()
|
||||
sane:fpOp2(FFINT|FOZ2X, @xT, @iA) // Convert int A to ext T
|
||||
sane:fpOp2(FFINT|FOADD, @xT, @iB) // Add int B to ext T
|
||||
sane:fpOp2(FFINT|FOX2Z, @iC, @xT) // Convert ext T to int C
|
||||
sane:zpRestore(0)
|
||||
sane.initFP()
|
||||
sane:saveZP()
|
||||
sane:op2FP(FFINT|FOZ2X, @xT, @iA) // Convert int A to ext T
|
||||
sane:op2FP(FFINT|FOADD, @xT, @iB) // Add int B to ext T
|
||||
sane:op2FP(FFINT|FOX2Z, @iC, @xT) // Convert ext T to int C
|
||||
sane:restoreZP(0)
|
||||
puti(iA); putc('+'); puti(iB); putc('='); puti(iC); putc('\n')
|
||||
sane:zpSave()
|
||||
sane:fpOp2(FFINT|FOZ2X, @xT, @iA) // Convert int A to ext T
|
||||
sane:fpOp2(FFINT|FOSUB, @xT, @iB) // Sub int B from ext T
|
||||
sane:fpOp2(FFINT|FOX2Z, @iC, @xT) // Convert ext T to int C
|
||||
sane:zpRestore(0)
|
||||
sane:saveZP()
|
||||
sane:op2FP(FFINT|FOZ2X, @xT, @iA) // Convert int A to ext T
|
||||
sane:op2FP(FFINT|FOSUB, @xT, @iB) // Sub int B from ext T
|
||||
sane:op2FP(FFINT|FOX2Z, @iC, @xT) // Convert ext T to int C
|
||||
sane:restoreZP(0)
|
||||
puti(iA); putc('-'); puti(iB); putc('='); puti(iC); putc('\n')
|
||||
sane:zpSave()
|
||||
sane:fpOp2(FFINT|FOZ2X, @xT, @iA) // Convert int A to ext T
|
||||
sane:fpOp2(FFINT|FOMUL, @xT, @iB) // Mul int B by ext T
|
||||
sane:fpOp2(FFINT|FOX2Z, @iC, @xT) // Convert ext T to int C
|
||||
sane:zpRestore(0)
|
||||
sane:saveZP()
|
||||
sane:op2FP(FFINT|FOZ2X, @xT, @iA) // Convert int A to ext T
|
||||
sane:op2FP(FFINT|FOMUL, @xT, @iB) // Mul int B by ext T
|
||||
sane:op2FP(FFINT|FOX2Z, @iC, @xT) // Convert ext T to int C
|
||||
sane:restoreZP(0)
|
||||
puti(iA); putc('*'); puti(iB); putc('='); puti(iC); putc('\n')
|
||||
sane:zpSave()
|
||||
sane:fpOp2(FFINT|FOZ2X, @xT, @iA) // Convert int A to ext T
|
||||
sane:fpOp2(FFINT|FODIV, @xT, @iB) // Div int B into ext T
|
||||
sane:fpOp2(FFINT|FOX2Z, @iC, @xT) // Convert ext T to int C
|
||||
sane:zpRestore(0)
|
||||
sane:saveZP()
|
||||
sane:op2FP(FFINT|FOZ2X, @xT, @iA) // Convert int A to ext T
|
||||
sane:op2FP(FFINT|FODIV, @xT, @iB) // Div int B into ext T
|
||||
sane:op2FP(FFINT|FOX2Z, @iC, @xT) // Convert ext T to int C
|
||||
sane:restoreZP(0)
|
||||
puti(iA); putc('/'); puti(iB); putc('='); puti(iC); putc('\n')
|
||||
//
|
||||
// Hook custom HALT exception handler and divide by zero :-)
|
||||
// Enable all exceptions
|
||||
//
|
||||
sane:zpSave()
|
||||
sane:fpHalt = @myException
|
||||
fpEnv = sane:fpOp0(FOGETENV)
|
||||
sane:fpOp1(FOSETENV, fpEnv | FBINVALID | FBUFLOW | FBOFLOW | FBDIVZER | FBINEXACT)
|
||||
sane:zpRestore(0)
|
||||
sane:saveZP()
|
||||
sane:haltFP = @myException
|
||||
fpEnv = sane:op0FP(FOGETENV)
|
||||
sane:op1FP(FOSETENV, fpEnv | FBINVALID | FBUFLOW | FBOFLOW | FBDIVZER | FBINEXACT)
|
||||
sane:restoreZP(0)
|
||||
//
|
||||
// String conversion tests
|
||||
//
|
||||
|
Loading…
x
Reference in New Issue
Block a user