answersLogoWhite

0

Circle Macro x,y,rad,color

local Loop1,Loop2,Loop3

pusha

; BX=X Offset, CX=Y Offset, DX=Some evil counter

xor bx,bx

mov cx,[rad]

mov ax,cx

shl ax,1

mov dx,3

sub dx,ax

; AL=Color

mov al,

; Calculate address of center in vidmem.

mov di,[y]

mov si,di

shl di,8

shl si,6

add di,si

add di,[x]

mov gs,di

Loop1:

; Plot 8 pixels using known centerpoint and X and Y offsets.

mov di,gs

add di,bx

mov si,cx

shl si,6

add di,si

shl si,2

add di,si

mov es:[di],al

sub di,si

sub di,si

shr si,2

sub di,si

sub di,si

mov es:[di],al

sub di,bx

sub di,bx

mov es:[di],al

add di,si

add di,si

shl si,2

add di,si

add di,si

mov es:[di],al

mov di,gs

add di,cx

mov si,bx

shl si,6

add di,si

shl si,2

add di,si

mov es:[di],al

sub di,si

sub di,si

shr si,2

sub di,si

sub di,si

mov es:[di],al

sub di,cx

sub di,cx

mov es:[di],al

add di,si

add di,si

shl si,2

add di,si

add di,si

mov es:[di],al

; Is DX still under zero?

cmp dx,0

jge Loop2

; If, add 4*XOffset+6 to DX

mov si,bx

shl si,2

add si,6

add dx,si

jmp Loop3

Loop2:

; If not, add 4*(XOffset-YOffset)+10 to DX

mov si,bx

sub si,cx

shl si,2

add si,10

add dx,si

; Decrease Y coordinate

dec cx

Loop3:

; Increase X coordinate

inc bx

; Is X Offset<Y Offset; if is, loop again.

cmp bx,cx

jl Loop1

popa

ENDM

mov ax,0013h

int 10h

mov ax,0A000h

mov es,ax

circle 10,10,5,55

AWAIT:

MOV AH,0

INT 16H

CMP AH,1

JE EXIT

JMP AWAIT

EXIT:

User Avatar

Wiki User

12y ago

Still curious? Ask our experts.

Chat with our AI personalities

RossRoss
Every question is just a happy little opportunity.
Chat with Ross
MaxineMaxine
I respect you enough to keep it real.
Chat with Maxine
SteveSteve
Knowledge is a journey, you know? We'll get there.
Chat with Steve

Add your answer:

Earn +20 pts
Q: Write assembly program that draw circle?
Write your answer...
Submit
Still have questions?
magnify glass
imp