Jump to content

Ethiopian multiplication: Difference between revisions

(→‎{{header|AutoIt}}: support for negative parameters)
Line 2,275:
1BDC:010E 90 NOP
1BDC:010F 90 NOP
;mulitplication routine starts here
1BDC:0110 89E5 MOV BP,SP ; prepare to get operands off stack
1BDC:0112 8B4E02 MOV CX,[BP+02] ; Get the first operand
Line 2,283:
1BDC:011E 7402 JZ 0122 ; no skip the next instruction
1BDC:0120 01D8 ADD AX,BX ; we are odd so add to the result
1BDC:0122 D1E9D1E3 SHRSHL CXBX,1 ; dividemultiply by 2
1BDC:0124 D1E3D1E9 SHLSHR BXCX,1 ; multiplydivide by 2 (if zr flag is set, we are done)
1BDC:0126 83F90175F2 CMP JNZ 011A CX,+01 ; arecx not 0, go back and wedo doneit (==1)again
1BDC:01290128 75EFC3 JNZ RET 011A ; no, go back and do it; return with the result in againAX
1BDC:012B 01D8 ADD AX,BX ; final add
1BDC:012D C3 RET ; return with the result in AX
 
;pretty small, just 24 bytes </lang>
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.