Timing routine not working

From: Andrew Kennedy (andrewkennedy2_at_LOGev1.net)
Date: 02/18/04


Date: Wed, 18 Feb 2004 16:34:14 -0000


The timing routine I added isn't quite working yet.

model tiny
code
586

ORG 100h

start:
       jmp begin

days LABEL WORD

dw offset su, offset mo, offset tu, offset we, offset th, offset fr, offset
sa
su db 'Sunday, $'
                                                                        
               
mo db 'Monday, $'
tu db 'Tuesday, $'
we db 'Wednesday, $'
th db 'Thursday, $'
fr db 'Friday, $'
                   
sa db 'Saturday, $'
prescence db 'COPYRIGHT (c) Andrew Kennedy andrewkennedy2@LOGev1.net(Remove
LOG)'

BEGIN:
       mov ax, cs
       mov ds, ax

xor eax, eax ; start the timer
cpuid
rdtsc
mov edi, eax ; save lower 32 bits in edi
push edi
xor eax, eax
cpuid

; Insert timed code here

       mov ah,2ah ; date, month in dh, day in dl,
       int 21h ; year in cx
       movzx bx,al
       add bx,bx
       mov dx,cs:[days+bx] ; print day of the week
       mov ah,9
       int 21h

       MOV AH,2Ah
       INT 21h ; Get Date
       MOV AL,DH ; DH contains month
       MOV BL,'-'
       CALL SHOWIT ; call month
       MOV AL,DL ; DL has day
       CALL SHOWIT
       MOV AX,CX ; CX contains year
       MOV BL,64h ; 64h = 100
       DIV BL ; Split year
       MOV AL,AH ; move year to al
       MOV BL, 00 ; Used by 'JL Last_L'
       CALL SHOWIT ; call year
       MOV DL,' ' ; 0D = CR
       INT 21h ; Display 2 spaces
       INT 21h ;

       MOV AH,2Ch
       INT 21h ; Get Time
       push dx
       MOV BL,3Ah ; 3Ah = ':'
       MOV AL,CH ; CH contains hour

       CALL SHOWIT
       MOV AL,CL ; CL contains minutes
       CALL SHOWIT
       MOV BL,20h
       MOV AL,DH ; DH contains seconds
       CALL SHOWIT
       mov ah,2
       mov dl,':'
       int 21h
       pop dx
       mov al,dl ; DL contains 1/100 secs
       call showit

       mov dl,0ah ; carriage return
       int 21h

xor eax, eax
cpuid
rdtsc
pop edi
sub edi, eax
xor eax, eax
sub eax, edi ; eax = result

       MOV AX,4C00h
       INT 21h
SHOWIT:
       PUSH DX ; Save DX, holds date or time
       MOV DL,0Ah ; move 10 into DL
       XOR AH,AH ; Zero AH
       DIV DL ; Div by 10
       OR AX,3030h ; Convert to ASCII
       MOV DX,AX
       MOV AH,02h
       INT 21h ; Display_character from DL, First charter
       MOV DL,DH
       INT 21h ; Display_character from DL, Second charter
       cmp bl, 21h ; Is it '/','-',or':'?
       JL LAST_D ; If not, quit
       MOV DL,BL
       INT 21h ; Display_character from DL, '/' or ':'
LAST_D:
       POP DX ; Restore DX
       RET ; End branch

END START



Relevant Pages

  • Re: Assembler equivalent of sprintf
    ... xor eax, eax ... mov eax, ... written as "inc byte ptr buffer" ... You could say that Nasm assumes "offset" ...
    (comp.lang.asm.x86)
  • Tasm Local WIN32_FIND_DATA w98 XP
    ... Below code is OK on w98 but in XP is NOT. ... CALL RtlZeroMemory, eax, size WIN32_FIND_DATA ... Call MessageBox, 0, offset szMsgFound, offset szMsgOK, 10h ... RET ...
    (alt.lang.asm)
  • Re: Assembler equivalent of sprintf
    ... xor eax, eax ... movzx eax, word ... mov eax, ... where NASM assumes offset with, ...
    (comp.lang.asm.x86)
  • Re: Same opcodes, different instructions !
    ... pointer to this object is a local variable in a function. ... Now, eax has, or rather should have, the pointer's address. ... Get this object's vptr in esi, vptr at offset 0x0 ...
    (alt.lang.asm)
  • Save some clocks ?
    ... xor eax, eax ... mov edi, eax; save lower 32 bits in edi ...
    (comp.lang.asm.x86)