cpu 8086 org 100h section .text jmp demo ;;; Split the string at DS:SI on the character in DL. ;;; Store pointers to strings starting at ES:DI. ;;; The amount of strings is returned in CX. split: xor cx,cx ; Zero out counter .loop: mov ax,si ; Store pointer to current location stosw inc cx ; Increment counter .scan: lodsb ; Get byte cmp al,'$' ; End of string? je .done cmp al,dl ; Character to split on? jne .scan mov [si-1],byte '$' ; Terminate string jmp .loop .done: ret ;;; Test on the string given in the task demo: mov si,hello ; String to split mov di,parts ; Place to store pointers mov dl,',' ; Character to split string on call split ;;; Print the resulting strings, and periods mov si,parts ; Array of string pointers print: lodsw ; Load next pointer mov dx,ax ; Print string using DOS mov ah,9 int 21h mov dx,period ; Then print a period int 21h loop print ; Loop while there are strings ret section .data period: db '. $' hello: db 'Hello,How,Are,You,Today$' section .bss parts: resw 10