Untitled

mail@pastecode.io avatar
unknown
plain_text
6 months ago
817 B
0
Indexable
Never
.MODEL SMALL
.STACK 10H

.DATA
    S DD 0    ;Define word: contain result
.CODE
 main proc 
    MOV AX, @DATA
    MOV DS, AX
    
    MOV AX, 0

    get_total:
        ADD AX, BX 
        INC BX;
        CMP BX, 9
    JLE get_total 
    
    
    
    MOV S, AX
    
    show_result:  
        MOV CX, 0
        MOV DX, 0
        MOV AX, S ; AX 16bit 
        MOV BX, 10; /10 -> seperate number
     
    divide:
        MOV DX, 0 ;DX: AX/BX -> divide 16bit
        DIV BX   
        INC CX 
        PUSH DX
        CMP AX, 0
        JNE divide
        JMP out
    
    out:
        MOV AH, 02H
        POP DX
        ADD DX, 30H; convert to ASCII 
        INT 21H
        Loop out
        
    MOV AH, 4CH
    INT 21H
 main endp
END MAIN