5.1 输出hw,求数组最大、小值,字符串转大、小写

5.1 输出hw,求数组最大、小值,字符串转大、小写】

1. 注释

1.1 单行注释

;注释内容

1.2 多行注释

comment*
注释内容
*comment

2. 输出“hello,world”

  • 头文件,命名数组定义字符串,结束代码,直接在c:下运行exe文件
  • 添加“‘$’”截止符来阻止下面代码的输出
  • 10是换行的ASCII码
  • 32是空格的ASCII码

image.png

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

image.png

3.2 字符串转小写

  • 只需要将目标位置改为如后就行or al,100000b

image.png

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

image.png

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

image.png

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

image.png

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值