The code for the implementation of a sub-routine to convert positive numeric data from binary to appropriate character string in a PDP−11 like machine has been given below
Note-that SP is the stack pointer and Ri represents ith register respectively.
BTOD :BTOD 1:MOVMOVINCMOVCLRDIVADDMOVBMOVBNEMOVRTS(SP)+,RO(SP)+ , R1R1(SP)+ , R3R210,R248,R3R3,−(R1)R2,R3BTOD 1RO−(SP)PC: Save the PC: address of last significant digit of destination: Setting an auto decrement in eighth instruction: Value to be converted: Pair R2−R3 receive quotient in R2 and remainder in R3: auto decrement will decrease R1: restore PC: return