Jump to content

circle area. plz help

- - - - -

  • Please log in to reply
1 reply to this topic

#1
thatsme

thatsme

    Programmer

  • Members
  • PipPipPipPip
  • 175 posts
hi, i have to write code which lets you to input radius and then finds area of the circle. the rasult musn't be only integer so i use quadruple real number variables. then i dont know how to move such variable to microprocessor because all registers are no more than 16bit. Thats my code, please help me to finish it (var3 is 3,14)
ASSUME CS:code, DS:data, SS:sstack


sstack SEGMENT PARA STACK 'STACK'
DB 256 dup (?)
sstekas ENDS


data SEGMENT

msg db 10, 13, "Input radius"
enterp db 10, 13, "$"
maxlength db 255
length db ?
var1 dq 8 dup ('0')
var3 dq 3.14
res_str db 19 dup ('$')
res dd 00000000h

data ENDS

code SEGMENT
start:

mov ax, data
mov ds, ax

mov ax, 02h
int 10h

mov dx, offset msg
mov ah, 9
int 21h

mov dx, offset maxlength
mov ah, 10
int 21h

mov dx, offset enterp
mov ah, 9
int 21h


finit
fld var3
fld var1
fsqrt
fmul st(0), st(1)
fst res
fwait

call res_to_str
call print_res


mov ah, 07h
int 21h

mov ah, 4Ch
int 21h

res_to_str:

push ax
push di
push cx
push dx

xor di, di
xor cx, cx
mov dx, 10
mov ax, res

find_length:
div dl
xor ah, ah
inc cx
cmp al, 0
je res_buf
jmp find_length

res_buf:
mov ax, res
mov di, cx
dec di

mov_to_buf:
div dl
mov res_str[di], ah
dec di
loop mov_to_buf

exit:
pop dx
pop cx
pop di
pop ax

ret

print_res:
push ax
push dx

mov dx, offset res_str
mov ah, 9
int 21h

pop dx
pop ax

ret

code ends
end start

Edited by thatsme, 09 January 2010 - 06:36 AM.
code modified


#2
thatsme

thatsme

    Programmer

  • Members
  • PipPipPipPip
  • 175 posts
an i questioning unclearly or no one knows how to handle real numbers?




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users