王爽《汇编语言》课后作业( P160(2) )

来源:互联网 发布:百度seo是什么 编辑:程序博客网 时间:2024/05/16 02:08

编程:将datasg段中每个单词的前四个字母改为大写字母。


assume cs:codesg,ss:stacksg,ds:datasg
stacksg segment
  dw 0,0,0,0,0,0,0,0
stacksg ends


datasg segment
   db '1. display      '
   db '2. brows        '
   db '3. replace      '
   db '4. modify       '
datasg ends


codesg segment
   start:
        mov ax,stacksg
        mov ss,ax
        mov sp,0010h
        
        mov ax,datasg
        mov ds,ax
        
        mov si,0
        mov bx,0
        
        mov cx,4h
      s:push cx
        mov si,0
        
        mov cx,4
     s0:mov al,[bx+3+si]
        and al,11011111b
        mov [bx+3+si],al
        inc si
        loop s0
        
        pop cx
        add bx,10h
        loop s
        
  mov ax,4c00h
  int 21h

codesg ends
end start

/*上面蓝色代码为本题思路,用到了嵌套循环,类似与数组的东西 

 * 说明一下bx是外层循环s的变量,si是内层循环的变量,这两个变量

 * 相当于c语言中分别是两个for循环中的递增变量

 */

运行结果如下:

    

原创粉丝点击