1

I would like to multiple integers like 10 and 100 with 1.06 or 2.05 and display the value. How to do this? The code below is a segment used to print out 2 digit numbers and 3 digit numbers.

a DB 100
b DB 10

d1 DB 100
d2 DB 10
quo DB 0


;--to display 2 digit numbers like 10
    mov ax,0
    mov al,b
    mov cl,10        
    div cl          
    mov cl,al        
    mov ch,ah

    mov ah, 02h
    mov dl,cl     
    add dl, 30h      
    int 21h

    mov ah, 02h
    mov dl,ch       
    add dl, 30h     
    int 21h

three_digit:

    mov ax,0
    mov al,a
    div d1
    mov quo,al          
    mov a,ah        
         
     mov ah, 02h
     mov dl,quo  ;2nd digit in CH = not ascii
     add dl, 30h       ;convert to ascii for display
     int 21h
     
    mov ax,0
    MOV al,d1
    DIV d2
    MOV d1,al
    LOOP three_digit
Peter Cordes
  • 286,368
  • 41
  • 520
  • 731
  • 1
    If you want to multiply by powers of 10, it might be easier to work in decimal floating-point, or just treat it as a string problem of moving the decimal point. – Peter Cordes Aug 30 '21 at 15:28
  • @PeterCordes I do not understand what you mean. – Adrian Joshua Aug 30 '21 at 15:53
  • to multiply by 10, convert the number to a string, find the `.` and move it to the right by 1 position. If there's no `.` then add a `0` to the end, or else if the `.` is the last character then substitute that for a `0`. – Erik Eidt Aug 30 '21 at 15:56
  • 1
    What format are you using to represent 1.06? Among others, options are string, floating point, (unpacked, packed or densely packed) binary coded decimal, and fixed point. – Erik Eidt Aug 30 '21 at 16:06
  • @ErikEidt I'm not using a format to represent 1.06 because I dont know how to represent a decimal in asm – Adrian Joshua Aug 30 '21 at 16:25
  • 1
    Well, that's what you should work on before trying to multiply. – Erik Eidt Aug 30 '21 at 16:31
  • 1
    @AdrianJoshua I see that you've moved on from [your previous question](https://stackoverflow.com/questions/68975723/how-to-multiply-a-2-user-inputs-with-two-numbers-then-add-them-in-assembly-8086) Was my answer to that question not satisfying? You did not click the *accept* checkmark and neither did you leave a comment. Did you at least follow the link I gave in my answer? The code in today's question has several problems. Finally here's some food for thought: there aren't too many people prepared to answer question about the 8086... – Sep Roland Aug 30 '21 at 18:20

0 Answers0