入力文字列を取得するコード
Windows マシンで nasm を使用してアセンブルします。nasm file.asm -o file.com
;read the string
mov ah,0x0A ;read
mov dx,buffer ;pointer to buffer
int 0x21
;newline
mov ah,2
mov dl,10
int 0x21
mov dl,13
int 0x21
;put $ sign at end of string
mov bx,buffer+1
mov dx,buffer+2
add dl,byte[bx]
mov bx,dx
mov byte[bx],'$'
;output
mov dx,buffer+2
mov ah,9
int 0x21
;exit
mov ah,0x4c
int 0x21
;buffer
buffer:
db 255 ;len of buffer
db 0 ;num of char read
db 255 ;actual string
;############################
長さ2文字までの文字列の作業ファイルで、それ以降はガベージを出しています。