mirror of
https://github.com/dschmenk/PLASMA.git
synced 2025-03-20 03:31:27 +00:00
Add elems functions to rpncalc
This commit is contained in:
parent
d87df9433d
commit
96d94816bb
src
@ -51,6 +51,9 @@ struc t_fpu
|
||||
word round
|
||||
word sqrt
|
||||
word square
|
||||
word cos
|
||||
word sin
|
||||
word tan
|
||||
end
|
||||
word fpu
|
||||
end
|
||||
|
@ -15,6 +15,7 @@ predef storInt, storSgl, storDbl, storExt, storStr
|
||||
predef shiftUp, shiftDown, rotateUp, rotateDown, dup, swap, clear
|
||||
predef add, sub, mul, div, rem
|
||||
predef neg, abs, trunc, round, sqrt, square
|
||||
predef cos, sin, tan
|
||||
export word fpu = @reset, @constPi, @constE
|
||||
word = @pushInt, @pushSgl, @pushDbl, @pushExt, @pushStr
|
||||
word = @pullInt, @pullSgl, @pullDbl, @pullExt, @pullStr
|
||||
@ -23,6 +24,7 @@ word = @storInt, @storSgl, @storDbl, @storExt, @storStr
|
||||
word = @shiftUp, @shiftDown, @rotateUp, @rotateDown, @dup, @swap, @clear
|
||||
word = @add, @sub, @mul, @div, @rem
|
||||
word = @neg, @abs, @trunc, @round, @sqrt, @square
|
||||
word = @cos, @sin, @tan
|
||||
//
|
||||
// Useful constants
|
||||
//
|
||||
@ -237,7 +239,25 @@ end
|
||||
def square
|
||||
sane:zpSave()
|
||||
sane:fpOp2(FFEXT|FOMUL, stackRegs[0], stackRegs[0])
|
||||
sane:zpRestore()
|
||||
return sane:zpRestore()
|
||||
end
|
||||
//
|
||||
// Elems operations
|
||||
//
|
||||
def cos
|
||||
sane:zpSave()
|
||||
sane:elOp1(FFEXT|FOCOSX, stackRegs[0])
|
||||
return sane:zpRestore()
|
||||
end
|
||||
def sin
|
||||
sane:zpSave()
|
||||
sane:elOp1(FFEXT|FOSINX, stackRegs[0])
|
||||
return sane:zpRestore()
|
||||
end
|
||||
def tan
|
||||
sane:zpSave()
|
||||
sane:elOp1(FFEXT|FOTANX, stackRegs[0])
|
||||
return sane:zpRestore()
|
||||
end
|
||||
//
|
||||
// Push useful constants
|
||||
|
@ -25,7 +25,7 @@ end
|
||||
predef delKey#0, cmdKey#0, dropKey#0
|
||||
predef digitKey#0, pointKey#0, opKey#0
|
||||
predef enterKey#0, chsKey#0, memKey#0
|
||||
predef sqrtKey#0, absKey#0
|
||||
predef elemsKey#0
|
||||
//
|
||||
// Current input
|
||||
//
|
||||
@ -89,6 +89,12 @@ byte[t_keypad] = 'R', 3, 20, "[SQ(R)]"
|
||||
word = @opKey
|
||||
byte[t_keypad] = '^', 11, 20, "[X(^)2]"
|
||||
word = @opKey
|
||||
byte[t_keypad] = 'C', 22, 14, "[(C)OS]"
|
||||
word = @elemsKey
|
||||
byte[t_keypad] = 'S', 30, 14, "[(S)IN]"
|
||||
word = @elemsKey
|
||||
byte[t_keypad] = 'T', 22, 16, "[(T)AN]"
|
||||
word = @elemsKey
|
||||
byte = 0
|
||||
//
|
||||
// Utility routines
|
||||
@ -330,6 +336,21 @@ def memKey(pkey)#0
|
||||
fin
|
||||
fin
|
||||
end
|
||||
def elemsKey(pkey)#0
|
||||
updateInput
|
||||
when ^pkey
|
||||
is 'C'
|
||||
fpu:cos()
|
||||
break
|
||||
is 'S'
|
||||
fpu:sin()
|
||||
break
|
||||
is 'T'
|
||||
fpu:tan()
|
||||
break
|
||||
wend
|
||||
showStack
|
||||
end
|
||||
//
|
||||
// Command line handler
|
||||
//
|
||||
|
Loading…
x
Reference in New Issue
Block a user