.model small
.stack 200h
  msg db 'This is the message to be displayed:','$'
  msg2 db 0dh,0ah,'The message you just entered: ','$'
  msg3 db 0dh,0ah,'$'
  buf db 7,8 DUP('$') 

      mov ax,@data    ;load
      mov ds,ax
      mov ah,09h      ;display msg
      lea dx,msg
      int 21h
      mov ah,0ah      ;store
      mov dx,offset buf
      int 21h
      mov ah,09h      ;display msg2
      lea dx,msg2
      int 21h
      lea dx,buf      ;display stored
      add dx,02
      mov ah,09h
      int 21h 
      mov ah,09h
      lea dx,msg3
      int 21h   

      mov ch,00
      mov cl,buf[1]
      mov bx,0002h 
Again: mov al,buf
      sub al,20H 
      mov buf,al
      inc bx
      loop again 
      MOV AH,09H
      LEA DX,buf 
      ADD DX,2H
      INT 21H         
      mov ax,4c00h    ;exit
      int 21h

that code ask the users to input letter in lowercase and then convert it to uppercase letter
my question is the code:
buf db 7,8 DUP('$')  ; as far as i understand this... the first number is the maximum input...
then the 2nd number (8) is the reserve bytes...
my question here is that why is it that program makes an error if the user input 6 characters??
the full maximum character should be inputted...the error is like this

INT 21h, AH=09h -
address: 0734B
byte 24h not found after 2000 bytes.
; correct example of INT 21h/9h:
mov dx, offset msg
mov ah, 9

please help me understand what is wrong with that code
Posted on 2009-08-27 23:22:05 by web4
The magic 2nd number:

Format of DOS input buffer:
Offset Size Description (Table 01344)
00h BYTE maximum characters buffer can hold
01h BYTE (call) number of chars from last input which may be recalled
(ret) number of characters actually read, excluding CR
02h  N BYTEs actual characters read, including the final carriage return

Posted on 2009-08-28 07:49:39 by sinsi
thanks buddy...but why is it makes an error if i input it up to the max input character read...
i don't know somehow why it is suddenly fixed when i edit the line of the
code: buf db 7,8 dup ('$') to buf db 7,9 dup ('$') cause i think 7,8 would be good but
don't know why is it output an error...
Posted on 2009-08-28 08:49:09 by web4
i guess DOS programming in ASM here is not very common
Posted on 2009-09-01 03:38:55 by web4
I'm often programming command line tools. (It doesn't matter if in DOS or Win32-Console.)
I would recommend that you avoid any user-inputs by keyboard, but let the user enter any parameters on the commandline. This can be handled much easier by the program.
Posted on 2009-09-01 19:51:13 by TasmDev