Ethiopian multiplication: Difference between revisions

→‎{{header|MMIX}}: replace program with a version with separate functions 'odd,'halve' & 'double'
(added MMIX example)
(→‎{{header|MMIX}}: replace program with a version with separate functions 'odd,'halve' & 'double')
Line 779:
 
LOC #1000 % locate program at address
GREG @
halve SR pliar,pliar,1
GO $127,$127,0
 
double SL pliand,pliand,1
GO $127,$127,0
 
odd DIV $77,pliar,2
GET $78,rR
GO $127,$127,0
 
% Main is the entry point of the program
Main SET pliar,A % initialize registers for calculation
SET pliand,B
SET acc,0
1H GO $127,odd
1H BZ BEV pliar$78,2F % if pliar is even skip incr. acc with pliand
ADD acc,acc,pliand %
2H SRGO pliar$127,pliar,1halve % halve pliar
SLGO pliand$127,pliand,1double % and double pliand
PBNZ pliar,1B % repeat from 1H while pliar > 0
// result: acc = 17 x 34
Anonymous user