TITLE    An example assembly language program     SAMPLE.ASM
COMMENT  |
         Objective: To demonstrate the use of some I/O
                    routines and to show the structure
                    of assembly language programs.
            Inputs: As prompted.
|          Outputs: As per input.
.MODEL SMALL
.STACK  100H
.DATA
name_msg      DB  'Please enter your name: ',0
query_msg     DB  'How many times to repeat welcome message? ',0
confirm_msg1  DB  'Repeat welcome message ',0
confirm_msg2  DB  ' times? (y/n) ',0 
welcome_msg   DB  'Welcome to Assembly Language Programming ',0

user_name    DB  16 DUP (?)   ; buffer for user name
response     DB  ?

.CODE
INCLUDE io.mac

main  PROC
      .STARTUP
      PutStr  name_msg       ; prompt user for his/her name
      nwln
      GetStr  user_name,16   ; read name (max. 15 characters)
      nwln
ask_count:
      PutStr  query_msg      ; prompt for repeat count
      GetInt  CX             ; read repeat count
      nwln
      PutStr  confirm_msg1   ; confirm repeat count
      PutInt  CX             ; by displaying its value
      PutStr  confirm_msg2
      GetCh   response       ; read user response
      nwln
      cmp     response,'y'   ; if 'y', display welcome message
      jne     ask_count      ; otherwise, request repeat count
display_msg:
      PutStr  welcome_msg    ; display welcome message
      PutStr  user_name      ; display the user name
      nwln
      loop    display_msg    ; repeat count times
      .EXIT      
main  ENDP
      END     main
