.model small
.386
.stack

.data

r002    dd      2.0
r100    dd      100.0
r320    dd      320.0
y       dw      0
angle   dd      0.0
anglestep dd    0.0
radius  dd      90.0

.code

main    proc

        mov     ax,@data
        mov     ds,ax

        mov     ax,0A000h               ;video segment
        mov     es,ax

        mov     ax,0013h                ;320x200x256
        int     10h

        finit

        fldpi                           ;1 unit circle sub arc per screen x
        fmul    r002
        fld     r320
        fdiv
        fstp    anglestep




        mov     cx,320                  ;screen width
        mov     si,0                    ;x
m1:
        push    cx

        fld     angle                   ;y = sine(angle)*radius
        fsin
        fmul    radius
        fistp   y

        add     y,100                   ; + y origin

        mov     di,y                    ;plot it
        mov     dl,15
        call    pset

        fld     angle                   ;increment angle
        fadd    anglestep
        fstp    angle

        inc     si                      ;next x

        pop     cx
        loop    m1

        mov     ah,0                    ;wait key
        int     16h
                                        ;text mode
        mov     ax,0003h
        int     10h

        mov     ax,4C00h                ;to DOS
        int     21h

main    endp


pset    proc    near
        push    ax                      ;call with  si = x     di = y
        push    bx                      ;           dl = color

        mov     ax,di                   ;--calc vid adress on x,y
        shl     ax,6
        mov     bx,ax                   ;bx=y*64
        shl     ax,2                    ;ax=y*256
        add     bx,ax                   ;bx = y*320
        add     bx,si                   ;bx = y*320 + x

        mov     es:[bx],dl

        pop     bx
        pop     ax
        ret
pset    endp

        end     main

