Assembler i8080 print result in decimal format

40 Views Asked by At

I need to write number of words that doesn't have (+,-,*,/) inside. The result must be given in dec. form like 04, 00, 15 etc. I have number of words inside the e. If the number of words is less than 10 it's correct like 09 but when the count is 10 i get 1:. I understand what's going on so the ascii value goes on so i need to be reset to 0 after the number on left is raised.

Here is my code where i want to write things. I use emustudio:

 update_counters:
        lxi h,text2      
        call putstr

        mov a,e          

        
        mvi c,0          
divide_by_10:
        sui 10           
        jnc increment_c  
        adi 10           
        jmp proceed_to_print 
increment_c:
        inr c            
        jmp divide_by_10

proceed_to_print:
        ; Vypíš desiatky
        mov a,c
        adi '0'          
        call putchar     
        
        ; Vypíš jednotky
        mov a,e          
        ani 0Fh         
        adi '0'          
        call putchar     

        call newline     
        hlt              

I tried to reset a number on right but i don't know how and i run out of ideas.

0

There are 0 best solutions below