essayez ce code.! mais vous devez déclarer des variables qui est une chose facile :)
`
print_float proc near
push cx
push dx
cmp bott, 0
jns div_not_signed
inc bosig
div_not_signed:
cmp upp, 0
jns upp_not_signed
inc upsig
upp_not_signed:
mov cl, upsig
sub cl, bosig
jz positive
neg dx
positive:
cmp ax, 0
jne checked
cmp dx, 0
jns checked
push dx
mov dl, '-'
call write_char
pop dx
checked:
call print_num
cmp dx, 0
je done
push dx
mov dl, '.'
call write_char
pop dx
mov cx, 5
call print_fraction
done:
pop dx
pop cx
ret
print_float endp
print_fraction proc near
push ax
push dx
next_fraction:
cmp cx, 0
jz end_rem
dec cx
cmp dx, 0
je end_rem
mov ax, dx
imul ten2
idiv bx
push dx
mov dx, ax
cmp dx, 0
jns not_sig
neg dx
not_sig:
add dl, 30h
call write_char
pop dx
jmp next_fraction
end_rem:
pop dx
pop ax
ret
print_fraction endp
print_numx proc near
push bx
push cx
push dx
mov cl, 1
mov bl, 100
cmp al, 0
jz end_show
begin_print:
cmp bl,0
jz end_show
cmp cl, 0
je calc
cmp al, bl
jb skip
calc:
xor cl, cl
cbw
div bl
mov dl, al
add dl, 30h
push ax
mov ah, 02h
int 21h
pop ax
mov al, ah
skip:
push ax
mov al, bl
cbw
div ten
mov bl, al
pop ax
jmp begin_print
end_show:
pop dx
pop cx
pop bx
ret
print_numx endp
write_char proc near
push ax
mov ah, 02h
int 21h
pop ax
ret
write_char endp
`
En supposant que * est * IEEE 754, vous trouverez les spécifications détaillées ici: http: // fr. wikipedia.org/wiki/IEEE_754-2008. * The Art of assembly Langue: * http://books.google.com/books?id=094tYob7ipQC&pg=PA95&source=gbs_toc_r&cad=4#v=onepage&q&f=false –
Vous devriez utiliser 3.1415926536 pour un flotteur près de pi au lieu. – hirschhornsalz
@drhirsch: Je ne suis pas d'accord. En langage assembleur sur un x86, vous devriez normalement utiliser 'fldpi'. –