I have the outlined definitions of 2 Plugins, 1 for
RSErasurePlugin and 1 for RSFECPlugin. They are published to
Cryptography. I am trying to understand how to write primitives to
get the work done. Any and All assistance MOST WELCOME! Let's get
her done!
I believe I have properly implemented the #declareCVarsIn: and initialized for both plugins.
I am looking at a primitive implementation in RSFECPlugin>>#primitiveInverseWithSize. A few questions: am I grabbing the stack arguments correctly? Testing their values correctly? Correctly calling a method to do the work. Manipulating the stack to setup a return value???
I am doing this...correct?
self pop: 2 thenPushInteger: multiplied.
^interpreterProxy methodReturnInteger: multiplied.
---
primitiveInverseWithSize
<export: true>
<var: 'a' declareC: 'unsigned short' >
<var: 'size' declareC: 'unsigned short' >
| a size multiplied |
interpreterProxy methodArgumentCount = 2
ifFalse: [ ^interpreterProxy primitiveFailFor: PrimErrBadNumArgs ].
a := interpreterProxy stackIntegerValue: 0.
size := interpreterProxy stackIntegerValue: 1.
((interpreterProxy isBytes: a)
and: [ (interpreterProxy stSizeOf: a) = 2 ])
ifFalse: [ ^interpreterProxy primitiveFailFor: PrimErrBadArgument ].
((interpreterProxy isBytes: size)
and: [ (interpreterProxy stSizeOf: a) = 2 ])
ifFalse: [ ^interpreterProxy primitiveFailFor: PrimErrBadArgument ].
multiplied := self inverse: a withSize: size.
self pop: 2 thenPushInteger: multiplied.
^interpreterProxy methodReturnInteger: multiplied.
And:
inverse: a withSize: size
(a = 0)
ifTrue: [RSErasureIllegalArgumentError signal: 'the argument is zero'].
^ expTable at: (size - ((logTable at: (a + 1)) - 1)).