home *** CD-ROM | disk | FTP | other *** search
/ minnie.tuhs.org / unixen.tar / unixen / PDP-11 / Trees / V6 / usr / source / s3 / switch.s < prev    next >
Encoding:
Text File  |  1975-05-13  |  508 b   |  41 lines

  1. / switch -- switch on contents of r0
  2. /
  3. /
  4. / calling sequence --
  5. /
  6. /   jsr r5,switch; swtab
  7. /
  8. / r0 is looked up in swtab and if found
  9. / control is returned to the corresponding place
  10. / if r0 is not found, the next inline instruction is 
  11. / executed
  12. /
  13. / swtab format --
  14. /
  15. / swtab:
  16. /    val1; ret1
  17. /   val2; ret2
  18. /   ...
  19. /   valn; retn
  20. /   ..; 0
  21. /
  22.  
  23.     .globl    switch
  24. switch:
  25.     mov    r1,-(sp)
  26.     mov    (r5)+,r1
  27. 1:
  28.     cmp    r0,(r1)+
  29.     beq    1f
  30.     tst    (r1)+
  31.     bne    1b
  32. 2:
  33.     mov    (sp)+,r1
  34.     rts    r5
  35. 1:
  36.     mov    (r1)+,r1
  37.     beq    2b
  38.     mov    r1,r5
  39.     br    2b
  40.  
  41.