ASM 代码骨架,示例

	page 60,132
TITLE 简化的伪段操作
;------------------------------------
		.MODEL 	SMALL
		.STACK	64
		.DATA
FLDD	DW		215
FLDE	DW		125
FLDF	DW		?
;------------------------------------
		.CODE
MAIN	PROC	FAR
		MOV		AX,@data
		MOV		DS,AX
		
		MOV		AX,FLDD
		ADD		AX,FLDE
		MOV 	FLDF,AX
		
		MOV		AX,4C00H
		INT 	21H

MAIN	ENDP		;过程结束
		END MAIN	;程序结束

  

以下是未简化的:

	page 60,132
TITLE  104asm1 (EXE) move and add operation
;------------------------------------------
STACK SEGMENT PARA STACK 'Stack'
	DW 32 DUP(0)
STACK ENDS
;------------------------------------------
DATASEG SEGMENT PARA 'Data'
FLDD 	DW 		215
FLDE 	DW		125
FLDF	DW		?
DATASEG ENDS
;------------------------------------------
CODESEG SEGMENT PARA 'Code'
MAIN 	PROC 	FAR
		ASSUME SS:STACK,DS:DATASEG,CS:CODESEG
		MOV		AX,DATASEG
		MOV		DS,AX
		MOV 	AX,FLDD
		ADD 	AX,FLDE
		MOV 	FLDF,AX
		
		MOV 	AX,4C00H	;处理结束
		INT 	21H	
		
MAIN 	ENDP			;过程结束
CODESEG	ENDS			;段结束
		END MAIN		;程序结束

  

保护模式下的初始化

.386 or .486 ;指令集
.MODEL FLAT,STDCALL ;内存模型
.STACK
.DATA ;承受后是所有数据
.CODE ;随后是指令代码
END

 

posted @ 2012-04-10 15:23  庚武  Views(539)  Comments(0Edit  收藏  举报