Displaying Time in Assembly

前端 未结 3 1400
梦如初夏
梦如初夏 2020-12-02 02:32

Hello im trying to display the actual time hours/minutes/seconds this is my code sample:

MOV AH, 2Ch
INT 21h

MOV AH, 0Eh

MOV AL, CH
INT 10h

MOV AL, 3Ah
IN         


        
3条回答
  •  醉话见心
    2020-12-02 03:10

    You need a print routine to print bytes as numbers, instead of writing them directly to the screen as characters. Luckily since you only have to deal with values between 0 and 59, and since you want leading zeroes, the problem is pretty simple. Assuming value to be printed in AX:

    print2Digits:
        ;; input in AX (0-99)
        ;; clobbers AX and DX, save them if needed
        MOV   DL, 0Ah ; divide by: 10
        DIV   DL      ; first digit in AL (quotient), second digit in AH (remainder)
        MOV   DX, AX  ; save the digits
        ADD   AL, 30h ; ASCII '0'
        MOV   AH, 0Eh ; set up print
        INT   10h     ; print first digit.
        MOV   AL, DH  ; retrieve second digit
        ADD   AL, 30h
        INT   10h     ; print it
        RET
    

提交回复
热议问题