1: / crypt -- password incoding 2: 3: / mov $key,r0 4: / jsr pc,crypt 5: 6: .globl crypt, _crypt 7: .globl savr5 8: 9: _crypt: 10: mov r5,-(sp) 11: mov sp,r5 12: mov r5,savr5 13: mov 4(r5),r0 14: jsr pc,crypt 15: clr savr5 16: mov (sp)+,r5 17: rts pc 18: 19: crypt: 20: mov r1,-(sp) 21: mov r2,-(sp) 22: mov r3,-(sp) 23: mov r4,-(sp) 24: mov r5,-(sp) 25: 26: mov r0,r1 27: mov $key,r0 28: movb $004,(r0)+ 29: movb $034,(r0)+ 30: 1: 31: cmp r0,$key+64. 32: bhis 1f 33: movb (r1)+,(r0)+ 34: bne 1b 35: 1: 36: dec r0 37: / 38: / 39: / fill out key space with clever junk 40: / 41: mov $key,r1 42: 1: 43: movb -1(r0),r2 44: movb (r1)+,r3 45: xor r3,r2 46: movb r2,(r0)+ 47: cmp r0,$key+128. 48: blo 1b 49: / 50: / 51: / establish wheel codes and cage codes 52: / 53: mov $wheelcode,r4 54: mov $cagecode,r5 55: mov $256.,-(sp) 56: 2: 57: clr r2 58: clr (r4) 59: mov $wheeldiv,r3 60: 3: 61: clr r0 62: mov (sp),r1 63: div (r3)+,r0 64: add r1,r2 65: bic $40,r2 66: bis shift(r2),(r4) 67: cmp r3,$wheeldiv+6. 68: bhis 4f 69: bis shift+4(r2),(r5) 70: 4: 71: cmp r3,$wheeldiv+10. 72: blo 3b 73: sub $2,(sp) 74: tst (r4)+ 75: tst (r5)+ 76: cmp r4,$wheelcode+256. 77: blo 2b 78: tst (sp)+ 79: / 80: .data 81: shift: 1;2;4;10;20;40;100;200;400;1000;2000;4000;10000;20000;40000;100000 82: 1;2 83: wheeldiv: 32.; 18.; 10.; 6.; 4. 84: .bss 85: cagecode: .=.+256. 86: wheelcode: .=.+256. 87: .text 88: / 89: / 90: / make the internal settings of the machine 91: / both the lugs on the 128 cage bars and the lugs 92: / on the 16 wheels are set from the expanded key 93: / 94: mov $key,r0 95: mov $cage,r2 96: mov $wheel,r3 97: 1: 98: movb (r0)+,r1 99: bic $!177,r1 100: asl r1 101: mov cagecode(r1),(r2)+ 102: mov wheelcode(r1),(r3)+ 103: cmp r0,$key+128. 104: blo 1b 105: / 106: / 107: / now spin the cage against the wheel to produce output. 108: / 109: mov $word,r4 110: mov $wheel+128.,r3 111: 3: 112: mov -(r3),r2 113: mov $cage,r0 114: clr r5 115: 1: 116: bit r2,(r0)+ 117: beq 2f 118: incb r5 119: 2: 120: cmp r0,$cage+256. 121: blo 1b 122: / 123: / we have a piece of output from current wheel 124: / it needs to be folded to remove lingering hopes of 125: / inverting the function 126: / 127: mov r4,-(sp) 128: clr r4 129: div $26.+26.+10.,r4 130: add $'0,r5 131: cmp r5,$'9 132: blos 1f 133: add $'A-'9-1,r5 134: cmp r5,$'Z 135: blos 1f 136: add $'a-'Z-1,r5 137: 1: 138: mov (sp)+,r4 139: movb r5,(r4)+ 140: cmp r4,$word+8. 141: blo 3b 142: / 143: 144: mov (sp)+,r5 145: mov (sp)+,r4 146: mov (sp)+,r3 147: mov (sp)+,r2 148: mov (sp)+,r1 149: mov $word,r0 150: rts pc 151: .bss 152: key: .=.+128. 153: word: .=.+32. 154: cage: .=.+256. 155: wheel: .=.+256.