Ethiopian multiplication: Difference between revisions
Content added Content deleted
(→{{header|AutoIt}}: support for negative parameters) |
|||
Line 2,275: | Line 2,275: | ||
1BDC:010E 90 NOP |
1BDC:010E 90 NOP |
||
1BDC:010F 90 NOP |
1BDC:010F 90 NOP |
||
;mulitplication routine |
;mulitplication routine starts here |
||
1BDC:0110 89E5 MOV BP,SP ; prepare to get operands off stack |
1BDC:0110 89E5 MOV BP,SP ; prepare to get operands off stack |
||
1BDC:0112 8B4E02 MOV CX,[BP+02] ; Get the first operand |
1BDC:0112 8B4E02 MOV CX,[BP+02] ; Get the first operand |
||
Line 2,283: | Line 2,283: | ||
1BDC:011E 7402 JZ 0122 ; no skip the next instruction |
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:0120 01D8 ADD AX,BX ; we are odd so add to the result |
||
1BDC:0122 |
1BDC:0122 D1E3 SHL BX,1 ; multiply by 2 |
||
1BDC:0124 |
1BDC:0124 D1E9 SHR CX,1 ; divide by 2 (if zr flag is set, we are done) |
||
1BDC:0126 |
1BDC:0126 75F2 JNZ 011A ; cx not 0, go back and do it again |
||
1BDC: |
1BDC:0128 C3 RET ; return with the result in AX |
||
1BDC:012B 01D8 ADD AX,BX ; final add |
|||
1BDC:012D C3 RET ; return with the result in AX |
|||
;pretty small</lang> |
;pretty small, just 24 bytes </lang> |