The Gateway to Computer Science Excellence
+1 vote
117 views
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}$$
in CO and Architecture by Veteran (105k points)
edited by | 117 views

Please log in or register to answer this question.

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,648 questions
56,460 answers
195,340 comments
100,198 users