实验6 实践课程中的程序
还不能发图,就发点比较重要的:7.6大小写:
assume cs:codesg,ds:datasg
datasg segment
db 'BaSiC'
db 'MinIX';这两个在内存中挨着放:“BaSiCMinIX......”
datasg ends
codesg segment
start:
mov ax,datasg
mov ds,ax
mov bx,0
mov cx,5
s1:
mov al,
and al,11011111b;将串中所有字符第6位置0以转化为大写
mov ,al
inc bx
loop s1;正因为两个字符串挨着放所以不将bx置0
mov cx,5
s2:
mov al,
or al,00100000b;将串中所有字符第6位置1以转化为小写
mov ,al
inc bx
loop s2
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,0
and al,11011111b
mov ,al
mov al,5
or al,00100000b
mov 5,al
inc bx
loop s
mov ax,4c00H
int 21h
codesg ends
end start
问题7.2
assume cs:codesg,ds:datasg
datasg segment
db 'welcome to masm!'
db '................';两个都有16个bytes
datasg ends
codesg segment
start:
mov ax,datasg
mov ds,ax
mov si,0
mov di,16
mov cx,8
s:
mov ax,
mov ,ax
add si,2
add di,2
loop s
mov ax,4c00H
int 21h
codesg ends
end start 问题7.3改进7.2使代码行数更少
assume cs:codesg,ds:datasg
datasg segment
db 'welcome to masm!'
db '................'
datasg ends
codesg segment
start:
mov ax,datasg
mov ds,ax
mov si,0
mov cx,8
s:
mov ax,
mov 16,ax;刚犯了个蠢, 的写法是错的
add si,2
loop s
mov ax,4c00H
int 21h
codesg ends
end start 问题7.6
assume cs:codesg,ds:datasg
datasg segment
db '1. file '
db '2. edit '
db '3. search '
db '4. view '
db '5. options '
db '6. help '
datasg ends
codesg segment
start:
mov ax,datasg
mov ds,ax
mov bx,0
mov cx,6
s:
mov al,;这里如果al写成ax就会把第5个字符置0也就是"."
and al,11011111b
mov 3,al
add bx,16
loop s
mov ax,4c00H
int 21h
codesg ends
end start 问题7.7和7.8
由于看过视频,上来就写出嵌套的正确形式
assume cs:codesg,ds:datasg
datasg segment
db 'ibm '
db 'dec '
db 'dos '
db 'vax '
datasg ends
codesg segment
start:
mov ax,datasg
mov ds,ax
mov bx,0
mov cx,4
s:
push cx
mov si,0
mov cx,3;由于push过cx了,结尾再pop cx回来,内部cx无论怎么改变都不影响外部循环
s0:
mov al,
and al,11011111b
mov ,al
inc si
loop s0
add bx,16
pop cx
loop s
mov ax,4c00H
int 21h
codesg ends
end start 流风逸雪 发表于 2020-4-4 14:53
问题7.7和7.8
由于看过视频,上来就写出嵌套的正确形式
开头忘记申明栈地址了,以后注意一下吧 问题7.9:
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,16
mov ax,datasg
mov ds,ax
mov bx,0
mov cx,4
s:
push cx
mov si,0
mov cx,4
s0:
mov al,
and al,11011111b
mov ,al
inc si
loop s0
add bx,16
pop cx
loop s
mov ax,4c00H
int 21h
codesg ends
end start
页:
[1]