What is wrong with my program?

Reply

Join Date: Apr 2007
Posts: 16
Reputation: eeeraser is an unknown quantity at this point 
Solved Threads: 0
eeeraser eeeraser is offline Offline
Newbie Poster

What is wrong with my program?

 
0
  #1
Apr 28th, 2007
Hi..
This is my fist time, I need your help guys to figure out what is the problem with my code. My program is to show time in this format " TIME:Hours : minute : seconds : Hunderthseconds" , but , the problem is that it didn't show correct numbers, it shows me just charachers I don't understand. As far as I know function AH = 2CH INT 21H, returns ASCII code for time " CH=hour, CL = minutes, DH = seconds, DL = 5/100 seconds"
... So, could you please figure out what is wrong with this code,
Thank you very much.
  1. TITLE " Project "
  2. .MODEL SMALL
  3. .STACK 200
  4. .DATA
  5. MSG1 DB 'TIME:$'
  6. MSG2 DB ?,'$'
  7. .CODE
  8. MAIN PROC
  9. MOV AX, @DATA ; get the address of the data segment
  10. MOV DS, AX ; and store it n register DS
  11. MOV AH, 9 ; display string function
  12. LEA SI, MSG1 ; get memory location of first message
  13. MOV DX, SI ; and store it in the DX register
  14. INT 21H
  15. MOV AH, 2CH ; Get time function 2CH interrupt 21H
  16. INT 21H
  17. LEA DI, MSG2 ; Get MSG2 address
  18. MOV BH, 3AH ; Copy the ASCII code for :
  19. MOV [DI], CH ; Copy hours into MSG2
  20. CALL WRITING ; call function Writing to write it on the standard output "screen"
  21. MOV [DI], BH ; Copy minutes
  22. CALL WRITING ; call function writing
  23. MOV [DI], CL
  24. CALL WRITING
  25. MOV [DI], BH
  26. CALL WRITING
  27. MOV [DI], DH
  28. CALL WRITING
  29. MOV [DI], BH
  30. CALL WRITING
  31. MOV [DI], DL
  32. CALL WRITING
  33. MOV AH, 07
  34. INT 21H
  35. MOV AX,4C00H ; Exit to DOS function
  36. INT 21H
  37. MAIN ENDP
  38. WRITING PROC
  39. PUSH DX ; Save value of DX
  40. MOV AH, 02 ; Function 02 of interrput 21H to write character to stander output
  41. MOV DL, MSG2 ; Copy content of MSG2 into DL
  42. INT 21H
  43. POP DX ; get the original value of DX again.
  44. RET
  45. WRITING ENDP
  46. END MAIN
Last edited by eeeraser; Apr 28th, 2007 at 6:31 am.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,396
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1466
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is online now Online
Still Learning

Re: What is wrong with my program?

 
0
  #2
Apr 28th, 2007
interrupt 2c returns binary numbers, not ascii. You have to convert them to ascii before displaying them.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 16
Reputation: eeeraser is an unknown quantity at this point 
Solved Threads: 0
eeeraser eeeraser is offline Offline
Newbie Poster

Re: What is wrong with my program?

 
0
  #3
Apr 28th, 2007
Thanks a lot man ... I really appreciate it
Best regards
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 16
Reputation: eeeraser is an unknown quantity at this point 
Solved Threads: 0
eeeraser eeeraser is offline Offline
Newbie Poster

Re: What is wrong with my program?

 
0
  #4
Apr 28th, 2007
I'm sorry, what should I do to change these to ASCII representation ^^.. Thanks again.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,396
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1466
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is online now Online
Still Learning

Re: What is wrong with my program?

 
0
  #5
Apr 28th, 2007
Here are some examples
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC