views:

70

answers:

3
+1  Q: 

clock on pdp-11

hello, I'm a little bit confused about simple program which I wrote, can You please explain why it quits after printing only one character, I expected it will print me character every 5 seconds, thanks in advance

tks = 177560
tkb = 177562
tps = 177564
tpb = 177566
lcs = 177546
. = torg + 2000

main:   mov #main, sp

        mov #clock, @#100  ; vector interrupt of the clock 100-102
        mov #300, @#102    ; 

        mov #100, @#lcs    ; here I enable interrupt-enable of the clock

prog:   clr r0             ; here endless loop
        beq prog
        halt

clock:  inc count
        cmp count, timeout
        bne clk_end
        clr count
        mov #'*, @#tpb
clk_end:rti

. = torg + 3000
timeout: .word 300000
count: .word 0
A: 

I'm not familiar with the PDP-11, but I have written interrupt code for other processors. On other processors, the behavior you describe could occur if the flags register isn't saved by the interrupt routine. If an interrupt occurred between the two instructions clr r0 and beq prog, and the interrupt handler cleared the equal bit in the flags register, it would cause the behavior that you describe.

Again, I'm not familiar with PDP-11 assembler, but you might try saving the state of the flags register when you enter the interrupt routine, and restoring it just before the rti instruction. Perhaps using the PDP-11 equivalent of the 80x86 push instruction.

Jim Mischel
thanks for the answer, but I think I have something else here, I changed my code to prog: br prog, but it works the same way
helloWorld
A: 

This is surely a simulator-related problem, since I tried to run you code, and it works fine!

Are you by chance a student at the Technion?

Tomer Vromen
yes, You are right I'm student of the Technion, and this simulator makes me crazy, what can be the problem, why do I receive halt? I suggest You also study there? Your program didn't halt? cause I expect it prints me * every 5 seconds
helloWorld
I'm using the simulator provided by the course on Windows 7, and it printed * every ~4 sec. without halting. Maybe try running it on a different computer?
Tomer Vromen
I thought that simulator doesn't depend on OS, ok, thanks
helloWorld
A: 

I think the mode for the clock should not be 0 but 1, Load it with 110 instead of 100. See KW11-P programmable real time clock manual.

Stephane