943,937 Members | Top Members by Rank

Ad:
  • Assembly Discussion Thread
  • Unsolved
  • Views: 2690
  • Assembly RSS
Apr 28th, 2007
0

What is wrong with my program?

Expand Post »
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.
Assembly Syntax (Toggle Plain Text)
  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.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
eeeraser is offline Offline
22 posts
since Apr 2007
Apr 28th, 2007
0

Re: What is wrong with my program?

interrupt 2c returns binary numbers, not ascii. You have to convert them to ascii before displaying them.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,953 posts
since Aug 2005
Apr 28th, 2007
0

Re: What is wrong with my program?

Thanks a lot man ... I really appreciate it
Best regards
Reputation Points: 10
Solved Threads: 0
Newbie Poster
eeeraser is offline Offline
22 posts
since Apr 2007
Apr 28th, 2007
0

Re: What is wrong with my program?

I'm sorry, what should I do to change these to ASCII representation ^^.. Thanks again.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
eeeraser is offline Offline
22 posts
since Apr 2007
Apr 28th, 2007
0

Re: What is wrong with my program?

Here are some examples
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,953 posts
since Aug 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Assembly Forum Timeline: Please check my code
Next Thread in Assembly Forum Timeline: HELP prime factors





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC