|
|
1.1 root 1: //////////
2: / i8086 general utilities library.
3: / div()
4: / ANSI 4.10.6.2.
5: / Division and remainder.
6: //////////
7:
8: #include "larges.h"
9:
10: //////////
11: / #include <stdlib.h>
12: / div_t div(int numer, int denom)
13: /
14: / Compute quotient and remainder of 'numer' by 'denom'.
15: / Return a pointer to a statically allocated div_t object.
16: //////////
17:
18: .prvd
19: quot: .word 0
20: rem: .word 0
21:
22: numer = RASIZE
23: denom = 2 + numer
24:
25: .shri
26: .globl div_
27:
28: div_:
29: mov bx, sp
30: mov ax, Pss numer(bx) / Dividend to AX
31: cwd / Sign-extend to DX:AX
32: idiv Pss denom(bx) / Divide by divisor
33: Map (ds, bx, $@quot)
34: mov bx, $quot / Pointer to result to DS:BX
35: mov (bx), ax / Store quotient
36: mov 2(bx), dx / Store remainder
37: #if LARGE
38: mov dx, ds
39: #endif
40: mov ax, bx / Return pointer in DX:AX
41: Gret
42:
43: / end of div.m
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.