5.1 输出hw,求数组最大、小值,字符串转大、小写】
1. 注释
1.1 单行注释
;注释内容
1.2 多行注释
comment*
注释内容
*comment
2. 输出“hello,world”
- 头文件,命名数组定义字符串,结束代码,直接在c:下运行exe文件
- 添加“‘$’”截止符来阻止下面代码的输出
- 10是换行的ASCII码
- 32是空格的ASCII码
3. 字符串转大小写
3.1 字符串转大写
assume cs:code,ds:data,ss:stack
data segment
str db 'HeLlo WoRID'
data ends
stack segment
db 10 dup (0)
stack ends
code segment
start:
mov ax,data
mov ds,ax
mov bx,0
mov cx,11
s:
mov al,[bx]
and al,1011111b //转小写or al,100000b
mov [bx],al
inc bx
loop s
mov ah,4ch
int 21h
code ends
end start
comment*
c++
for(int i =0;i<str.size()++)
if(小写)转大写
*comment
3.2 字符串转小写
- 只需要将目标位置改为如后就行
or al,100000b
3.3 直接输出内容
assume cs:code,ds:data,ss:stack
data segment
str db 'HeLlo WoRID','$'
data ends
stack segment
db 10 dup (0)
stack ends
code segment
start:
mov ax,data
mov ds,ax
mov bx,0
mov cx,11
s:
mov al,[bx]
or al,100000b
mov [bx],al
inc bx
loop s
lea dx,str //中断指令
mov ah,9
int 21h
mov ah,4ch
int 21h
code ends
end start
comment*
c++
for(int i =0;i<str.size()++)
if(小写)转大写
*comment
4. 求数组最大、小值
4.1 求数组最大值
assume cs:code,ds:data,ss:stack
data segment
str db 'HeLlo WoRID','$'
data ends
stack segment
db 10 dup (0)
stack ends
code segment
start:
mov ax,data
mov ds,ax
mov bx,0
mov cx,11
mov ah,0
s:
mov al,[bx]
cmp ah,al
jnb s1
mov ah,al
s1:
mov [bx],al
inc bx
loop s
mov ah,4ch
int 21h
code ends
end start
comment*
c++
数组当中的最大值最小值
int res = 0
for (int i = 0;i < str.size();i++)if (s[i] > res) res = s[i];
return res
求最大值
*comment
4.2 求数组最小值
assume cs:code,ds:data,ss:stack
data segment
str db 'HeLlo WoRID','$'
data ends
stack segment
db 10 dup (0)
stack ends
code segment
start:
mov ax,data
mov ds,ax
mov bx,0
mov cx,11
mov ah,0ffh
s:
mov al,[bx]
cmp ah,al
jna s1
mov ah,al
s1:
mov [bx],al
inc bx
loop s
mov ah,4ch
int 21h
code ends
end start
comment*
c++
数组当中的最大值最小值
int res = ff
for (int i = 0;i < str.size();i++)if (res > s[i]) res = s[i];
return res
求最小值
*comment