基础代码

来源:互联网 发布:excel表格数据 编辑:程序博客网 时间:2024/06/05 20:26

 ; Turbo Assembler    Copyright (c) 1988, 1991 By Borland International, Inc.

; HELLO2.ASM - Editted version of HELLO.ASM.
;              Display greeting after accepting input.

; From the Turbo Assembler Users Guide - Getting started

   DOSSEG
   .MODEL  SMALL
   .STACK  100h
   .DATA
TimePrompt DB 'Is it after 12 noon (Y/N)?$'
GoodMorningMessage  LABEL  BYTE
   DB  13,10,'Good morning, world!',13,10,'$'
GoodAfternoonMessage  LABEL  BYTE
   DB  13,10,'Good afternoon, world!',13,10,'$'
   .CODE
   MOV  AX,@data
   MOV  DS,AX                                ;set DS to point to the data segment
   MOV  DX,OFFSET TimePrompt                 ;point to the time prompt
   MOV  AH,9                                 ;DOS print string function #
   INT  21h                                  ;display the time prompt
   MOV  AH,1                                 ;DOS get character function #
   INT  21h                                  ;get a single-character response
   CMP  AL,'y'                               ;typed lowercase y for after noon?
   JZ   IsAfternoon                          ;yes, it's after noon
   CMP  AL,'Y'                               ;typed uppercase Y for after noon?
   JNZ  IsMorning                            ;no, it's before noon
IsAfternoon:
   MOV  DX,OFFSET GoodAfternoonMessage       ;point to the afternoon greeting
   JMP  DisplayGreeting
IsMorning:
   MOV  DX,OFFSET GoodMorningMessage         ;point to the before noon greeting
DisplayGreeting:
   MOV  AH,9                                 ;DOS print string function #
   INT  21h                                  ;display the appropriate greeting
   MOV  AH,4ch                               ;DOS terminate program function #
   INT  21h                                  ;terminate the program
   END