.ORIG x3000 ;Program inputs a sequence of unsigned decimal integers ; and displays each input integer at the console. ;Program terminates after displaying an input of 0. LOOP JSR GETDEC ;Input an unsigned decimal integer ST R0, DATA JSR PUTBIN ;Display the input in binary LD R0, NEWLN TRAP x21 LD R0, DATA ;Repeat until 0 BRNP LOOP TRAP x25 ;Halt DATA .BLKW 1 NEWLN .FILL x0A ; =========================================================== GETDEC ;Subroutine to input an unsigned integer in decimal format ;The input is entered at the keyboard ending with LF (x0A) ;The input value is returned in R0 ;Save working registers ST R7, GET7 ;Restore working registers LD R7, GET7 RET GET7 .BLKW 1 ; ============================================================ PUTBIN ;Subroutine to display an unsigned integer in binary format ;The integer to be displayed is passed in register R0 ;Save working registers ST R7, PUT7 ;Restore working registers LD R7, PUT7 RET PUT7 .BLKW 1 .END