0

Now iam working on the currency conversion system which able to convert from RM to USD using assembly language with 32-bit, but now i stuck at divide the floating point value like 0.19. Or is there any ways to do it? Please help me a bit of urget

Thank in advance

INCLUDE Irvine32.inc 
.data 
welcomeUSD db "Welcome to Currency Convertion(RM to USD)",0
amount1 db "Please eneter amount:",0
convertUSD db "Enter conversion rate:",0
convertionRate real4 ?
input dword ?
input1 dword ?
calcProd real4 ?
usdInput dword ?
usdconvertionRate real4 ?  
.code
main PROC   
;==================================  
mov     edx, OFFSET welcomeUSD  
call    WriteString
call    CrLf

;Get user input
;============================================
mov     edx, OFFSET  amount1 
call        WriteString  
call ReadInt
mov usdInput,eax
call    CrLf

;Get user input 2
;===================================

mov edx ,offset convertUSD
call        WriteString 
call ReadDec
mov usdconvertionRate ,eax

   mov eax, usdInput           
   mov ebx, usdconvertionRate              
   xor edx, edx            
   div ebx                 
   call WriteDec        

    mov al, '.'             
    call WriteChar        

    imul eax, edx, 10       
    xor edx, edx           
    div ebx                 
    call WriteDec         

    imul eax, edx, 10      
    xor edx, edx            
    div ebx                 
    call WriteDec         
    exit    
main ENDP
END main
Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
John Chong
  • 1
  • 1
  • 3
  • 1
    None of your code shows any use of floating point; so the first thing you'll have to figure out is whether you'll emulate floating point with integer instructions yourself (which only makes sense for ancient 32-bit CPUs - 80386 and 80486 from back when FPU was "optional") or use FPU (likely?) or use one of the later SIMD extensions (SSE, AVX). – Brendan Mar 24 '21 at 10:01
  • It looks like your code now is using fixed-point integer, with a fixed 2 places after the decimal point. Floating point is *one* way to store `0.19` in a computer, which makes it easy to do math with, but hard to convert to/from a decimal string. (Unless there's an Irvine32 library function like ReadFloat; check the manual.) – Peter Cordes Mar 24 '21 at 12:05
  • Maybe this will help, try looking into this [https://stackoverflow.com/questions/59451389/need-help-to-display-number-with-decimal-places-in-assembly-language-using-visua](https://stackoverflow.com/questions/59451389/need-help-to-display-number-with-decimal-places-in-assembly-language-using-visua) – Jonathan Apr 04 '21 at 12:34

0 Answers0