0011 0000 0000 0000 ; program starts at location x3000 0010 001 100000000 ; load bit pattern to left rotate 0010 010 100000001 ; load number of times to rotate 0000 010 000001011 ; branch to done if count is 0 0101 011 011 1 00000 ; clear r3 0001 001 001 1 00000 ; set condition code based on value in r1 0000 011 000000111 ; branch if positive or zero 0001 011 011 1 00001 ; most significant bit is 1 0001 001 001 000 001 ; left shift by one 0001 001 001 000 011 ; add back in shifted out bit 0001 010 010 1 11111 ; decrement count 0000 111 000000010 ; branch to top of loop 0011 001 100000010 ; store shifted result 1111 0000 00100101 ; halt the simulator ; --------------------------------------- ; | load bit pattern to left rotate | ; | load number of times to left rotate | ; --------------------------------------- ; | ; -------------------------->| ; | V ; | / \ ; | / \ ; | / test \ yes ; | < for >-------------------- ; | \ zero / | ; | \ / | ; | \ / | ; | |no | ; | | | ; | V | ; | ------------------------------------------- | ; | | clear r3 | | ; | | set condition code based on value in r1 | | ; | ------------------------------------------- | ; | | | ; | | | ; | V | ; | / \ | ; | / \ | ; | / test for\ yes | ; | < zero or >------------ | ; | \ positive/ | | ; | \ / | | ; | \ / | | ; | |no | | ; | | | | ; | V | | ; | ----------------------------- | | ; | | most significant bit is 1 | | | ; | ----------------------------- | | ; | | | | ; | |<----------------- | ; | | | ; | ---------------------------- | ; | | left shift by one | | ; | | add back shifted out bit | | ; | | decrement count | | ; | ---------------------------- | ; | | | ; ---------------------------- | ; | ; --------------------------- ; | ; V ; ------------------------ ; | store shifted result | ; | stop the simulator | ; ------------------------ ; | ; V