Welcome to Dream.In.Code
Getting Help is Easy!

Join 136,157 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 2,141 people online right now. Registration is fast and FREE... Join Now!




Timer using assembly

 
Reply to this topicStart new topic

Timer using assembly

$ @ l^l^l @ R
27 Dec, 2007 - 09:01 AM
Post #1

New D.I.C Head
*

Joined: 25 Dec, 2007
Posts: 3

hi . . .
This code is a procedure for a timer to be displayed on a game I'm programing using assembly

but when I assemble it it gave Divide overflow

CODE
; variables for timer


det_flag DB 5
   time_flag DB ?
   time DB 30H ,3ah, 30h, 30h
   time_print_c DB 67
   time_out DB "TIME OUT ",0
   ten DB 10
   ur_score DB 30h,30h,30h



;define a procedure to read the time of that game.
mRead_time PROC NEAR
PUSHA
setCrusor 22,69
MOV AH,2Ch
INT 21h
    
MOV AL,DH
DIV ten    
    
MOV CH,AH
ADD CH,30h     
    
CMP [time_flag],CH
  JE no_time_inc

inc_now:
  MOV [time_flag],CH
  CMP [time+3],39h  
   JE inc_sec
  INC [time+3]
  JMP print_time

inc_sec:
  MOV [time+3],30h  
  CMP [time+2],35h               
   JE inc_min
  INC [time+2]  
  JMP print_time

inc_min:
  MOV [time+2],30h
  INC [time]                    

print_time:    
  MOV DL,[time+SI]  
  MOV AH,06h
  INT 21h
  INC SI
  CMP SI,4
   JE no_time_inc
  JMP print_time

no_time:
  setCrusor 22,67    
  MOV DX, OFFSET time_out
  MOV CX,9
  MOV BX,0  
  MOV AH,40h    
  INT 21h

final_exit:
  MOV DL,0FFh
  MOV AH,06h
  INT 21h
  JZ final_exit      
  CMP AL,1bh
   JE final_exit0
  JMP final_exit

final_exit0:    
  MOV AH,4Ch
  INT 21h
no_time_inc:
  POPA

RET
mRead_time ENDP




Please can any one help me why ?

thank you

This post has been edited by born2c0de: 27 Dec, 2007 - 10:36 PM
User is offlineProfile CardPM
+Quote Post

born2c0de
RE: Timer Using Assembly
27 Dec, 2007 - 10:36 PM
Post #2

printf("I'm a %XR",195936478);
Group Icon

Joined: 26 Nov, 2004
Posts: 3,906



Thanked: 34 times
Dream Kudos: 2800
Expert In: 80x86 Assembly, C/C++, VB6, VB.NET, C#, J2SE, Win32 API, Reversing

My Contributions
I'm not near an Assembler right now but this is what I could get from a quick read.
QUOTE
MOV AL,DH
DIV ten


Since ten is an 8bit variable, the register AX is taken as the Dividend (and not AL).
Use this instead and you shouldn't get the error.

CODE
XOR AH, AH
MOV AL, DH
DIV ten

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/1/08 11:22PM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month