I know how to get to the user input and such, but I do not know what to do after that.

There are 60 seconds in a minute, and 60 minutes in an hour, so your next step is to start dividing.

Please post any code you've written so far; this will help us help you figure out what you're missing.

mov     eax,[qsec]
        mov     ebx,60
        mov     edx,0
        div     bx
        push    edx
        mov     edx,0
        div     bx
        push    edx

        lea     edi,[sHHMMSS]

        mov     ecx,3
mRp:
        mov     ebx,10
        mov     edx,0
        div     bx
        add     eax,'0'
        mov     byte [edi],al
        inc     edi
        add     edx,'0'
        mov     byte [edi],dl
        inc     edi

        cmp     ecx,1
        jle     mEx

        pop     eax
        mov     byte [edi],':'
        inc     edi
        loop    mRp
mEx:

        ...
 
qsec    dd 12*60*60+3*60+41;12:03:41
sHHMMSS db 8 dup(?)

Here's a solution:

secs_to_hhmmss:
	lea	esi, [hhmmss_const]
	lea	edi, [hhmmss_output]
	mov	eax, [hhmmss_input]
	cdq				; sign extend into edx
	div	dword [esi]		; divide edx:eax by 3600
	call	.write_two_digits	; write HH
	mov	al, ':'
	stosb				; write separator
	mov	eax, edx		; load remainder into eax
	cdq				; sign extend into edx
	div	dword [esi+4]		; divide by 60
	call	.write_two_digits	; write MM
	mov	al, ':'
	stosb				; write separator
	mov	eax, edx		; load remainder into eax
	call	.write_two_digits	; write SS
	mov	al, 0
	stosb				; write string terminator (\0)
	ret
.write_two_digits:
	cbw
	div	byte [esi+8]		; divide by 10
	call	.write_digit
	mov	al, ah			; 2nd digit
.write_digit:
	cmp	al, 9
	jbe	@f
	mov	al, 9			; saturate number
@@:
	add	al, '0'			; ASCII adjust
	stosb
	ret

hhmmss_input	dd (12*3600) + (55*60) + 30
hhmmss_output	dd 0,0,0,0
hhmmss_const	dd 3600, 60, 10, 0
This article has been dead for over six months. Start a new discussion instead.