; this program inputs a string, and prints it as many times as ; there are characters in the string bits 16 org 100h section .text mov dx,str0 ;1 print greeting mov ah,9 int 21h ;1 mov bx,stbuf ;1.5 set max # of chars mov byte [bx],50 ; mov byte [bx+1],50 ;1.5 mov dx,stbuf ;2 get name mov ah,0ah int 21h ;2 mov word cx,[stbuf] ;3 cx contains # of chars xchg cl,ch ; little endian switch and cx,0x00ff ;3 mov ax,0x0d0a ;4 add cr, lf and $ char to string mov bx,stbuf ; bx points to end of string add bx,cx mov [bx+2],ax mov al,'$' mov byte [bx+4],al ;4 mov dx,stbuf ; prepares printing add dx,2 ; points to first char mov ah,09 ;5 prints loop0 int 21h ;5 loop loop0 ; repeats cx times int 20h ; end program section .data str0 db 'Type your name:', 13, 10, '$' section .bss stbuf resb 100 ; reserves 100 bytes starting here