使用汇编编程,可以直接访问内存中的数据,对数据进行相关操作,现在需要通过汇编指令and,or对字符串数据进行大小写转换。如下例,将BaSiC转换成大写,将iNforMaTiOn转换成小写。
例子:
- assume cs:codesg,ds:datasg
-
- datasg segment
- db 'BaSiC'
- db 'iNforMaTiOn'
- datasg ends
-
- codesg segment
- start: mov ax,datasg
- mov ds,ax
-
- mov cx,5
- mov bx,0
-
- s1: mov al,ds:[bx]
- and al,11011111b
- mov ds:[bx],al
- inc bx
- loop s1
-
- mov cx,11
- mov bx,5
-
- s2: mov al,ds:[bx]
- or al,00100000b
- mov ds:[bx],al
- inc bx
- loop s2
-
- mov ax,4c00h
- int 21h
-
- codesg ends
-
- end start
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持城东书院。