微机原理实验报告程序

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

实验2—1
(1)定义字
DA TA SEGMENT
A DW 855CH
B DW 0AB43H
NUM DW ?
DA TA ENDS
CODE SEGMENT Assume CS:CODE,DS:DATA START:MOV AX,DATA
MOV DS,AX
MOV AX,A
MOV BX,B
ADD AX,BX
MOV NUM,AX
MOV AH,4CH
INT 21H
CODE ENDS
END START
实验2—1
直接寻址
DA TA SEGMENT
A D
B 5CH,85H
B DB 43H,0ABH
NUM DW ?
DA TA ENDS
CODE SEGMENT Assume CS:CODE,DS:DATA START:MOV AX,DATA
MOV DS,AX
MOV AX,A
MOV BX,B
ADD AX,BX
MOV NUM,AX
MOV AH,4CH
INT 21H
CODE ENDS
END START
实验2—3
拆字
DA TA SEGMENT
ORG 1000H
NUM DW 1234H
ORG 4000H
A D
B ?
B DB ?
DA TA ENDS
CODE SEGMENT
Assume CS:CODE,DS:DA TA
START:
MOV AX,NUM
MOV A,AH
MOV B,AL
MOV AH,4CH
INT 21H
CODE ENDS
END START
实验3—3
DA TA SEGMENT
INFOR1 DB 0AH,0DH, 'Please Press any key to input a letter:$' ;0AH为换行,0DH为回车INFOR2 DB 0AH,0DH, 'You Input a lowercase letter! $'
INFOR3 DB 0AH,0DH, 'You input a uppercase letter! $'
INFOR4 DB 0AH,0DH, 'You input a digit! $'
INFOR5 DB 0ah,0dh, 'You input other letter! $'
DA TA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
MOV DX,OFFSET INFOR1
MOV AH,09H ;输出字符串INFOR1
;MOV AH,1
INT 21H
MOV AH,01H ;从键盘输入一个字符
INT 21H
CMP AL, '0'
JB OTHER ;小于0,为其他字符
CMP AL, '9'
JBE DIGIT ;大于等于0,小于等于9,为数字
CMP AL, 'A'
JB OTHER
CMP AL, 'Z'
JBE UPPER
CMP AL, 'a'
JB OTHER
CMP AL, 'z'
JBE LOWER
JMP PEND
LOWER: MOV DX,OFFSET INFOR2 MOV AH,09H
INT 21H
JMP PEND
UPPER: MOV DX,OFFSET INFOR3 MOV AH,09H
INT 21H
JMP PEND
DIGIT: MOV DX,OFFSET INFOR4
MOV AH,09H
INT 21H
JMP PEND
OTHER: MOV DX,OFFSET INFOR5 MOV AH,09H
INT 21H
JMP PEND
PEND: MOV AH,4CH
INT 21H
CODE ENDS
END START
实验3—1
DA TA SEGMENT
STRING DB 'I am a student'
LEN EQU $-STRING
DA TA ENDS
CODE SEGMENT
Assume CS:CODE,DS:DATA START:MOV AX,DATA
MOV DS,AX
MOV BX,OFFSET STRING
MOV CL,LEN
NEXT:MOV AL,[BX]
CMP AL,'a'
JB LOP
CMP AL,'z'
JA LOP
SUB AL,20H
MOV [BX],AL
LOP:INC BX
DEC CL
JNZ NEXT
MOV AH,4CH
INT 21H
CODE ENDS
END START
实验4—1
DA TA SEGMENT
A D
B '1234567890'
N EQU $-A
B DB N DUP(?)
DA TA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DA TA START:
MOV AX,DATA
MOV DS,AX
MOV ES,AX
LEA SI,A
LEA DI,B
ADD DI,N
MOV CX,N
MOVE:MOV AL,[SI]
MOV ES:[DI],AL
INC SI
DEC DI
LOOP MOVE
MOV AH,4CH
INT 21H
CODE ENDS
END START
实验4—2
DA TA SEGMENT
ORG 1000H
DB 100 DUP('A')
ORG 1050H
DB 100 DUP('B')
DA TA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA,ES:DATA START: MOV AX,DATA
MOV DS,AX
;MOV ES,AX
MOV SI,1000H
MOV DI,1050H
MOV CX,100
AGAIN: MOV AL,[SI]
MOV [DI],AL
INC SI
INC DI
LOOP AGAIN
MOV AH,4CH
INT 21H
CODE ENDS
END START
实验4—3
DA TA SEGMENT
BUF DW 1,2,3,4,5,6,7,8,9,0
MAX DW 0
DA TA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA START: MOV AX,DATA
MOV DS,AX
MOV SI,OFFSET BUF
MOV CX,10
AGAIN: MOV AX,[SI]
CMP AX,MAX
JB NEXT
MOV MAX,AX
NEXT: INC SI
INC SI
LOOP AGAIN
MOV AH,4CH
INT 21H
CODE ENDS
END START
实验6—1
DA TA SEGMENT
STR DB 'Please input a character:$'
STR1 DB 0ah,0dh
STR3 DB ?,'H$'
DA TA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DA TA
START:MOV AX,DATA
MOV DS,AX
MOV DX,OFFSET STR
MOV AH,09H
INT 21H
MOV AH,01H
INT 21H
MOV STR1,AL
MOV DX,OFFSET STR1
MOV AH,09H
INT 21H
MOV AH,4CH
INT 21H
CODE ENDS
END START
实验6—2
DA TA SEGMENT
STR1 DB 0dh,0ah,'Please input a character:$'
STR2 DB 0dh,0ah,'You input a number!$'
STR3 DB 0dh,0ah,'The character you input is not a number!$' DA TA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DA TA
START:MOV AX,DATA
MOV DS,AX
MOV DX,OFFSET STR1
MOV AH,09H
MOV AH,01H
INT 21H
CMP AL,30H
JB NEXT1
CMP AL,39H
JA NEXT1
MOV DX,OFFSET STR2
MOV AH,09H
INT 21H
JMP NEXT2
NEXT1:MOV DX,OFFSET STR3 MOV AH,09H
INT 21H
NEXT2:MOV AH,4CH
INT 21H
CODE ENDS
END START
实验6—3
DA TA SEGMENT
info1 db 0dh,0ah, 'input string:$' info2 db 0dh,0ah, 'output string:$' STR DB 20 DUP(?)
DA TA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DA TA START:MOV AX,DATA
MOV DS,AX
MOV DX,OFFSET STR
ADD SI,10
MOV [SI],BYTE PTR '$'
MOV DX,OFFSET info1
MOV AH,09H
INT 21H
MOV CX,10
AGAIN:MOV AH,01H
INT 21H
DEC SI
MOV [SI],AL
LOOP AGAIN
MOV DX,OFFSET STR
MOV AH,09H
MOV AH,01H
INT 21H
MOV AH,4CH
INT 21H
CODE ENDS
END START
实验6—1
;输入字符后回车
CODE SEGMENT
ASSUME CS:CODE,DS:CODE START:MOV AX,CODE
MOV DS,AX
MOV AH,01H
INT 21H
MOV DL,0AH
INT 21H
PUSH AX
AND AX,00FFH
MOV CL,4
SHR AL,CL
ADD AL,30H
MOV DL,AL
MOV AH,02H
INT 21H
POP AX
AND AL,0FH
CMP AL,0AH
JNC NEXT
ADD AL,30H
JMP final
NEXT:ADD AL,37H
final:MOV DL,AL
MOV AH,02H
INT 21H
MOV DL,'H'
INT 21H
MOV AH,4CH
INT 21H
CODE ENDS
END START
实验6—3
DATA SEGMENT
info1 DB 0dh,0ah,'input string:$' info2 DB 0dh,0ah,'output string:$' STR DB 0Bh,0,20 dup(?)
n EQU $-STR
DB '$'
DATA ENDS
CODE SEGMENT
ASSUME cs:code,ds:data START:mov ax,DATA
mov DS,ax
lea DX,info1
mov AH,09H
INT 21H
lea DX,STR
mov AH,0AH
INT 21H
MOV CX,0
lea SI,STR
mov DI,SI
add DI,n-1
INC SI
INC SI
number:MOV BL,[SI]
CMP BL,0DH
JZ NEXT
INC CX
INC SI
JMP number
NEXT:lea SI,STR
INC SI
INC SI
again:mov bl,[SI]
mov [DI],bl
INC SI
DEC DI
loop again
lea DX,info2
mov AH,09H
INT 21H
INC DI
mov DX,DI
mov AH,09H
INT 21H
mov AH,4ch
INT 21h CODE ends
end start
code segment assume cs:code start:
mov ah,1
int 21h
cmp al,1bh
jz tj
mov bl,al
mov ch,2
rotate:
mov cl,4
rol bl,cl
mov al,bl
and al,0fh
add al,30h
cmp al,3ah
jl printit
add al,7h
printit:
mov dl,al
mov ah,2
int 21h
dec ch
jnz rotate
jmp start
tj:
mov ax,4c00h
int 21h
code ends
end start。

相关文档
最新文档