首页 > 代码库 > 微机接口技术与汇编语言上机实验报告_汇编初步(intel8086)

微机接口技术与汇编语言上机实验报告_汇编初步(intel8086)

实验环境:intel x386

 

一。要求:将3000H单元开始置数为00H-0FH

SSTACK	SEGMENT STACK
	  	DW 32 DUP(?)
SSTACK	ENDS

CODE	SEGMENT
		ASSUME CS:CODE, SS:SSTACK
START:	PUSH DS
	XOR AX, AX
	MOV DS, AX
	MOV SI, 3000H
	MOV CX, 16
AA1:	MOV [SI], AL
	INC SI
	INC AL
	LOOP AA1 		;CX == 0? NEXT():AA1
	MOV AX, 4C00H	;AH = 4C STOP CUR, RETURN
	INT 21H
CODE 	ENDS
	END START


 二。要求:将3500H后8位置入3600H开始的8位

有两种解法

1.

SSTACK 	SEGMENT STACK
		DW 32 DUP(?)
SSTACK 	ENDS

CODE	SEGMENT
		ASSUME CS:CODE, SS:SSTACK
START:	PUSH DS
	XOR AX, AX		;SET AX = 0000H
	MOV DS, AX
	CLD				;CLOSE INTERUPTE
	MOV SI, 3500H
	MOV BX, 3600H
	MOV CX, 8		;FOR LOOP
AA1:	MOV AL, [SI]		;REP MOVSB 	;DS:[SI] -> ES:[DI], SI+1, DI+1
	MOV [BX], AL
	INC SI
	INC BX
	LOOP AA1		;CX == 0 ? NEXT() : AA1
	MOV AX, 4C00H
	INT 21H
CODE 	ENDS
	END START

2.

SSTACK 	SEGMENT STACK
		DW 32 DUP(?)
SSTACK 	ENDS

CODE	SEGMENT
		ASSUME CS:CODE, SS:SSTACK
START:	PUSH DS
	XOR AX, AX		;SET AX = 0000H
	MOV DS, AX
	CLD			;CLOSE INTERUPTE
	MOV ES, AX
	MOV SI, 3500H
	MOV DI, 3600H
	MOV CX, 8		;FOR LOOP
	REP	MOVSB 		;DS:[SI] -> ES:[DI], SI+1, DI+1
	MOV AX, 4C00H
	INT 21H
CODE 	ENDS
		END START


 

 三。要求:将数据段中的str1赋给str2

 

DATA SEGMENT
	STR1 DB ‘ABCDEFGHIJKLN‘
	COUNT EQU $-STR1				;$的值表示count的偏移地址, 而str1是BUF所占用的字节数
	STR2 DB COUNT DUP(0)
DATA ENDS
SSTACK SEGMENT STACK				;!!--DEF--!汇编程序发现这是堆栈段,执行的时候会直接使SSTACK -> SS
		DB 200H DUP(0)
SSTACK ENDS

CODE SEGMENT
	ASSUME DS:DATA, ES:DATA, SS:SSTACK, CS:CODE	
	;DATA(DATA SEGMENT)
	;ES(EXTRA DATA SEGMENT)
	;SSTACK -> SS(STACK SEGMENT)
	;CODE -> CS(CODE SEGMENT)
START:
	MOV	AX, DATA
	MOV DS, AX
	MOV ES, AX
	LEA SI, STR1
	LEA DI, STR2		
	MOV CX, COUNT
	CLD							;Direction Flag to 0 (0 -> DF)
LP1:	MOVSB						;DS:[SI] -> ES:[DI], SI++, DI++ 
	DEC CX						;
	JNZ LP1 					;THREE SENTENCE == REP MOVESB, CX FOR COUNT
	MOV AH, 4CH					;MOV AX, 4C00H
	INT 21H
CODE	ENDS
	END START                              
		                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       


 二。要求:将3500H后8位置入3600H开始的8位

 


 四。要求:使用DOS接口输出一段字符串

DATA SEGMENT
	MESSAGE DB ‘please input your name!‘ , 0DH, 0AH, ‘$‘
DATA ENDS
CODE SEGMENT
START:	MOV AH, 09H
	MOV DX, SEG MESSAGE
	MOV DS, DX
	MOV DX, OFFSET MESSAGE
	INT 21H
        ...
CODE ENDS