a$ = "0123456789ABCDEF"
w$ = "        dw  "
s$ = "tan     dw  "

REM use: qbasic mtan.bas>tan.inc  to dump to disk

c = 0
PRINT "; tan function tables: 256 word entries return tan(ax)."
PRINT
PRINT "; mov si,ax"
PRINT "; mov ax,[tan+si]"
PRINT : PRINT s$;

FOR z = 0 TO 256

 x = INT(TAN(z * 2 * 3.14159265# / 256)) * 256

 IF x < 0 THEN x = 65536 + x
 IF x > 65535 THEN x = 65535

 q$ = "0"

 u = INT(x / 256)
 y = INT(u / 16)

 PRINT q$; MID$(a$, y + 1, 1); MID$(a$, (u / 16 - INT(u / 16)) * 16 + 1, 1);

 u = x - u * 256
 y = INT(u / 16)

 PRINT MID$(a$, y + 1, 1); MID$(a$, (u / 16 - INT(u / 16)) * 16 + 1, 1); "h";

 c = c + 1
 IF c < 8 THEN PRINT ","; : GOTO 91

 c = 0
 q = (z - 7)
 u = INT(q * 1000) / 1000

 PRINT " ;"; u

 IF z > 254.5 THEN GOTO 92

 PRINT ; w$;
91

 NEXT z
92

