// Interface
typedef struct{
+
+ N32路T *(*allocate_array_zero)(Extent, N32路Allocate_MemoryFault);
N32路T *(*allocate_array)(Extent, N32路Allocate_MemoryFault);
void (*deallocate)(N32路T*);
+
void (*copy)(N32路T*, N32路T*);
void (*bit_and)(N32路T*, N32路T*, N32路T*);
void (*bit_or)(N32路T*, N32路T*, N32路T*);
bool (*gt)(N32路T*, N32路T*);
bool (*eq)(N32路T*, N32路T*);
bool (*eq_zero)(N32路T*);
+ N32路Status (*accumulate)(N32路T *accumulator1 ,N32路T *accumulator0 ,...);
N32路Status (*add)(N32路T*, N32路T*, N32路T*);
+ bool (*increment)(N32路T *a);
N32路Status (*subtract)(N32路T*, N32路T*, N32路T*);
N32路Status (*multiply)(N32路T*, N32路T*, N32路T*, N32路T*);
N32路Status (*divide)(N32路T*, N32路T*, N32路T*, N32路T*);
N32路Status (*shift_left)(Extent, N32路T*, N32路T*, N32路T*);
N32路Status (*shift_right)(Extent, N32路T*, N32路T*, N32路T*);
N32路Status (*arithmetic_shift_right)(Extent, N32路T*, N32路T*);
+
N32路T* (*access)(N32路T*, Extent);
void (*from_uint32)(N32路T *destination ,uint32_t value);
} N32路螞;
-extern const N32路螞 N32路位;
+Local const N32路螞 N32路位; // initialized in the LOCAL section
#endif
N32路T *N32路lsb = &N32路constant[1];
// the allocate an array of N32
-N32路T *N32路allocate_array( Extent extent ,N32路T *(*memory_fault)(Extent) ){
+N32路T *N32路allocate_array(Extent extent ,N32路Allocate_MemoryFault memory_fault){
N32路T *instance = malloc((extent + 1) * sizeof(N32路T) );
if(!instance){
return memory_fault ? memory_fault(extent) : NULL;
return instance;
}
-N32路T *N32路alloc_array_zero( Extent extent ,N32路T *(*memory_fault)(Extent) ){
+N32路T *N32路allocate_array_zero(Extent extent ,N32路Allocate_MemoryFault memory_fault){
N32路T *instance = calloc( extent + 1 ,sizeof(N32路T) );
if(!instance){
return memory_fault ? memory_fault(extent) : NULL;
// allocating a block once is more efficient
// library code writes these, they are not on the interface
-Local N32路T N32路t[4]
+Local N32路T N32路t[4];
// allocation
va_list args;
va_start(args ,accumulator0);
-
- uint64_t *sum = &accumulator0->d0;
- uint64_t *carry = 0;
+ uint32_t sum = accumulator0->d0;
+ uint32_t carry = 0;
N32路T *current;
while( (current = va_arg(args ,N32路T *)) ){
- *sum += current->d0;
- if(*sum < current->d0){ // Accumulator1 into carry
- (*carry)++;
- if(*carry == 0){
+ sum += current->d0;
+ if(sum < current->d0){ // Accumulator1 into carry
+ (carry)++;
+ if(carry == 0){
va_end(args);
return N32路Status路accumulator1_overflow;
}
product0->d0 = (uint32_t)product;
product1->d0 = (uint32_t)(product >> 32);
- if(product1->d0 == 0) return N32路status路one_word_product;
+ if(product1->d0 == 0) return N32路Status路one_word_product;
return N32路Status路two_word_product;
}
return N32路shift_right(shift_count, spill, operand, fill);
}
-// an interface instance
-
Local const N32路螞 N32路位 = {
- .copy = N32路copy
+
+ .allocate_array = N32路allocate_array
+ ,.allocate_array_zero = N32路alloc_array_zero
+ ,.deallocate = N32路deallocate
+
+ ,.copy = N32路copy
,.bit_and = N32路bit_and
,.bit_or = N32路bit_or
,.bit_complement = N32路bit_complement
,.gt = N32路gt
,.eq = N32路eq
,.eq_zero = N32路eq_zero
- ,.eq_one = N32路eq_one
,.accumulate = N32路accumulate
,.add = N32路add
- ,.next = N32路next
+ ,.increment = N32路increment
,.subtract = N32路subtract
,.multiply = N32路multiply
,.divide = N32路divide
,.shift_left = N32路shift_left
,.shift_right = N32路shift_right
,.arithmetic_shift_right = N32路arithmetic_shift_right
- ,.allocate_array = N32路allocate_array
- ,.allocate_array_zero = N32路alloc_array_zero
- ,.deallocate = N32路deallocate
+
,.access = N32路access
,.from_uint32 = N32路from_uint32
};