Slide 9.3: This book's link library (cont.)
Slide 9.5: This book's link library (cont.)
Home

This Book's Link Library (Cont.)


ReadChar
It reads a single character from the keyboard and returns the character in the AL register.

ReadHex
It reads a 32-bit hexadecimal integer from the keyboard and returns the value in EAX.

ReadInt
It reads a 32-bit signed integer from the keyboard and returns the value in EAX.

ReadString
It reads a string from the keyboard, stopping when the user presses the Enter key. Pass the offset of a buffer in EDX and set ECX to the maximum number of characters the user can enter, plus 1 (to save space for the terminating null byte). It returns the count of the number of characters typed by the user in EAX.

 Simply Reading in and Writing out by Using 
 ReadString   ReadChar 
 .data
 buffer  BYTE  128 DUP(0)

 .code
 call  Clrscr
 mov   edx, OFFSET buffer
 mov   ecx, SIZEOF buffer
 call  ReadString
 call  Crlf
 call  WriteString

 NEWLINE =      
 .data
 buffer  BYTE  128 DUP(0)
 .code
      call  Clrscr
      mov   esi, (OFFSET buffer) - 1
 L1:  inc   esi
      call  ReadChar
      call  WriteChar
      mov   [esi], al
      cmp   al, NEWLINE
      jne   L1

      mov   BYTE PTR [esi], 0
      call  Crlf
      mov   edx, OFFSET buffer   
      call  WriteString