recategorized by
491 views
1 votes
1 votes
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 $R_i$ represents $i^{th}$ register respectively.$$\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}$$
recategorized by

Please log in or register to answer this question.

Related questions

2 votes
2 votes
0 answers
3
go_editor asked Dec 18, 2016
663 views
A modern day machine typically has an atomic TEST AND SET instruction. Why?
12 votes
12 votes
1 answer
4
go_editor asked Dec 19, 2016
3,503 views
In the program scheme given below indicate the instructions containing any operand needing relocation for position independent behaviour. Justify your answer.$$\begin{arr...