asm.s

来自「this is the MONTGOMERY INV routine for t」· S 代码 · 共 66 行

S
66
字号
        NAME    main
        
        PUBLIC  __iar_program_start
        
        SECTION .intvec : CODE (2)
        CODE32
        
__iar_program_start
        B       main

        PUBLIC  __iar_zero_init
        PUBLIC  __iar_copy_init
        
        EXTERN  acl_p_mont_inv
        SECTION .text : CODE (2)
        CODE32
        
#define         res     r0      
#define         aa      r1      
#define         mm      r2      
#define         tt      r3      
#define         temp    r4      

// int acl_p_mont_inv(vect res, vect a, vect m, vect3 tmp, size_t len);
//   res = +- (a^-1) * (2^k) mod m     (m must be odd)
//   returns 0 if a is non-invertible, +- k otherwise
//   a != 0  and  a != 1
// on entry:
//   r0 = pointer to result
//   r1 = pointer to a
//   r2 = pointer to m
//   r3 = pointer to temporary array (size: 3*len ints)
//   [sp] = length of input/output arrays in 32-bit words

main   
        ldr     res,= result_buf
        ldr     aa,= source1_buf
        ldr     mm,= source2_buf
        ldr     tt,= temp_buf

        ldr     temp,= 3
        str      temp, [aa]
     
        ldr     temp,= 37
        str      temp, [mm]

        ldr     temp,= 1
        str      temp, [sp]

        BL      acl_p_mont_inv

        B       main

__iar_zero_init:
__iar_copy_init:

        SECTION .data : DATA (2)
        DATA

result_buf    DS32    64
source1_buf   DS32    64
source2_buf   DS32    64
temp_buf      DS32    64
        
        END

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?