Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Help with IDIV function

ZotudZotud Member Posts: 1
Hi,

Im pretty new to assembler and having a problem with creating a modulus function. The full problem is that I want to display a clock on the screen that takes the time from the system clock. This is my current thinking:

cycle: mov ah,06 ;check for Esc pressed?
mov dl,0ffh
int 21h

cmp al,27 ; if pressed then exit program
je finish

mov dh,5 ;set cursor position
mov dl,27
mov bh,0
mov ah,poscur
int 10h

mov ah,2ch ;get time from system clock
int 21h ;ch will contain hours, cl will contain
;mins
;dh will contain secs, dl will contain
;0.05 secs
mov secs1,dh

mov ax,secs1

mov al,10

idiv al

add secs1,48

mov dl,secs1 ;display secs1
mov ah,02
int 21h

jmp cycle

The problem is that the values for mins (for example) are displayed as ascii chars. So I want to divide mins by 10 using IDIV, which should give me the quotient and the reminder then I can correct their values and display the time. However I cannot move secs1 (mins value) into ax (ax is divided by al when using idiv function), I get an operands types do not match error. Is there a way around this problem, maybe using different registers etc?

Thanks for any help..

Comments

  • tburchamtburcham Member Posts: 102
    The full problem is that I want to display a clock on the screen that takes the time from the system clock. This is my current thinking:

    : cycle: mov ah,06 ;check for Esc pressed?
    : mov dl,0ffh
    : int 21h
    :
    : cmp al,27 ; if pressed then exit program
    : je finish
    :
    : mov dh,5 ;set cursor position
    : mov dl,27
    : mov bh,0
    : mov ah,poscur
    : int 10h
    :
    : mov ah,2ch ;get time from system clock
    : int 21h ;ch will contain hours, cl will contain
    : ;mins
    : ;dh will contain secs, dl will contain
    : ;0.05 secs
    : mov secs1,dh
    :
    : mov ax,secs1
    :
    : mov al,10
    :
    : idiv al
    :
    : add secs1,48
    :
    : mov dl,secs1 ;display secs1
    : mov ah,02
    : int 21h
    :
    : jmp cycle
    :
    : The problem is that the values for mins (for example) are displayed as ascii chars. So I want to divide mins by 10 using IDIV, which should give me the quotient and the reminder then I can correct their values and display the time. However I cannot move secs1 (mins value) into ax (ax is divided by al when using idiv function), I get an “operands types do not match” error. Is there a way around this problem, maybe using different registers etc?

    [b]
    ####################################

    Hi,
    You can use:

    movsx ax,dh

    ...or...

    xor ax,ax
    mov al,dh

    ...and put dh into secs1 before or after this
    if you need it there.
    TB
    [/b]

  • seyedmajidseyedmajid Member Posts: 1
    Hi My friend
    i want use your code for taking the time from system clock but it didn't work because this interrupt you use is for DOS os.
    do you know any interrupt for windows.
    Thanks

  • AsmGuru62AsmGuru62 Member Posts: 6,519
    [color=Blue]No DOS interrupts work in Windows - to get the local Time use API GetLocalTime:

    [link=http://msdn.microsoft.com/en-us/library/ms724338(VS.85).aspx]http://msdn.microsoft.com/en-us/library/ms724338(VS.85).aspx[/link]
    [/color]
Sign In or Register to comment.