944,082 Members | Top Members by Rank

Ad:
  • Assembly Discussion Thread
  • Unsolved
  • Views: 2051
  • Assembly RSS
Sep 24th, 2006
0

separating strings

Expand Post »
im coding in 8086 assembly.
i want to separate a string.
For example:

Str DB '24+67'

i want to separate the '24', the '+' and the '67'
and place them in the variable
num1, operator, num2 respectively.

can anyone help me with a piece of code please.
thanks
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
joker1379 is offline Offline
3 posts
since Sep 2006
Sep 28th, 2006
0

Re: separating strings

Hi

use this :

Assembly Syntax (Toggle Plain Text)
  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ;; ;;
  3. ;; Source Name : StrSpr.ASM ;;
  4. ;; Executable Name : StrSpr.COM ;;
  5. ;; Code Model : Real mode flat model ;;
  6. ;; Created Date : 29/09/2006 ;;
  7. ;; Author : VIDOCQ ;;
  8. ;; Description : A simple example of a DOS .COM ;;
  9. ;; file programmed using NASM 0.98 ;;
  10. ;; ;;
  11. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  12. [BITS 16]
  13. [ORG 0x100]
  14. [SECTION .text]
  15. %macro Write 2 ;ShowIt,ShowLength
  16. mov BX,1 ; Selects DOS file handle 1: Standard Output
  17. mov CX,%2 ; ShowLength: Length of string passed in CX
  18. mov DX,%1 ; Showit: Offset address of string passed in DX
  19. mov AH,40H ; Select DOS service 40: Print String
  20. int 21H ; Call DOS
  21. %endmacro
  22. start :
  23. mov AX,[mystr]
  24. mov WORD [num1],AX
  25. mov AH,[mystr+2]
  26. mov BYTE [operator],AH
  27. mov AX,[mystr+3]
  28. mov WORD [num2],AX
  29. Write num1,2
  30. Write CRLF,2
  31. Write operator,1
  32. Write CRLF,2
  33. Write num2,2
  34. ret
  35. [SECTION .data]
  36. mystr DB "24+67"
  37. num1 DW 0
  38. num2 DW 0
  39. operator DB 0
  40. CRLF DW 0D0AH
  41.  
  42. ;;----- End of file-----;;

GoodLuck .
Reputation Points: 10
Solved Threads: 0
Newbie Poster
VIDOCQ is offline Offline
6 posts
since Aug 2006

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: I have problem about Knapsack in ASM
Next Thread in Assembly Forum Timeline: Where can i learn about assembly language





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


Follow us on Twitter


© 2011 DaniWeb® LLC