; STARS.ASM ; ; Input a single digit (ASCII) and output that many asterisks. ; (Doesn't check for valid digits, so if you type in a non-digit you ; may get a lot more asterisks, depending on the ASCII code entered.) ; ; Original program by: Alan Pinck ; -IAN! idallen@ncf.ca November 1999 ;---------------------------------------------------------------------- Stars segment assume CS:Stars,DS:Stars org 100h ; .COM requires this ;---------------------------------------------------------------------- start: ; Print a prompt ; mov dx,offset msg ; offset address of the message text mov ah,09h ; code for "display ASCII$ string" int 21h ; Note: don't forget the 'h' on 21h! ; Get one key ; mov ah,01h ; code for "get+echo one key" int 21h ; char is returned in AL sub al,"0" ; convert char from ASCII to decimal mov count,AL ; store this value as our count ; Loop printing stars until count goes to zero ; loop: mov al,count ; load current count cmp al,0h ; compare count against zero je done ; we're done if it's equal ; Output one star ; mov dl,"*" ; load the char we're going to print mov ah,02h ; code for "output one ASCII char" int 21h ; Decrement the count ; mov al,count ; update count by loading it, sub al,1h ; subtracting one, and mov count,al ; storing it back jmp loop ; go back up and see if we do more ; End the program ; done: mov ah,4Ch ; code for "terminate program" int 21h ;---------------------------------------------------------------------- ; Data and variables down here. ; msg db "Please push a key: " db "$" ; end of ASCII$ string count db 0 ; one-byte (unsigned) counter ;---------------------------------------------------------------------- Stars ends end start ; "start" is the label on the first instruction