function __R( range : word ) : word; assembler; asm mov ax, Word(System.RandSeed) { DS:[003eH] } mov bx, Word(System.RandSeed+2) { DS:[0040H] } mov cx, ax mul CS:word ptr [0598H] shl cx, 1 shl cx, 1 shl cx, 1 add ch, cl add dx, cx add dx, bx shl bx, 1 shl bx, 1 add dx, bx add dh, bl mov cx, 0005H @1: shl bx, 1 loop @1 add dh, bl add ax, 0001 adc dx, 0000 mov word(System.RandSeed), ax { [003eH], ax } mov word(System.RandSeed+2), dx { [0040H], dx } xor ax, ax mov bx, range or bx, bx je @2 xchg dx, ax div bx xchg dx, ax @2: end; |
[001973]