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

Hi

use this :

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;                                                    ;;
;;  Source Name     : StrSpr.ASM                      ;;
;;  Executable Name : StrSpr.COM                      ;;
;;  Code Model      : Real mode flat model            ;;
;;  Created Date    : 29/09/2006                      ;;
;;  Author          : VIDOCQ                          ;;
;;  Description     : A simple example of a DOS .COM  ;;
;;                    file programmed using NASM 0.98 ;;
;;                                                    ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
[BITS 16]
[ORG 0x100]
[SECTION .text]
%macro  Write 2 ;ShowIt,ShowLength
mov BX,1  ; Selects DOS file handle 1: Standard Output
mov CX,%2  ; ShowLength: Length of string passed in CX
mov DX,%1  ; Showit: Offset address of string passed in DX
mov AH,40H  ; Select DOS service 40: Print String
int 21H  ; Call DOS
%endmacro
start :
mov AX,[mystr]
mov WORD [num1],AX
mov AH,[mystr+2]
mov BYTE [operator],AH
mov AX,[mystr+3]
mov WORD [num2],AX
Write num1,2
Write CRLF,2
Write operator,1
Write CRLF,2
Write num2,2
ret
[SECTION .data]
mystr  DB "24+67"
num1  DW 0
num2  DW 0
operator DB 0
CRLF       DW      0D0AH
 
;;----- End of file-----;;

GoodLuck .

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.