|
实验2-分支程序实验
1.已知X、Y、Z、MAX为16位的带符号数,求三个数中最大值,结果存入MAX单元。- stack segment stack
- db 50 dup(0)
- stack ends
- data segment
- num db 10101010b, 10, 6FH
- max db ?
- data ends
- code segment
- assume cs:code, ds:data, ss:stack
- start: mov ax,data
- mov al,num
- cmp al,num[1]
- JGE next1
- mov al,num[1]
- next1:cmp al,num[2]
- JGE next2
- mov al,num[2]
- next2:mov max,al
- mov ax,4c00h
- int 21h
- code ends
- end start
复制代码
2.编写程序计算Y的值,当X<0时,Y=-1;当X=0时,Y=0,当X>0时,Y=1,其中,输入数据X和输出数据Y均在数据段中定义,且皆为字节变量。- data segment
- mems db 06H
- memd db ?
- data ends
- code segment
- assume cs:code, ds:data
- start: mov ax,data
- mov ds,ax
- mov al,mems
- cmp al,0
- JGE next
- mov al,-1
- JMP done
- next: JE done
- mov al,1
- done: mov ax,4c00H
- int 21H
- code ends
- end start
复制代码
实验3-循环程序实验
1.求10个学生成绩中的最高成绩,结果存入MAX字节单元中,已知成绩为字节型。- stack segment stack
- db 200 dup(0)
- stack ends
- data segment
- hui db 00,11,22,33,44,55,66,77,88,99
- max db ?
- data ends
- code segment
- assume cs:code,ds:data,ss:stack
- start: mov ax,data
- mov ds,ax
- mov cx,10
- mov bx,0
- mov al,hui[bx]
- again:inc bx
- CMP hui[bx],al
- JBE next
- XCHG al,hui[bx]
- next:loop again
- mov max,al
- mov ah,4ch
- int 21h
- code ends
- end start
复制代码
2.编写程序用来分别统计一组数中奇数和偶数的个数,数据和结果均在数据段中。- data segment
- dw 1,2,3,4,5,6,7,8,9,10
- data ends
- code segment
- assume cs:code,ds:data
- start: mov ax,data
- mov ds,ax
- mov si,0
- mov dx,0
- mov cx,10
- mov bl,2
- S:mov ah,0
- mov al,[si]
- div bl
- CMP ah,0
- JE seven
- suneven:inc dl
- JMP short OK
- seven:inc dh
- OK:add si,2
- loop s
- mov ax,4c00h
- int 21h
- code ends
- end start
复制代码
实验四:综合程序设计实验
1.编写一个汇编程序,要求对键盘输入的大写字母用小写字母显示出来,键盘输入的小写字母用大写字母显示出来。- CODE SEGMENT
- MAIN PROC FAR
- ASSUME CS:CODE
- START:PUSH DS
- SUB AX,AX
- PUSH AX
- A1:MOV AH,1
- INT 21H
- CMP AL,' '
- JZ EXT0
- CMP AL,'A'
- JB A1
- CMP AL,'Z'
- JA A2
- ADD AL,20H
- MOV AH,2
- MOV DL,AL
- INT 21H
- JMP A1
- A2:SUB AL,20H
- MOV AH,2
- MOV DL,AL
- INT 21H
- JMP A1
- EXT0:RET
- MAIN ENDP
- CODE ENDS
- END START
复制代码
2.编写一个汇编程序,使得从键盘上输入十个以内的字符,以输入空格结束,然后按数字、字母和其它符号三类统计各自的个数,在屏幕上依次显示出统计结果。- STACK SEGMENT STACK
- DB 200 DUP(0)
- STACK ENDS
- DATA SEGMENT
- X DB '0'
- DATA ENDS
- CODE SEGMENT
- ASSUME CS:CODE,DS:DATA,SS:STACK
- START: MOV AX,DATA
- MOV DS,AX
- SUB AX,AX
- MOV BH,0
- MOV BL,0
- MOV DH,0
- MOV CX,10
- AA1: CMP CX,0
- JZ STOP
- MOV AH,1
- INT 21H
- CMP AL,20H
- JB STOP
- CMP AL,'0'
- JB CC2
- CMP AL,'9'
- JA CC1
- INC BH
- JMP NEXT1
- CC1: CMP AL,'A'
- JB CC2
- CMP AL,'Z'
- JB NEXT
- CMP AL,'a'
- JB CC2
- CMP AL,'z'
- JA CC2
- NEXT: INC BL
- JMP NEXT1
- CC2: INC DH
- NEXT1: LOOP AA1
- STOP: MOV AH,2
- MOV DL,BH
- ADD DL,X
- INT 21H
- MOV AH,2
- MOV DL,BL
- ADD DL,X
- INT 21H
- MOV AH,2
- MOV DL,DH
- ADD DL,X
- INT 21H
- MOV AX,4C00H
- INT 21H
- CODE ENDS
- END START
复制代码
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?立即注册
×
|