another addition with tasm

Please support our Assembly advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Aug 2009
Posts: 46
Reputation: jingo1126 is an unknown quantity at this point 
Solved Threads: 0
jingo1126 jingo1126 is offline Offline
Light Poster

another addition with tasm

 
0
  #1
Sep 2nd, 2009
  1. .model small
  2. .stack
  3. .data
  4. .code
  5.  
  6. start:
  7. mov ah,1
  8. int 21h
  9. mov ah,2
  10. mov dl,0ah
  11. int 21h
  12. push ax
  13. mov ah,1
  14. int 21h
  15. mov ah,2
  16. int 21h
  17. pop bx
  18. add ax,bx
  19. aaa
  20. add al,30h
  21. mov dl,al
  22. mov ah,2
  23. int 21h
  24. end start
Ok guys?this is another addition program in tasm..
im using a different approach in adding 2 digits..
i was wondering why my 2nd input wont show even there is service 2,,can someone help me with this problem..thnks
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 830
Reputation: wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all 
Solved Threads: 94
wildgoose's Avatar
wildgoose wildgoose is offline Offline
Practically a Posting Shark

Re: another addition with tasm

 
0
  #2
Sep 2nd, 2009
You need something like the following. I did this in an editor so you'll have to debug it! Note the comments!

  1. .model small
  2. .stack
  3. .data
  4. .code
  5.  
  6. start:
  7. mov ah,1
  8. int 21h ; DOS - Read character from StdIn (Key)
  9. ; al=char read
  10.  
  11. ; mov ah,2
  12. ; mov dl,0ah ; WRITE LineFeed ????
  13. ; int 21h ; DOS - Write character to StdOut
  14. ; ; NOTE: AL is now destroyed! as LineFeed was written!
  15.  
  16. ;;; BASED upon your error, and this next push....
  17. mov ah,2
  18. mov dl,al
  19. int 21h
  20.  
  21. push ax ; Save Old Character
  22.  
  23. mov ah,1
  24. int 21h ; DOS - Read character from StdIn (Key)
  25. ; al = char read
  26.  
  27. mov ah,2
  28. int 21h ; DOS - Write character to StdOut
  29.  
  30. pop bx ; Restore Old Character
  31. ; al = 2nd char bl = 1st char
  32.  
  33. ; You aren't doing BCD so why are you using the instruction AAA ?
  34.  
  35. ;;; add ax,bx
  36. ;;; aaa
  37.  
  38. mov ah,0
  39. add al,bl
  40. daa ; Decimal adjust High Nibble, Low Nibble
  41. ;ah=high digit, al=low digit
  42.  
  43. mov dh,al ; Save lower digit
  44.  
  45. mov dl,ah ; Upper digit
  46. add dl,30h
  47. mov ah,2
  48. int 21h ; DOS - Write Digit Upper ASCII
  49.  
  50. mov dl,dh ; Lower Digit
  51. add dl,30h
  52. mov ah,2
  53. int 21h ; DOS - Write digit Lower ASCII
  54.  
  55.  
  56.  
  57. end start
Last edited by wildgoose; Sep 2nd, 2009 at 5:07 pm.
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 830
Reputation: wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all wildgoose is a name known to all 
Solved Threads: 94
wildgoose's Avatar
wildgoose wildgoose is offline Offline
Practically a Posting Shark

Re: another addition with tasm

 
0
  #3
Sep 2nd, 2009
My mistake

Line #40 should be
  1. ;daa ; Decimal adjust
  2. aaa ; Ascii adjust

daa puts result of two unpacked adds into upper nibble of al.
aaa adds the BCD (lower nibble) carry result onto the ah register. Why it needs to be pre-cleared.
Last edited by wildgoose; Sep 2nd, 2009 at 5:50 pm.
Reply With Quote Quick reply to this message  
Join Date: Aug 2009
Posts: 46
Reputation: jingo1126 is an unknown quantity at this point 
Solved Threads: 0
jingo1126 jingo1126 is offline Offline
Light Poster

Re: another addition with tasm

 
0
  #4
Sep 2nd, 2009
ok thanks wildgoose im gona try and debug..cheers
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 1
Reputation: fr0sts is an unknown quantity at this point 
Solved Threads: 0
fr0sts fr0sts is offline Offline
Newbie Poster
 
0
  #5
Oct 14th, 2009
awts... is this code right?im troubled by this codes.. NEW kid in town.. just studied assembly..can any1 help me out? here is me e-add..

lockheart_l@yahoo.com
Reply With Quote Quick reply to this message  
Reply

Message:



Similar Threads
Other Threads in the Assembly Forum


Views: 823 | Replies: 4
Thread Tools Search this Thread



Tag cloud for Assembly
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC