<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    I thought I would close the loop with a recipe that works for doing
    bare metal work:<br>
    <br>
    First, the revised "program":<br>
    <tt>    .title getc</tt><tt><br>
    </tt><tt><br>
    </tt><tt>TKS = 177560</tt><tt><br>
    </tt><tt>TKB = 177562</tt><tt><br>
    </tt><tt>;TPS = 177564</tt><tt><br>
    </tt><tt>;TPB = 177566</tt><tt><br>
    </tt><tt><br>
    </tt><tt>begin:</tt><tt><br>
    </tt><tt>    inc    TKS        ;set the ASR to input</tt><tt><br>
    </tt><tt>getc:</tt><tt><br>
    </tt><tt>    tstb    TKS        ;is a character available on the
      ASR?</tt><tt><br>
    </tt><tt>    bpl    getc        ;loop until there is</tt><tt><br>
    </tt><tt><br>
    </tt><tt>    movb    TKB,R0        ;put the character into register
      0</tt><tt><br>
    </tt><tt><br>
    </tt><tt>    halt</tt><tt><br>
    </tt><tt><br>
    </tt><tt>    .end begin</tt><tt><br>
    </tt><tt></tt><br>
    In RT-11, edit and save the program:<br>
    <tt>.edit/create vol:getc.mac</tt><br>
    <br>
    Compile it:<br>
    <tt>.r macro</tt><tt><br>
    </tt><tt>*VOL:getc,VOL:getc/L:TTM/C:C:E:M:P:R:S=VOL:getc.mac</tt><br>
    <br>
    Type the listing if you like:<br>
    <tt>.type vol:getc.lst</tt><br>
    <br>
    Link it with /lda for an absolute binary that starts at location
    1000.<br>
    <tt>.link vol:getc/<a class="moz-txt-link-freetext" href="map:vol:getc/lda">map:vol:getc/lda</a></tt><br>
    <br>
    Look at the map to confirm:<br>
    <tt>.type vol:getc.map</tt><br>
    <br>
    <tt>RT-11 LINK  V08.10     Load Map       Page 1</tt><tt><br>
    </tt><tt>GETC  .LDA       Title:    GETC      Ident:              </tt><tt><br>
    </tt><tt><br>
    </tt><tt>Section  Addr    Size    Global    Value    Global   
      Value    Global    Value</tt><tt><br>
    </tt><tt><br>
    </tt><tt> . ABS.     000000    001000 = 256.   words 
      (RW,I,GBL,ABS,OVR)</tt><tt><br>
    </tt><tt>      001000    000020 = 8.     words  (RW,I,LCL,REL,CON)</tt><tt><br>
    </tt><tt><br>
    </tt><tt>Transfer address = 001000, High limit = 001016 = 263.  
      words</tt><br>
    <br>
    Suspend RT-11<br>
    CTRL-E<br>
    <br>
    In SimH, attach the lda file to the paper tape punch:<br>
    <tt>sim>att ptp getc.lda</tt><br>
    <br>
    Resume RT-11<br>
    <tt>sim>c</tt><br>
    <br>
    Back in RT-11, copy the lda file to the PC: device:<br>
    <tt>copy getc.lda pc:</tt><br>
    <br>
    Halt RT-11:<br>
    CTRL-E<br>
    <tt>sim>q</tt><br>
    <br>
    Fire up pdp11:<br>
    <tt>pdp11</tt><tt><br>
    </tt><tt><br>
    </tt><tt>PDP-11 simulator V4.0-0 Beta        git commit id: 9c977e93</tt><tt><br>
    </tt><br>
    In SimH, load the absolute address binary and run it from location
    1000:<br>
    <tt>sim> load getc.lda </tt><tt><br>
    </tt><tt>sim> g 1000</tt><tt><br>
    </tt><br>
    Press a key, any key and try to remember what you pressed (type
    'A'):<br>
    <tt>A</tt><tt><br>
    </tt><tt>HALT instruction, PC: 001020 (HALT)</tt><tt><br>
    </tt><br>
    Examine the contents of register 0:<br>
    <tt>sim> e r0</tt><tt><br>
    </tt><tt>R0:    000101</tt><br>
    <br>
    101 is the ASCII code for 'A' in Octal .<br>
    <br>
    Thanks all for the hints and suggestions.<br>
    <br>
    Will<br>
    <br>
    <div class="moz-cite-prefix">On 2/19/16 4:01 PM, Timothe Litt wrote:<br>
    </div>
    <blockquote cite="mid:56C7909C.3000409@ieee.org" type="cite">
      <pre wrap="">The console terminal driver won't like you touching the device registers.

Don't do that.  Use the RT-11 syscalls instead.

Or load your program into the (emulated) bare hardware, and have fun.

This communication may not represent my employer's views,
if any, on the matters discussed. 

On 19-Feb-16 16:58, Will Senn wrote:
</pre>
      <blockquote type="cite">
        <pre wrap="">Given the following test program that I wrote (GETC.MAC):

   .title getc

    .mcall    .exit

TKS = 177560
TKB = 177562
;TPS = 177564
;TPB = 177566

begin:
    inc    TKS        ;set the ASR read enable bit
getc:
    tstb    TKS        ;is a character available?
    bpl    getc        ;loop until there is

    movb    TKB,R0        ;put the character into register 0

    .exit

    .end begin

I would expect the console to wait until I typed a single character
and then for the program to exit. What is happening is that the
program appears to accept any number of characters and only ends when
I type CTRL-C twice.

Here are some questions that arise:

1. Is it reasonable to expect to be able to read directly from the ASR
Keyboard buffer while running RT-11 in SimH or does this somehow
compete with the running OS? (I can print characters using the ASR
Punch Buffer just fine)
2. Is there a flaw in the program? (Nevermind that it doesn't do
anything much with the character).
3. Is this a totally abnormal way to read a character?
4. What's up with needing to hit CTRL-C twice?

Answers to any of the above would be appreciated or if you have
something else, that's fine too.

Thanks,

Will
_______________________________________________
Simh mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Simh@trailing-edge.com">Simh@trailing-edge.com</a>
<a class="moz-txt-link-freetext" href="http://mailman.trailing-edge.com/mailman/listinfo/simh">http://mailman.trailing-edge.com/mailman/listinfo/simh</a>
</pre>
      </blockquote>
      <pre wrap="">

</pre>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
Simh mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Simh@trailing-edge.com">Simh@trailing-edge.com</a>
<a class="moz-txt-link-freetext" href="http://mailman.trailing-edge.com/mailman/listinfo/simh">http://mailman.trailing-edge.com/mailman/listinfo/simh</a></pre>
    </blockquote>
    <br>
  </body>
</html>