;This program waits for user input. if the user inputs "coolprog" a triangle will be drawn. otherwise the program will print an error. .model small .stack 100h .data p = 9 ;maximum string support: 49 chars startp = 0 ;x=0,y=0 line = 200 ;the length of the first line is 200 pixels st_msg db 'Enter password: ',0dh,0ah,'> $' in_str db p,0, 8 dup (0dh), '$' err_msg db 'incorrect password$' dlstr db 'coolprog' strlen db ? .code mov ax,@data mov ds,ax mov es,ax mov ax,3 int 10h init: lea dx,st_msg ;prints out st_msg mov ah,9 ; int 21h ; lea dx,in_str ;reads in in_str mov ah,0ah ; int 21h ; call chrfix mov cx,8 ;check the full length of the password 'coolprog' = 8 chars long lea si,in_str ;insert in_str to si lea di,dlstr ;insert dlstr to di rep cmpsb ;run a comparison between the two for 8 chars, if not equal, jump to err jne err jmp done err: call newl lea dx,err_msg ;prints out err_msg mov ah,9 ; int 21h ; call newl jmp init done: mov ax,0013h ;set vga mode int 10h ; mov ax,0a000h ; mov ds,ax ; mov di,startp ;set start location mov al,1 ;set start color mov bx,line dr: call draw ;draw a single line add di,321 ;move to the start of the next line sub di,bx ; inc al ;increase color cmp al,100 jb cont mov al,1 cont: sub bx,2 ;shorten line. when reaches 0 the loop stops jnz dr mov ah,8 ;will cause the program to hang until the user presses any key int 21h mov ah,4ch ;return control to OS int 21h ;******************* draw: ;method that draws a line starting at startp mov cx,bx ;length of line lin: mov [di],al ;draw a single pixel inc di ;move 1 pixel loop lin ret ;******************* chrfix:push cx ;method that fixes extra chars that stick to the beginning of a string push si ;register backup push ax ; mov al,in_str[1] ;find the length of the string mov strlen,al mov cl,strlen mov ch,0 mov si,2 fix: mov al,in_str+si ;shift all characters 2 spaces left and fill in the remaining 2 with '0dh' mov in_str+si-2,al inc si loop fix sub si,2 mov in_str+si,0dh mov in_str+si+1,0dh pop ax ;register restore pop si ; pop cx ; ret ;******************* newl: mov ah,2 ;method that moves the cursor to the next line mov dl,10 ;drop 1 line int 21h ; mov dl,13 ;go to start of line int 21h ; ret end