zoukankan      html  css  js  c++  java
  • 7.4 在codesg中填写代码,将datasg中的第一个字符串转化为大写,第二个字符串转化为小写

    assume             cs:codesg,ds:datasg
    datasg             segment
    db                 'BaSiC'
    db                 'iNfOrMaTiOn'
    datasg              ends
    codesg              segment
    start:                   mov           ax,datasg
                             mov           ds,ax                                   ;设置ds指向datasg段
                             mov           bx,0                                    ;设置(bx)=0,ds:bx指向‘BaSiC’的第一个字母
                             mov           cx,5                                    ;设置循环次数5,因为'BaSiC'有5个字母
    s:                       mov           al,[bx]                                 ;将ASCLL码从ds:bx所指向的单元中取出
                             and           al,11011111B                            ;将al中的ASCLL码的第5位置为0,变为大写字母
                             mov           [bx],al                                 ;将转变后的ASCLL码写回原单元
                             inc           bx                                      ;(bx)加1,ds:bx指向下一个字母
                             loop          s
                             mov           bx,5                                    ;设置(bx)=5, ds:bx指向'iNfOrMaTiOn'的第一个字母
                             mov           cx,11                                   ;设置循环次数11
    s0:                      mov           al,[bx]
                             or            al,00100000B                            ;将al中的ASCLL码的第5位置为1,变为小写字母
                             mov           [bx],al
                             inc           bx
                             loop          s0
                             mov           ax,4c00H
                             int           21H
    codesg                   ends
                             end           start
    

    方法二:

    assume             cs:codesg,ds:datasg
    datasg             segment
    db                    'BaSiC'
    db                    'MinIX'
    datasg               ends
    codesg               segment
    start:                   mov             ax,datasg
                             mov             ds,ax
                             mov             bx,0
                             mov             cx,5
    s:                       mov             al,[bx]                ;定位第一个字符串中的字符
                             and             al,11011111b
                             mov             [bx],al
                             mov             al,[5+bx]            ;定位第二个字符串中的字符
                             or              al,00100000b
                             mov             [5+bx],al
                             inc             bx
                             loop            s
                             mov             ax,4c00H
                             int             21H
    codesg                   ends
                             end             start
    

      

     

    天晴了,起飞吧
  • 相关阅读:
    四十一.redis主从复制 RDB/AOF持久化 数据类型
    四十.创建Redis集群 管理集群
    三十九.NoSQL概述 部署Redis服务 、 部署LNMP+Redis
    三十八. 分库分表概述 配置mycat
    520D
    442C
    LA4788
    LA3276
    LA4122
    zoj3478
  • 原文地址:https://www.cnblogs.com/jianqiao123/p/12251889.html
Copyright © 2011-2022 走看看