基础代码

 ; 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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值