GATEverse
← GATE CSE 1988

Q9ii

NATMarks unknown

The code for the implementation of a sub-routine to convert positive numeric data from binary to appropriate character string in a PDP−11PDP-11 like machine has been given below Note-that SPSP is the stack pointer and RiR_i represents ithi^{th} register respectively.

BTOD :MOV(SP)+,RO: Save the PCMOV(SP)+ , R1: address of last significant digit of destinationINCR1: Setting an auto decrement in eighth instructionMOV(SP)+ , R3: Value to be convertedBTOD 1:CLRR2DIV10,R2: Pair R2−R3 receive quotient in R2 and remainder in R3ADD48,R3MOVBR3,−(R1): auto decrement will decrease R1MOVR2,R3BNEBTOD 1MOVRO−(SP): restore PCRTSPC: return\begin{array}{ll} \text{BTOD :} & \text{MOV} & \text{$(SP){+} , R_O$} & \text{: Save the PC} \\ & \text{MOV} & \text{$(SP) {+}$ , $R_{1}$} & \text{: address of last significant digit of destination} \\ & \text{INC} & R_{1} & \text{: Setting an auto decrement in eighth instruction} \\ & \text{MOV} & \text{$(SP) {+}$ , $R_{3}$} & \text{: Value to be converted} \\ \text{BTOD 1:} & \text{CLR} & R_{2} & \\ & \text{DIV} & 10,R_{2} & \text{: Pair $R_{2}-R_{3}$ receive quotient in $R_{2}$} \\&& &\text{ and remainder in $R_{3}$} \\ & \text{ADD} & 48,R_{3} \\ & \text{MOVB} & R_{3}, -(R_{1}) & \text{: auto decrement will decrease $R_{1}$} \\ & \text{MOV} & R_{2},R_{3} \\ & \text{BNE} & \text{BTOD 1} & \\ & \text{MOV} & {R_O} - \text{(SP)} & \text{: restore PC} \\ & \text{RTS} & \text{PC} & \text{: return} \end{array}
Sign in to save attempts.

Loading…