⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test1.asm

📁 Embedded magazine source code. this is the source code in the year 1989
💻 ASM
字号:
	page	,132
	TITLE	test1.asm
	SUBTTL	/// First romable program from .EXE file ///
;-----------------------------------------------------------
;  Self-contained test program to be converted to ROM.
;  Assemble with the "/Mx" switch.
;  Link with the "/DOSSEG" linker switch.
;-----------------------------------------------------------
_TEXT	SEGMENT  WORD PUBLIC 'CODE'
_TEXT	ENDS
T_TEXT	SEGMENT  WORD PUBLIC 'CODE'
T_TEXT	ENDS
C_ETEXT	SEGMENT  PARA PUBLIC 'ENDCODE'
	db	16 dup(?)		; EXE2ROM puts initial SP here.
C_ETEXT	ENDS
_DATA	SEGMENT  WORD PUBLIC 'DATA'
_DATA	ENDS
STACK	SEGMENT  PARA STACK 'STACK'	; Dummy Stack, not really used.
STACK	ENDS

DGROUP	GROUP	_DATA, STACK

	ASSUME  CS: _TEXT, DS: DGROUP, SS: DGROUP
	extrn	_end:byte
_DATA	SEGMENT
test_data dw	7654h
	  dw	SEG C_ETEXT	; **** for testing segment relocation
	  dw	SEG test_data	; **** for testing segment relocation
_DATA	ENDS

_TEXT	SEGMENT
test_code	proc	near
	cli
	cld
	mov	ax,SEG DGROUP
	mov	ss,ax		; SS = DGROUP
	mov	ds,ax		; DS = DGROUP
	mov	ax,SEG C_ETEXT
	mov	es,ax		; ES = C_ETEXT
	mov	sp,word ptr es:[0]	; EXE2ROM supplies SP here
	call	_datainit
; Application test code goes here
	jmp	short test_code

_datainit:
	push	ds
	pop	es		; ES = DS
	mov	di,0		; es:[di] is beginning of RAM data segment
;---------------------------------------
;  Pre-clear the data area from es:0 to es:(offset DGROUP:_end)
;  This includes both _DATA and _BSS.
;---------------------------------------
	mov	cx,offset DGROUP: _end
	xor	ax,ax
	rep	stosb
	mov	ax,SEG C_ETEXT
	inc	ax		; ax = SEG of crunched data table
	mov	es,ax
	mov	si,0		; es:[si] = top of initialized data table
;--------------------------------------
;  The ROM table of initialized data has the following format:
;	word	<N=count of words in this block.  0=end of list>
;	word	<offset (into DS) where this block goes>
;	word....word	<N words that comprise the block>
;--------------------------------------
datainit0:
	mov	cx,es:[si]	; get a word count
	add	si,2
	jcxz	datainit_done
	mov	bx,es:[si]	; get offset of block destination
	add	si,2
datainit2:
	mov	ax,es:[si]	; fetch a data word of the block
	mov	[bx],ax		; place it in RAM
	add	si,2
	add	bx,2
	loop	datainit2	; do it CX times
	jmp	short datainit0	; on to the next block
	mov	ax,SEG test_data ; **** for testing segment relocation
datainit_done:
	push	ss
	pop	es
	ret

T_TEXT	SEGMENT
;---------------------------------------
;  This segment is different from _TEXT.  It is here to test out
;  segment relocation in the FAR call.
;---------------------------------------
	ASSUME	CS:T_TEXT
farproc	proc	far
	ret
farproc	endp
T_TEXT	ENDS

	ASSUME	CS:_TEXT
;              (back to _TEXT segment)
	call	farproc		; **** for testing segment relocation ****
test_code	endp

_TEXT		ENDS
	end	test_code

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -