Click here to Skip to main content
15,888,521 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,
I can not create a 2d array and set it to print.
The project I want to do: Save the name of 20 students and sort and print.
Thank you for your help


What I have tried:

.model small
.data     
    p1 db 'please enter name:$'
    maxlen db 25
    actlen db ?
    ;str db 20 dup(?),'$'
    str db 20 dup(25 dup(?)),'$'
    count db 0
    
    t1 db '        Student Names$'
    t2 db '-----------------------------$'
    t3 db 'No.             Names$'
.code
    main proc
        mov ax,@data
        mov ds,ax
        
        call cls
        m1:
        call read
        jz m2
        jmp m1          
        
        m2:
        call sort
        call print
        jz m3
        
        m3:
        mov ax,4ch
        int 21h
        
    main endp
    ;
    cls proc 
        mov ax,0b800h
        mov es,ax
        mov si,0
        mov al,' '
        mov cx,10
        
       c1:
        mov es:si,al
        add si,2
        loop c1  
     ret
    cls endp
    ;
     newline proc
       ;khate jadid
       MOV dl, 10
       MOV ah, 02h
       INT 21h
       ;ebteday khate jadid
       MOV dl, 13
       MOV ah, 02h
       INT 21h    
       ;
      ret
     newline endp
    ;
    read proc
        mov ah,09h
        lea dx,p1
        int 21h
       
        call newline 
    
        mov ah,0ah
        lea dx,maxlen
        int 21h 
    
        call newline
    
        inc count
        
        cmp count,5
        jne r1
    r1:
        ret   
    read endp
    ;
    sort proc
        
     ret  
    sort endp
    ;
    print proc
       mov ah,09h
       lea dx,t1
       int 21h
       
       call newline
       
       mov ah,09h
       lea dx,t2
       int 21h     
       
       call newline
       
       mov ah,09h
       lea dx,t3
       int 21h
       
       call newline
       
       mov ah,09h
       lea dx,t2
       int 21h
       call newline
       
       
      mov si,0
     mov al,' '
     mov cl,actlen
     mov ch,0
    b2:
        cmp str[si],al
        
        mov ah,09h
        lea dx,str[si][1]
        int 21h 
        
        jne b1
    b1:
       loop b2
  
        ret   
    print endp
    ;
end main
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900