实验内容:
(1)将datasg段中每个单词的头一个字母改成大写字母。
datasg段中的数据为:
(2)
将datasg段中每个单词的字母改成大写字母。
datasg段中的数据为:
ibm
dec
dos
vax
(3)
将datasg段中每个单词的前四个字母改成大写字母
datasg段中的数据为:
(1)
变量+常量的方式定位内存地址:
代码如下:
assume cs:codesg,ds:datasgdatasg segmentdb '1. file 'db '2. edit 'db '3. search 'db '4. view ' db '5. options 'db '6. help '
datasg endscodesg segment
start: mov ax,datasgmov ds,axmov bx,0mov cx,6s: mov al,[bx+3]and al,11011111bmov [bx+3],aladd bx,16loop smov ax,4c00hint 21h
codesg ends
end start
(2)
用ds保存cx的值,以达到双层循环的效果。
代码如下:
assume cs:codesg,ds:datasgdatasg segmentdb 'ibm 'db 'dec 'db 'dos 'db 'vax '
datasg endscodesg segment
start: mov ax,datasgmov ds,axmov bx,0mov cx,4s0: mov dx,cxmov si,0mov cx,3s: mov al,[bx+si]and al,11011111bmov [bx+si],alinc siloop s0add bx,16mov cx,dxloop s0mov ax,4c00hint 21hcodesg ends
end start
用内存保存cx
代码如下:
assume cs:codesg,ds:datasgdatasg segmentdb 'ibm 'db 'dec 'db 'dos 'db 'vax 'db 0 ;定义一个字,用来存放cx
datasg endscodesg segment
start: mov ax,datasgmov ds,axmov bx,0mov cx,4s0: mov ds:[40h],cxmov si,0mov cx,3s: mov al,[bx+si]and al,11011111bmov [bx+si],alinc siloop s0add bx,16mov cx,ds:[40h]loop s0mov ax,4c00hint 21hcodesg ends
end start
最好的处理方式 - 栈:
代码如下:
assume cs:codesg,ds:datasg,ss:stacksgdatasg segmentdb 'ibm 'db 'dec 'db 'dos 'db 'vax '
datasg endsstacksg segmentdw 0,0,0,0,0,0,0,0
stacksg endscodesg segment
start: mov ax,stacksgmov ss,axmov sp,16mov ax,datasgmov ds,axmov bx,0mov cx,4s0: push cxmov si,0mov cx,3s: mov al,[bx+si]and al,11011111bmov [bx+si],alinc siloop sadd bx,16pop cxloop s0mov ax,4c00hint 21h
codesg ends
end start
(3)
代码如下:
assume ds:datasg,ss:stacksg,cs:codesgstacksg segmentdw 0,0,0,0,0,0,0,0
stacksg endsdatasg segmentdb '1. display......'db '2. brows........'db '3. replace......'db '4. modify.......'
datasg endscodesg segment
start: mov ax,datasgmov ds,axmov ax,stacksgmov ss,axmov sp,16mov bx,0mov cx,4s: push cxmov cx,4mov si,0s0:mov al,[bx+si+3]and al,11011111bmov [bx+si+3],alinc siloop s0add bx,16pop cxloop smov ax,4c00hint 21h
codesg ends
end start