separating strings

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

Join Date: Sep 2006
Posts: 3
Reputation: joker1379 is an unknown quantity at this point 
Solved Threads: 0
joker1379 joker1379 is offline Offline
Newbie Poster

separating strings

 
0
  #1
Sep 24th, 2006
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
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 6
Reputation: VIDOCQ is an unknown quantity at this point 
Solved Threads: 0
VIDOCQ's Avatar
VIDOCQ VIDOCQ is offline Offline
Newbie Poster

Re: separating strings

 
0
  #2
Sep 28th, 2006
Hi

use this :

  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 .
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



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

©2003 - 2009 DaniWeb® LLC