Brent Hilpert wrote:
Jay West wrote:
It's been decades since I looked at '11
assembler
(Disclaimer: I haven't dealt with '11 assembler since ~1982 either.)
So, why would the branch at location 1016 go back
to the data
at 1002? Obviously there's something I'm missing.
The comment is incorrect. The intent is to go to 1004.
Jim wrote....
>Location Content Op-code comment
>001000 012700 mov #1,r0 load ro with 1
>
>
^ comment should be
"r0" not "ro"
>001002 000001
>001004 006100 rol rotate r1 left
>
>
^ comment should be
"rotate r0 left"
>001006 012701 mov delay r1 load
register r1 with delay
>001010 007777 delay
>001012 005301 dec r1 decrement register 1
>001014 001376 bne -2 continue to decrement r1 until r1=0
>
>
-2 = -2
>001016 000772 br -12 back to
001002 (dec r0)
>
>
-6 <> -12 ^ comment should
be "001004",
^ comment should be
"rotate r0" not "dec r0"
At 1014 the machine code and assembler instruction are consistent, and correct for word
offsets.
At 1016 the machine code and assembler instruction are NOT consistent, but machine code is
still correct for word offsets.
(And presuming branch offsets are calculated relative to instruction following the branch
(after PC increment).)
There are some inconsistencies between the machine code / mnemonics / comments, but that
doesn't explain why it doesn't work.
I'm sure the '11 experts will chime in here...
Using simh you can see what the code does.
A couple possibilities as to why it isn't.
1. Make sure console is set up to monitor R0
iirc: there are knobs on the front panel to determine what
you are looking at.
2. Running too fast? increase the value at 1010 (077777?)
Here is a badly documented run of this program in simh
** Start up simh emulator
./BIN/pdp11
PDP-11 simulator V3.3-1
** Load in the program
sim> d 001000 012700
sim> d 001002 000001
sim> d 001004 006100
sim> d 001006 012701
sim> d 001010 007777
sim> d 001012 005301
sim> d 001014 001376
sim> d 001016 000772
* Verify what we entered
sim> e 001000-001016
1000: 012700
1002: 000001
1004: 006100
1006: 012701
1010: 007777
1012: 005301
1014: 001376
1016: 000772
* Look at the disassembly
sim> e -m 001000-001016
1000: MOV #1,R0
1004: ROL R0
1006: MOV #7777,R1
1012: DEC R1
1014: BNE 1012
1016: BR 1004
** Note that the BR is to 1004, not 1002
** Load start address
sim> de pc 01000
** Set up a breakpoint
sim> br 001016
** Single step through instructions
sim> s
Step expired, PC: 001004 (ROL R0)
sim> s
Step expired, PC: 001006 (MOV #7777,R1)
sim> s
Step expired, PC: 001012 (DEC R1)
sim> s
Step expired, PC: 001014 (BNE 1012)
Step expired, PC: 001012 (DEC R1)
sim> s
Step expired, PC: 001014 (BNE 1012)
** This gets boring after a while, so we execute till the breakpoint
sim> go
Breakpoint, PC: 001016 (BR 1004)
sim> e r0
R0: 000002
sim> go
Breakpoint, PC: 001016 (BR 1004)
sim> e r0
R0: 000004
** And see where it goes from there
sim> s
Step expired, PC: 001004 (ROL R0)
sim> s
Step expired, PC: 001006 (MOV #7777,R1)