home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c081_11 / 9.ddi / CHAPXMPL.ZIP / HELLO2.ASM < prev    next >
Encoding:
Assembly Source File  |  1991-02-13  |  1.8 KB  |  40 lines

  1. ; Turbo Assembler    Copyright (c) 1988, 1991 By Borland International, Inc.
  2.  
  3. ; HELLO2.ASM - Editted version of HELLO.ASM.
  4. ;              Display greeting after accepting input.
  5.  
  6. ; From the Turbo Assembler Users Guide - Getting started
  7.  
  8.    DOSSEG
  9.    .MODEL  SMALL
  10.    .STACK  100h
  11.    .DATA
  12. TimePrompt DB 'Is it after 12 noon (Y/N)?$'
  13. GoodMorningMessage  LABEL  BYTE
  14.    DB  13,10,'Good morning, world!',13,10,'$'
  15. GoodAfternoonMessage  LABEL  BYTE
  16.    DB  13,10,'Good afternoon, world!',13,10,'$'
  17.    .CODE
  18.    mov  ax,@data
  19.    mov  ds,ax                                ;set DS to point to the data segment
  20.    mov  dx,OFFSET TimePrompt                 ;point to the time prompt
  21.    mov  ah,9                                 ;DOS print string function #
  22.    int  21h                                  ;display the time prompt
  23.    mov  ah,1                                 ;DOS get character function #
  24.    int  21h                                  ;get a single-character response
  25.    cmp  al,'y'                               ;typed lowercase y for after noon?
  26.    jz   IsAfternoon                          ;yes, it's after noon
  27.    cmp  al,'Y'                               ;typed uppercase Y for after noon?
  28.    jnz  IsMorning                            ;no, it's before noon
  29. IsAfternoon:
  30.    mov  dx,OFFSET GoodAfternoonMessage       ;point to the afternoon greeting
  31.    jmp  DisplayGreeting
  32. IsMorning:
  33.    mov  dx,OFFSET GoodMorningMessage         ;point to the before noon greeting
  34. DisplayGreeting:
  35.    mov  ah,9                                 ;DOS print string function #
  36.    int  21h                                  ;display the appropriate greeting
  37.    mov  ah,4ch                               ;DOS terminate program function #
  38.    int  21h                                  ;terminate the program
  39.    END
  40.