# INITIALISE VARIABLES SET REGA 4 SET REGB 610 SET REGC 0 # JUMP TO END IF A == 0 SET REGX REGA JMP 28 # ELSE, HALVE A SHR REGA 1 # DOUBLE B SHL REGB 1 # CHECK IF A IS ODD SET REGX REGA AND REGX 1 # IF IT'S EVEN, CHECK IF A == 1 JMP 20 # ELSE, ADD B TO THE RESULT ADD REGC REGB # CHECK IF A == 1 SET REGX REGA # JMP JUMPS ON A 0, NOT A 1 SUB REGX 1 # IF IT IS, JUMP TO THE END OF THE LOOP JMP 28 # ELSE, JUMP TO THE BEGINNING OF THE LOOP SET REGX 0 JMP 8 # PRINTS THE RESULT PRT REGC # EXITS THE PROGRAM NOP