flat assembler
Message board for the users of flat assembler.

Index > Windows > A given character array (under windows)

Author
Thread Post new topic Reply to topic
dushlak



Joined: 21 Apr 2021
Posts: 7
dushlak 22 Apr 2021, 12:47
there is a task (A given character array S (n), n≤700. Develop a program that extracts all repeated occurrences of numbers and arithmetic signs from this array.)
I wrote the code, but it is necessary under windows in the MASM32 program help please
Code:
org   100h
push  start
retn

mess0   db  13,10,10,'ARRAY...'
db  13,10,'------------',13,10,'$'
mess1   db  13,10,10,'FOUND...'
        db  13,10,'------------',13,10,'$'

array   db  700 dup(0)          
len     dw  0                  

start:
        in ax,40h
        mov   bx,700            
        xor   dx,dx            
        div   bx                
        cmp   dx,16            
        jb    start            
        mov   [len],dx          

        mov   di,array          
@@:     xor   cx,cx            
        loop  $                
        in    ax,40h            
        imul  ax,9E35h          
        and   al,7Fh            
        cmp   al,13            
        je    @b                
        cmp   al,10            
        je    @b                
        stosb                  
        dec   dx                
        jnz   @b                
        mov   ah,9              
        mov   dx,mess0          
        int   21h              
        mov   cx,[len]          
        mov   si,array          
@@:     lodsb                  
        int   29h              
        loop  @b                

        mov   ah,9              
        mov   dx,mess1          
        int   21h              

        mov   cx,[len]          
        mov   si,array          
        mov   di,si            
        xor   dx,dx            
@@:     lodsb                  
        mov   bl,al            
        cmp   al,'*'            
        jz    @save            
        cmp   al,'/'            
        jz    @save            
        cmp   al,'+'            
        jz    @save            
        cmp   al,'-'            
        jz    @save            
        sub   bl,30h            
        cmp   bl,9              
        ja    @next            
@save:  inc   dx                
        stosb                  
@next:  loop  @b                

        mov   cx,dx              
       mov   si,array          
@@:     lodsb                  
        int   29h              
        loop  @b                

        mov   ah,8              
        int   21h              
        int   20h    
Post 22 Apr 2021, 12:47
View user's profile Send private message Reply with quote
DimonSoft



Joined: 03 Mar 2010
Posts: 1228
Location: Belarus
DimonSoft 23 Apr 2021, 12:07
But the code you’ve posted doesn’t do what you say, it barely filters out any non-digit and non-operation-sign characters, no repeating occurences detection.

P.S. Are you sure taking someone else’s code pieces and asking other people to write more is going to help you learn anything? For now you have a piece of code that uses undocumented functions and ignores documentation requirements for documented ones, not to mention obviously useless stuff here and there.
Post 23 Apr 2021, 12:07
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.