|
|
1.1 root 1: ////////
2: /
3: / Intel 8086 C runtime.
4: / SMALL model.
5: /
6: ////////
7:
8: .globl vlrem
9: .globl vrrem
10:
11: ////////
12: /
13: / unsigned long
14: / vrrem(a, b);
15: / unsigned long a;
16: / unsigned long b;
17: /
18: / unsigned long
19: / vlrem(a, p);
20: / unsigned long a;
21: / unsigned long *p;
22: /
23: / these two routines perform 32 bit unsigned remainder.
24: / they are called by the compiler when a user program performs an
25: / unsigned long remainder, and are called by the library routines
26: / that perform long remainder.
27: /
28: ////////
29:
30: alow = 8
31: ahigh = 10
32: blow = 0
33: bhigh = 2
34:
35: vlrem: mov ax,bx / save bx.
36: mov bx,sp / point bx at
37: mov bx,6(bx) / the operand and
38: jmp L0 / go to common end.
39:
40: vrrem: mov ax,bx / save bx.
41: mov bx,sp / point bx at
42: lea bx,6(bx) / the operand.
43:
44: L0: push si / standard
45: push di / c
46: push bp / function
47: mov bp,sp / linkage.
48:
49: push ax / save saved bx.
50: mov si,ahigh(bp) / pick up
51: mov di,alow(bp) / dividend.
52: sub dx,dx / clear out the
53: sub ax,ax / the upper half of the mq.
54:
55: mov cx,$32 / step count.
56:
57: L1: shl di,$1 / shift
58: rcl si,$1 / one
59: rcl ax,$1 / bit
60: rcl dx,$1 / left.
61:
62: cmp dx,bhigh(bx) / does it go in ??
63: jb L3 / nope.
64: ja L2 / yes.
65: cmp ax,blow(bx) / maybe ??
66: jb L3 / nope.
67:
68: L2: sub ax,blow(bx) / subtract the
69: sbb dx,bhigh(bx) / divisor (don't maintain quotient).
70:
71: L3: loop L1 / do this 32 times.
72:
73: pop bx / restore bx.
74: mov sp,bp / standard
75: pop bp / c
76: pop di / function
77: pop si / linkage.
78: ret / done.
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.