URL
https://opencores.org/ocsvn/zipcpu/zipcpu/trunk
Subversion Repositories zipcpu
[/] [zipcpu/] [trunk/] [sw/] [lib/] [mpy32s.S] - Rev 57
Go to most recent revision | Compare with Previous | Blame | View Log
; We could build mul32s (32-bit signed multiply) asmpy32s:PUSH R2CLR R2 ; Keep track of resulting sign in R2TST R0 ; Is R0 negative?XOR.LT #1,R2 ; If so, resulting sign will be negative, andNEG.NZ R0 ; then we negate R0 (R0 = ABS(R0))TST R1 ; Is R1 negative?XOR.LT #1,R2 ; If so, result will be opposite sign of beforeTST R1 ; Need to retest since xor modified flagsNEG.LT R1 ; Now we get R1=ABS(R1)JSR mpy32u ; Do our unsigned multiplyCMP R2 ; Check resulting signBZ ret_mul32s ; If positive, do nothing moreNOT R0 ; If negative, negate the resultNOT R1ADD $1,R1ADD.C $1,R0ret_mul32s:POP R2RET
Go to most recent revision | Compare with Previous | Blame | View Log
