0

The question is: Enter a text of size T not exceeding 250 characters and entered on the keyboard using the function 0Ah of interrupt 21h, for size and text entry. This text is a sequence of words separated by one or more blanks, a word is in turn a chain of alphabetic characters. A verification of the size is required at the time of its entry: If the size is less than 1 or greater than 250 an error message is displayed: the size entered is incorrect; and resume typing again I know that the int 21h with AH=09h is going to read from the keyboard, but with the criteria they put, I found some difficult. here's my code

DATA SEGMENT
 
text DB 250 dup(?)
error db  'Taille erronee',10,13,'$'
msg1 db 'please put the size of the text',10,13,'$'
msg2 db 'pease start writing your text',10,13,'$'
temp db 5 dup ('$')
          
DATA ENDS

CODE SEGMENT
ASSUME cs:code, ds:data
    MAIN: 
        MOV AX,DATA                  
        MOV DS,AX
        XOR AX,AX
                 
        MOV DX,offset msg1
        CALL write 
        
               
    readSize:    
        MOV DX,offset temp
        CALL read
        
        MOV temp, [dx]
        
        CMP temp,49h
        JE continue
        JB readSize
        CMP temp,0FAh
        JG readSize 
        
    continue:
        MOV DX,offset msg2
        CALL write
    
    
    
    mov ah,4ch
    int 21h 
    

PROC read
    MOV AH,0AH
    INT 21h   
RET    
ENDP read 
    
PROC write
    MOV AH,09H
    INT 21H 
RET      
ENDP write
    
        
CODE ENDS
  End Main
Peter Cordes
  • 286,368
  • 41
  • 520
  • 731
  • 1
    [How buffered input works](https://stackoverflow.com/q/47379024) shows how to use int 21h / ah=0Ah with a buffer with size total/actual bytes at the start. – Peter Cordes May 28 '22 at 00:59

0 Answers0