;this is a test programme for floating point number arithmatics


;--------------------------------------addition-------------------------------

 use16
 org 100h

 main:
   mov	 dx,text1
   mov	 ah,9h
   int	 21h

 addition1:
   finit	;reset all the registers and fags of FPU to their original values and initialize the FPU
   fld	 [float1]  ;decrement the top FPU register by one and load floating poit value	so st(0)= float1
   fld	 [float2]   ;so st(0) = float2 and st(1) = float1
   fadd  st0,st1
   fstp  [float3]

   xor	 eax,eax
   mov	 eax,[float3]
   ;xor  di,di
   mov	 di,num1		  ;point start of num to di
   call  mkstr



 prnt1:
   mov	   dx,num1
   mov	   ah,9h
   int	   21h

   xor	ah,ah
   int	16h
   mov	   dx,tab
   mov	   ah,9h
   int	   21h



 addition2:
   finit
   fld	 [float4]
   fld	 [float5]
   fadd  st0,st1
   fstp  [float3]



   xor	 eax,eax
   mov	 eax,[float3]

   mov	 di,num2
   call  mkstr



 prnt2:
   mov	   dx,num2
   mov	   ah,9h
   int	   21h

   jmp	 exit

 mkstr:

   xor	cx,cx
   mov	   ecx,2
   .str2:
	xor	edx,edx

	div	ecx
	xchg	eax,edx 	;now  modulus is in al
	add	al,30h
	cld

	stosb			;store in num and inc di once
	xchg	eax,edx
	cmp	eax,0
	jne	.str2

	mov	al,24h
	stosb
	ret






 exit:
   xor	ah,ah
   int	16h
   mov	ax,4c00h
   int	21h



;-----------------------------------------------data------------------------------------------------------
 text1	db 'this is a test programme for floating point number arithmatics ',13,10,24h
 tab	db 13,10
	db 'adm',13,10,24h
 num1	 db 0
 num2	 db 0
 float1 dd 9.45
 float2 dd 5.22
 float4 dd 9.45
 float5 dd 5.22
 float3 dd 0
 float7 dd 123
 float6 dd 0