I have reformulated my work but now I just can´t get the result in floating point. Does anyone know why?
.MODEL SMALL
.386
.387
.STACK 200h ; reserva 1k para a stack
data Segment
menu db ' ',0ah,0dh
db ' 2006/2007 ',0ah,0dh
db ' ',0ah,0dh
db ' þþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþ ',0ah,0dh
db ' þ Arquitectura Computadores I þ ',0ah,0dh
db ' þþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþ ',0ah,0dh
db ' þ 1 - Calculate Area þ ',0ah,0dh
db ' þ 2 - Help þ ',0ah,0dh
db ' þ 3 - EXIT þ ',0ah,0dh
db ' þþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþ ',0ah,0dh
db ' ',0ah,0dh
db ' ',0ah,0dh
db ' ',0ah,0dh
db ' ',0ah,0dh
db ' ',0ah,0dh
db ' ',0ah,0dh
db ' ',0ah,0dh
db ' ',0ah,0dh
db ' ',0ah,0dh
db 'Choose an option:','$'
menuajuda db ' ',0ah,0dh
db ' 2006/2007 ',0ah,0dh
db ' ',0ah,0dh
db ' þþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþ ',0ah,0dh
db ' þ Area of Circle þ ',0ah,0dh
db ' þþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþ ',0ah,0dh
db ' This program calculates the area of a þ ',0ah,0dh
db ' þ circle given the radius by the user þ ',0ah,0dh
db ' þ þ ',0ah,0dh
db ' þþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþ ',0ah,0dh
db ' þ þ ',0ah,0dh
db ' þ þ ',0ah,0dh
db ' þþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþ ',0ah,0dh
db ' ',0ah,0dh
db ' ',0ah,0dh
db ' ',0ah,0dh
db ' ',0ah,0dh
db ' ',0ah,0dh
db ' ',0ah,0dh
db 'Return to the menu.','$'
ILLEGAL DB 0DH,0AH,'Introduce the value: $'
mens1 Db 0ah,0ah,0dh,'Radius: ','$'
mens3 Db 0ah,0ah,0dh,'The area of the circle is:','$'
menserro1 Db 0ah,0ah,0dh,'Introduce numbers only','$'
menserro db 0ah,0ah,0dh,' (ERROR) Introduce a number between 1 and 3',0ah,0dh,'$'
prima db 0ah,0dh,' Press ENTER and a number ','$'
menserro2 db 0ah,0dh,' (ERROR) Introduce (Y)es or (N)o','$'
prima2 db 0ah,0dh,' Press ENTER and then a letter','$'
sair db 0ah,0ah,0dh,'Quit? Y/N ','$'
resultado db 100 dup (?)
db '$'
temp real4 ?
; x dw ?
x real4 ?
data Ends
Pilha Segment 'stack'
db 100 dup(?)
pilha ends
Code Segment
Assume CS: Code, DS: data, es:nothing
call MenuPrincipal
;----------------------------------------------
Inicio:
mov ax,data ;move data para ax
mov ds,ax ;move ax para ds
mov es,ax ;move ax para es
;++++++++++++Limpa o ecran+++++++++++++++
clescr proc near
call clrscr1
mov ah,6
mov bh,9Fh
xor cx,cx
mov dh, 24
mov dl, 79
mov al,cl
int 10h
ret
clescr endp
clrscr1 proc near
mov ah,6
mov ah,00h
mov al,03h
int 10h
ret
clrscr1 endp
MenuPrincipal proc near
call clescr
mov dx,dx
or dx,dx
mov ah,01h
mov cx,07h
int 10h
lea dx,menu
mov ah,09h
int 21h
call getch
mov cl,al
cmp cl,'1'
jz calculo
cmp cl,'2'
jz Ajuda
cmp cl,'3'
jz exit
jnz erro
jmp calculo
MenuPrincipal endp
erroNumero proc near
lea dx,menserro1
mov ah,09h
int 21h
lea dx,prima
mov ah,09h
int 21h
call getch
jmp MenuPrincipal
erroNumero endp
erro proc near
lea dx,menserro
mov ah,09h
int 21h
lea dx,prima
mov ah,09h
int 21h
call getch
jmp MenuPrincipal
erro endp
Ajuda proc near
call clescr
lea dx,menuajuda
mov ah,09h
int 21h
call getch
jmp MenuPrincipal
Ajuda endp
;**************************************************************************;
;--------------------------- DECIMALY_INPUT ------------------------------;
;**************************************************************************;
DECIMAL_INPUT PROC
; this procedure will read a number in decimal form
; input : none
; output : store binary number in BX
; uses : MAIN
JMP @READ
@ERROR:
LEA DX, ILLEGAL
MOV AH, 9
INT 21H
call clescr
call calculo
@READ: ; jump label
XOR BX, BX ; clear BX
XOR CX, CX ; clear CX
MOV AH, 1 ; set input function
INT 21H ; read a character
CMP AL, "-" ; compare AL with "-"
JE @MINUS ; jump to label @MINUS if AL="-"
CMP AL, "+" ; compare AL with "+"
JE @PLUS ; jump to label @PLUS if AL="+"
JMP @INPUT ; jump to label @INPUT
@MINUS: ; jump label
MOV CX, 1 ; set CX=1
@PLUS: ; jump label
INT 21H ; read a character
CMP AL, 0DH ; compare AL with CR
JE @END ; jump to label @END if AL=CR
@INPUT: ; jump label
CMP AL, 2eH ; compare AL with 0 mudei de 30h para 2e par aceitar o .
JL @ERROR ; jump to label @ERROR if AL<0
CMP AL, 39H ; compare AL with 9
JG @ERROR ; jump to label @ERROR if AL>9
AND AX, 000FH ; convert ascii to decimal code
PUSH AX ; push AX onto the STACK
MOV AX, 10 ; set AX=10
MUL BX ; set AX=AX*BX
MOV BX, AX ; set BX=AX
POP AX ; pop a value from STACK into AX
ADD BX, AX ; set BX=AX+BX
MOV AH, 1 ; set input function
INT 21H ; read a character
CMP AL, 0DH ; compare AL with CR
JNE @INPUT ; jump to label if AL!=CR
@END: ; jump label
OR CX, CX ; check CX is 0 or not
JE @EXIT ; jump to label @EXIT if CX=0
NEG BX ; negate BX
@EXIT: ; jump label
CMP BX, 0 ; compare BX with 0
JL @ERROR ; jump to label @ILLEGAL if BX<0
CMP BX, 9999 ; compare BX with 9999
JG @ERROR ; jump to label @ILLEGAl if BX>9999
RET ; return control to the calling procedure
DECIMAL_INPUT ENDP
;**************************************************************************;
;--------------------------- DECIMAL_OUTPUT -----------------------------;
;**************************************************************************;
DECIMAL_OUTPUT PROC
; this procedure will display a decimal number
; input : BX
; output : none
; uses : MAIN
CMP BX, 0 ; compare BX with 0
JGE @START ; jump to label @START if BX>=0
MOV AH, 2 ; set output function
MOV DL, "-" ; set DL='-'
INT 21H ; print the character
NEG BX ; take 2's complement of BX
@START: ; jump label
MOV AX, BX ; set AX=BX
XOR CX, CX ; clear CX
MOV BX, 10 ; set BX=10
@REPEAT: ; loop label
XOR DX, DX ; clear DX
DIV BX ; divide AX by BX
PUSH DX ; push DX onto the STACK
INC CX ; increment CX
OR AX, AX ; take OR of Ax with AX
JNE @REPEAT ; jump to label @REPEAT if ZF=0
MOV AH, 2 ; set output function
@DISPLAY: ; loop label
POP DX ; pop a value from STACK to DX
OR DL, 30H ; convert decimal to ascii code
INT 21H ; print a character
LOOP @DISPLAY ; jump to label @DISPLAY if CX!=0
RET ; return control to the calling procedure
DECIMAL_OUTPUT ENDP
;**************************************************************************;
DECIMAL_INPUTteste PROC
; this procedure will read a number in decimal form
; input : none
; output : store binary number in BX
; uses : MAIN
JMP @READ ; jump to label @READ
@ERROR: ; jump label
LEA DX, ILLEGAL ; load and display the string ILLEGAL
MOV AH, 9
INT 21H
call clescr
call calculo
@READ: ; jump label
XOR eBX, eBX ; clear BX
XOR eCX, eCX ; clear CX
MOV AH, 1 ; set input function
INT 21H ; read a character
CMP AL, "-" ; compare AL with "-"
JE @MINUS ; jump to label @MINUS if AL="-"
CMP AL, "+" ; compare AL with "+"
JE @PLUS ; jump to label @PLUS if AL="+"
JMP @INPUT ; jump to label @INPUT
@MINUS: ; jump label
MOV eCX, 1 ; set CX=1
@PLUS: ; jump label
INT 21H ; read a character
CMP AL, 0DH ; compare AL with CR
JE @END ; jump to label @END if AL=CR
@INPUT: ; jump label
CMP AL, 2eH ; compare AL with 0 mudei de 30h para 2e par aceitar o .
JL @ERROR ; jump to label @ERROR if AL<0
CMP AL, 39H ; compare AL with 9
JG @ERROR ; jump to label @ERROR if AL>9
AND eAX, 000FH ; convert ascii to decimal code
PUSH eAX ; push AX onto the STACK
MOV eAX, 10 ; set AX=10
MUL eBX ; set AX=AX*BX
MOV eBX, eAX ; set BX=AX
POP eAX ; pop a value from STACK into AX
ADD eBX, eAX ; set BX=AX+BX
MOV AH, 1 ; set input function
INT 21H ; read a character
CMP AL, 0DH ; compare AL with CR
JNE @INPUT ; jump to label if AL!=CR
@END: ; jump label
OR eCX, eCX ; check CX is 0 or not
JE @EXIT ; jump to label @EXIT if CX=0
NEG eBX ; negate BX
@EXIT: ; jump label
CMP eBX, 0 ; compare BX with 0
JL @ERROR ; jump to label @ILLEGAL if BX<0
CMP eBX, 9999 ; compare BX with 9999
JG @ERROR ; jump to label @ILLEGAl if BX>9999
RET ; return control to the calling procedure
DECIMAL_INPUTteste ENDP
DECIMAL_OUTPUTteste PROC
; this procedure will display a decimal number
; input : BX
; output : none
; uses : MAIN
CMP eBX, 0 ; compare BX with 0
JGE @START ; jump to label @START if BX>=0
MOV AH, 2 ; set output function
MOV DL, "-" ; set DL='-'
INT 21H ; print the character
NEG eBX ; take 2's complement of BX
@START: ; jump label
MOV eAX, eBX ; set AX=BX
XOR eCX, eCX ; clear CX
MOV eBX, 10 ; set BX=10
@REPEAT: ; loop label
XOR eDX, eDX ; clear DX
DIV eBX ; divide AX by BX
PUSH eDX ; push DX onto the STACK
INC eCX ; increment CX
OR eAX, eAX ; take OR of Ax with AX
JNE @REPEAT ; jump to label @REPEAT if ZF=0
MOV AH, 2 ; set output function
@DISPLAY: ; loop label
POP eDX ; pop a value from STACK to DX
OR DL, 30H ; convert decimal to ascii code
INT 21H ; print a character
LOOP @DISPLAY ; jump to label @DISPLAY if CX!=0
RET ; return control to the calling procedure
DECIMAL_OUTPUTteste ENDP
;--------------------------------------------------------------------------;
calculo proc near
lea dx,mens1
mov ah,09h
int 21h
;Call DECIMAL_INPUT
Call DECIMAL_INPUTteste
mov x,ebx
;-----------------Co-Processador---------------
;----------------------------------------------
finit
wait
fild x ; ST(0) = x
fmul x ; ST(0) = ST(0) * x = x*y
fldpi
fmul
;fstsw ax
sahf
fstp temp
lea dx,mens3
mov ah,09h
int 21h
;mov bx,temp
mov ebx,temp
;call DECIMAL_OUTPUT;entra bx
call DECIMAL_OUTPUTteste
jmp exit
calculo endp
exit proc near
lea dx,sair
mov ah,09h
int 21h
call getch
mov cl,al
cmp cl,'N'
jz inicio
cmp cl,'S'
jz fim
cmp cl,'n'
jz menuprincipal
cmp cl,'s'
jz fim
jnz erro2
exit endp
erro2 proc near
call clescr
lea dx,menserro2
mov ah,09h
int 21h
lea dx,prima2
mov ah,09h
int 21h
call getch
jmp exit
erro2 endp
; process overlow error:
;++++++++++++++++++++++ Getchar +++++++++++++++++++++++++++++++++++++++++++++
getch proc near
xor ax,ax
;mov ah,08h
mov ah,01h
int 21h
ret
getch endp
Fim:
call clescr
mov ah,4ch
int 21h
Code Ends
End Inicio