汇编实验记录
程序员文章站
2024-03-23 22:41:22
...
汇编实验
##汇编实验记录
1.一个双字数据存放在DX和AX寄存器中,编程实现把这个双字左移四位。
代码如下:
DATAS SEGMENT
SHIF DD 12345678H
DATAS ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATAS
START:
MOV AX,DATAS
MOV DS,AX
MOV DX,WORD PTR [SHIF+2]
MOV AX,WORD PTR [SHIF]
MOV CL,4
SHL DX,CL
MOV BL,AH
SHL AX,CL
SHR BL,CL
OR DL,BL
MOV BL,DH
PUSH AX
PUSH DX
MOV DL,BL
MOV CL,4
SHR DL,CL
CMP DL,9
JL L1
ADD DL,7H
L1:ADD DL,30H
MOV AH,2
INT 21H
MOV DL,BL
AND DL,0FH
CMP DL,9
JL L2
ADD DL,7H
L2:ADD DL,30H
INT 21H
POP DX
POP AX
MOV BL,DL
PUSH AX
MOV CL,4
MOV BL,DL
SHR DL,CL
CMP DL,9
JL L3
ADD DL,7H
L3:ADD DL,30H
MOV AH,2
INT 21H
MOV DL,BL
AND DL,0FH
CMP DL,9
JL L4
ADD DL,7H
L4:ADD DL,30H
INT 21H
POP AX
MOV BL,AH
PUSH AX
MOV CL,4
MOV DL,BL
SHR DL,CL
CMP DL,9
JL L5
ADD DL,7H
L5:ADD DL,30H
MOV AH,2
INT 21H
MOV DL,BL
AND DL,0FH
CMP DL,9
JL L6
ADD DL,7H
L6:ADD DL,30H
MOV AH,2
INT 21H
POP AX
MOV BL,AL
MOV DL,AL
MOV CL,4
SHR DL,CL
CMP DL,9
JL L7
ADD DL,7H
L7:ADD DL,30H
MOV AH,2
INT 21H
MOV DL,BL
AND DL,0FH
CMP DL,9
JL L8
ADD DL,7H
L8:ADD DL,30H
INT 21H
MOV AH,4CH
INT 21H
CODE ENDS
END START
运行结果: