a$ = "0123456789ABCDEF"
w$ = "        db  "
s$ = "negtan  db  "

REM Make ArcTan tables for use in assembler
REM use: qbasic marctan.bas>arctan.inc  to dump to disk

c = 0
PRINT "; arctan tables, 256 entries. 0-128 degrees"
PRINT "; to use, (for angles 0-90):"
PRINT ""
PRINT ";arctan:                                                              "
PRINT ";       mov cx,rise        ; positive"
PRINT ";       mov ax,run         ; positive"
PRINT ";       cmp ax,cx"
PRINT ";       jl opptan          ; greater than 45 degrees, other side..."
PRINT ""
PRINT ";       xchg cx,ax         ; ax<cx"
PRINT ";       mov dl,ah          ; *256"
PRINT ";       mov ah,al"
PRINT ";       mov dh,0"
PRINT ";       mov al,0"
PRINT ";       div cx"
PRINT ";       mov si,ax"
PRINT ";       dec si"
PRINT ";       mov al,negtan[si]  ; resulting angle (0-128 is 0-45) in ax"
PRINT ";       mov ah,0"
PRINT ";       ret"
PRINT ";opptan:"
PRINT ";       mov dl,ah          ; ax<cx"
PRINT ";       mov ah,al          ; *256"
PRINT ";       mov dh,0"
PRINT ";       mov al,0"
PRINT ";       div cx"
PRINT ";       mov si,ax          ; ax remainder"
PRINT ";       dec si"
PRINT ";       mov cl,negtan[si]"
PRINT ";       mov ch,0"
PRINT ";       mov ax,0100h"
PRINT ";       sub ax,cx          ; resulting angle (128-256 is 45-90) in ax"
PRINT ";       ret"
PRINT : PRINT s$;

FOR z = 0 TO 100 STEP 100 / 256

 x = INT(ATN(z / 100) / 2 / 3.1415926535# * 1027)

 IF x = 256 THEN PRINT "100h"; : GOTO 78

 q$ = "0"

 y = INT(x / 16)

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

78

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

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

 PRINT " ;"; u; "/100"
 IF z > 99.6 THEN GOTO 99

 PRINT ; w$;

91

 NEXT z

99  END

