BASM.ASM ( File view )

  • By 2010-07-08
  • View(s):19
  • Download(s):2
  • Point(s): 1
				include	basm.inc

	extrn	GetAsmSymbol:far
	extrn	GetAsmLabel:far
	extrn	EmitByte:far
	extrn	EmitFixup:far
	extrn	EmitJump:far
	extrn	EmitFloat:far

	.code	Basm_Text

	Argm	Text,dword,1
	Argm	Len,word,1
	Argm	Options,word,1
	Loc	Dummy,word,1
	Loc	SaveSI,word,1
	Loc	SaveDI,word,1
	Loc	StackLimit,word,1
	Loc	Prefixes,byte,6
	Loc	TextPtr,dword,1
	Loc	SaveTextPtr,word,1
	Loc	Oper1TextPtr,word,1
	Loc	Oper2TextPtr,word,1
	Loc	Mode,byte,1
	Loc	DataLength,byte,1
	Loc	InOpcode,byte,1
	Loc	OperCount,byte,1
	Loc	OpcodePtr,word,1
	Loc	RegNum,word,1
	Loc	Oper2Size,word,1
	Loc	HashValue,byte,1
	Loc	Opcode,byte,1
	Loc	Pending,byte,1
	Loc	RMBits,byte,1
	Loc	FixupAddr,dword,1
	Loc	PureMemFlag,byte,1
	Loc	SizeBit,byte,1
	Loc	DirectionBit,byte,1
	Loc	DefPrefix,byte,1
	Loc	FixupOffs,word,1
	Loc	DwordFixup,byte,1
	Loc	Dummy2,byte,1
	Loc	Value,dword,1
	Loc	Symbol,byte,<size TSymbol>
	Loc	IdentBuf,byte,34
	Loc	UpCaseIdent,byte,34
	Loc	StringBuf,byte,128
	Loc	CodeCount,word,1
	Loc	CodeBuffer,byte,<11*size TCodeBuffer>
	Loc	TempAddr,dword,1
	Loc	Operand1,byte,<size TAsmSymbol>
	Loc	Operand2,byte,<size TAsmSymbol>
	Loc	Operand3,byte,<size TAsmSymbol>
	Loc	Limit,word,1
	Entry	Assemble
	call	Init
	mov	InOpcode,1
	call	GetToken
	mov	ax,TextPtr.offs
	mov	SaveTextPtr,ax
	call	ProcessLabel
	call	ProcessPrefix
	dec	InOpcode
	call	ProcessData
	jz	@@2
	mov	al,';'
	call	CheckToken
	jz	@@1
	call	PutPrefixes
	jmp	short @@2
@@1:	mov	al,tOPCODE
	call	NeedToken
	call	ProcessOperands
	call	ProcessCommand
@@2:	call	Flush
	xor	ax,ax
@Exit:	mov	cx,TextPtr.Offs
	lds	bx,Text
	mov	[bx],cx
	mov	si,SaveSI
	mov	di,SaveDI
	Exit

Init	proc	near
	mov	SaveSI,si
	mov	SaveDI,di
	lea	ax,Limit[-1000]
	mov	StackLimit,ax
	les	bx,Text
	les	bx,es:[bx]
	mov	TextPtr.Offs,bx
	mov	TextPtr.Segm,es
	xor	ax,ax
	mov	SaveTextPtr,ax
	mov	Symbol.sParent.Offs,ax
	mov	Symbol.sParent.Segm,ax
	mov	word ptr Prefixes[0],ax
	mov	CodeCount,ax
	mov	Pending,al
	ret
Init	endp

Flush	proc	near
	lea	si,CodeBuffer
@@1:	sub	CodeCount,size TCodeBuffer
	jc	@@7
	cld
	push	si
	xor	ax,ax
	lodsb
	mov	bx,ax
	lodsb
	mov	cx,ax
	lodsw
	xchg	ax,dx
	lodsw
	xchg	ax,dx
	dec	bx
	js	@@2
	jz	@@3
	dec	bx
	jz	@@4
	push	ax
	mov	ax,cx
	and	cl,0feh
	push	cx
	and	al,1
	push	ax
	call	EmitFloat
	jmp	short @@5
@@2:	push	ax
	call	EmitByte
	jmp	short @@5
@@3:	push	cx dword ptr [si] dx ax
	call	EmitFixup
	jmp	short @@5
@@4:	push	ax dword ptr [si]
	call	EmitJump
@@5:	or	ax,ax
	jz	@@6
	jmp	Error
@@6:	pop	si
	add	si,size TCodeBuffer
	jmp	@@1
@@7:	mov	CodeCount,0
	ret
Flush	endp

ProcessPrefix	proc	near
@@1:	cmp	dh,tOPCODE
	jne	@@3
	mov	bx,OpcodePtr
	cmp	byte ptr cs:[bx],80h+cPrefix
	jne	@@3
	mov	al,cs:[bx+2]
	mov	cx,5
	lea	bx,Prefixes[-1]
@@2:	inc	bx
	cmp	byte ptr [bx],0
	loopne	@@2
	mov	ah,0
	mov	[bx],ax
	call	GetToken
	jmp	@@1
@@3:	ret
ProcessPrefix	endp

ProcessData	proc	near
	cmp	dh,tOPCODE
	jne	@@3
	mov	bx,OpcodePtr
	mov	ax,cs:[bx]
	cmp	al,80h+cDB
	jne	@@3
	mov	DataLength,ah
	cmp	word ptr Prefixes[0],0
	je	@@1
	jmp	SyntaxErr
@@1:	call	GetToken
@@2:	lea	si,Operand1
	call	Expression
	push	dx
	call	ProcessDataElem
	call	Flush
	pop	dx
	mov	al,','
	call	CheckToken
	jnz	@@2
	mov	al,';'
	call	NeedToken
	xor	ax,ax
@@3:	ret
ProcessData	endp

ProcessDataElem	proc	near
	mov	di,si
	mov	ax,[si].aValue.W0
	mov	dx,[si].aValue.W2
	mov	cx,[si].aAddr.Offs
	or	cx,[si].aAddr.Segm
	cmp	DataLength,2
	je	@@5
	ja	@@7
	or	cx,cx
	jz	@@1
	jmp	InvOperErr2
@@1:	lea	si,StringBuf
	cmp	byte ptr [si],0
	jne	@@2
	call	ByteOperand
	jnz	@@13
	jmp	short @@11
@@2:	xor	ax,ax
	cld
	lodsb
	xchg	ax,cx
	jcxz	@@4
@@3:	cld
	lodsb
	push	si cx
	call	@@11
	call	Flush
	pop	cx si
	loop	@@3
@@4:	ret
@@5:	cmp	StringBuf[0],2
	ja	@@14
	call	WordOperand
	jcxz	@@10
	mov	bx,fOffs*256+eFixup
	cmp	[si].aHalf,bh
	jb	@@6
	mov	bh,[si].aHalf
@@6:	xchg	ax,cx
	mov	ax,Operand1.aAddr.Offs
	mov	TempAddr.Offs,ax
	mov	ax,Operand1.aAddr.Segm
	mov	TempAddr.Segm,ax
	jmp	Put
@@7:	cmp	StringBuf[0],4
	ja	@@14
	jcxz	@@8
	xchg	ax,cx
	mov	bx,fPtr*256+eFixup
	cmp	[si].aHalf,0
	je	@@12
	mov	bh,[si].aHalf
	mov	ax,Operand1.aAddr.Offs
	mov	TempAddr.Offs,ax
	mov	ax,Operand1.aAddr.Segm
	mov	TempAddr.Segm,ax
	call	Put
	jmp	short @@9
@@8:	call	@@10
@@9:	xchg	ax,dx
@@10:	call	@@11
	xchg	al,ah
@@11:	mov	bl,eByte
	mov	cx,ax
@@12:	call	Put
	ret
@@13:	jmp	OutOfRangeErr
@@14:	jmp	StringConstErr
ProcessDataElem	endp

ProcessLabel	proc	near
	call	FilterChar
	cmp	al,':'
	jne	@@1
	lea	bx,IdentBuf
	push	ss bx
	call	GetAsmLabel
	jnz	Error
	call	GetToken
	mov	al,':'
	call	NeedToken
@@1:	ret
ProcessLabel	endp

ProcessOperands	proc	near
	mov	OperCount,0
	mov	ax,SaveTextPtr
	mov	Oper1TextPtr,ax
	mov	al,';'
	call	CheckToken
	jnz	@@3
	lea	si,Operand1
	call	Expression
	inc	OperCount
	mov	al,';'
	call	CheckToken
	jnz	@@3
	mov	al,','
	call	NeedToken
	mov	ax,SaveTextPtr
	mov	Oper2TextPtr,ax
	lea	si,Operand2
	call	Expression
	inc	OperCount
	lea	si,Operand1
	lea	di,Operand2
	mov	ax,[si].aSize
	mov	cx,[di].aSize
	mov	Oper2Size,cx
	jcxz	@@1
	or	ax,ax
	jnz	@@2
	xchg	cx,[si].aSize
	jmp	short @@2
@@1:	xchg	ax,[di].aSize
@@2:	mov	al,';'
	call	CheckToken
	jnz	@@3
	mov	al,','
	call	NeedToken
	lea	si,Operand3
	call	Expression
	inc	OperCount
	mov	al,';'
	call	NeedToken
@@3:	ret
ProcessOperands	endp

@Err:	cbw
Error		label near
	push	SaveTextPtr
	pop	TextPtr.offs
	jmp	@Exit
FieldErr	label near
	mov	al,-15
	jmp	@Err
ZeroDivErr	label near
	mov	al,-14
	jmp	@Err
Not286Err	label near
	mov	al,-13
	jmp	@Err
InvOperErr	label near
	mov	al,-12
	jmp	@Err
IntConstErr	label near
	mov	al,-11
	jmp	@Err
StringConstErr	label near
	mov	al,-10
	jmp	@Err
OutOfRangeErr	label near
	mov	al,-9
	jmp	@Err
InvRegErr	label near
	mov	al,-8
	jmp	@Err
RelSymErr	label near
	mov	al,-7
	jmp	@Err
TypeErr		label near
	mov	al,-6
	jmp	@Err
ConstErr	label near
	mov	al,-5
	jmp	@Err
MemRefErr	label near
	mov	al,-4
	jmp	@Err
InvOperErr2	label near
	mov	al,-3
	jmp	@Err
OutOfMemErr	label near
	mov	al,-2
	jmp	@Err
SyntaxErr	label near
	mov	al,-1
	jmp	@Err

CheckStack	proc near
	cmp	sp,StackLimit
	jbe	OutOfMemErr
	ret
CheckStack	endp

	include	asmexpr.inc

	include	asmlex.inc

	include	asminstr.inc

	extrn	OpcodeTable:near
	extrn	ResWordTable:near

	end
			
...
Expand> <Close

Want complete source code? Download it here

Point(s): 1

Download
0 lines left, continue to read
Sponsored links

File list

Tips: You can preview the content of files by clicking file names^_^
Name Size Date
$$$DN$$$.LST13.00 B06-11-97 07:03
$$$DN$$.LST11.00 B06-11-97 07:03
BASM.PAS249.00 B07-09-93 02:39
BPTDLG.PAS7.79 kB12-20-93 00:47
CALSTKWN.PAS2.94 kB12-20-93 01:43
<COMPILER>0.00 B06-11-97 06:19
COMPILER.PAS4.12 kB12-20-93 00:32
ARITH.ASM5.12 kB10-02-93 14:48
ASM.ASM7.44 kB10-02-93 15:14
ASMEXPR.INC8.75 kB07-08-93 16:10
ASMINSTR.INC15.34 kB07-10-93 15:41
ASMLEX.INC6.31 kB07-10-93 14:34
BASM.ASM6.33 kB07-10-93 15:53
BASM.INC3.35 kB08-30-93 02:13
CHEAP.ASM3.94 kB10-02-93 15:15
CODEGEN.ASM18.44 kB10-02-93 14:44
COMPILE.ASM17.92 kB10-02-93 14:48
COMPILER.INC22.90 kB01-04-94 18:21
CONVERT.ASM11.38 kB10-02-93 14:44
CONVERT2.ASM15.17 kB10-02-93 15:13
DEBANALZ.INC8.35 kB01-04-94 17:46
DEBEMUL.INC8.13 kB07-08-93 16:13
DEBOPCOD.INC4.31 kB07-08-93 16:13
DEBUG.ASM7.74 kB07-09-93 02:35
DEBUG2.ASM3.77 kB07-08-93 21:32
DEBUGGER.ASM29.41 kB10-02-93 15:22
DECLARE.ASM39.16 kB10-02-93 14:44
ERROR.ASM945.00 B10-02-93 14:48
EXPR.ASM26.44 kB10-02-93 15:11
EXTARITH.ASM10.17 kB01-04-94 18:18
EXTCONV.ASM8.11 kB01-04-94 18:18
EXTEND.INC626.00 B01-04-94 18:24
EXTPOW10.ASM872.00 B01-04-94 18:19
EXTSTR.ASM4.50 kB01-04-94 18:19
LEX.ASM28.36 kB10-02-93 14:55
LINK.ASM16.07 kB10-02-93 15:15
LINKMAP.ASM9.58 kB10-02-93 18:41
OBJECT.ASM9.40 kB10-02-93 14:48
OPCODES.ASM10.90 kB07-10-93 14:49
OPERS.ASM17.51 kB10-02-93 15:22
PUT.ASM9.20 kB10-02-93 14:37
STDFUNC.ASM17.04 kB10-02-93 15:14
STDPROC.ASM21.22 kB10-02-93 14:37
STDUTILS.ASM4.49 kB10-02-93 14:22
STMT.ASM16.26 kB10-02-93 14:55
STMTPART.ASM8.80 kB10-02-93 14:50
TDINFO.ASM5.52 kB07-24-94 21:50
TDINFO1.INC7.40 kB02-18-94 01:57
TDINFO2.INC6.15 kB07-24-94 21:48
TDINFO3.INC6.55 kB07-24-94 21:49
TDINFO4.INC4.46 kB07-24-94 21:50
TDINFO5.INC2.06 kB02-09-94 15:30
TDINFO6.INC6.27 kB07-24-94 21:51
TDINFO7.INC4.86 kB07-24-94 20:47
TPSTART.ASM7.54 kB10-03-93 20:00
UNITS.ASM5.14 kB10-02-93 15:15
COMPOPT.PAS970.00 B12-13-93 14:02
COMPVARS.PAS6.27 kB01-04-94 17:51
COMPWIND.PAS5.25 kB12-20-93 00:27
CONFIG.PAS13.10 kB01-04-94 15:13
CONTEXT.PAS5.19 kB01-04-94 17:33
CONTROLS.PAS13.42 kB01-04-94 17:33
CPUWIN.PAS2.51 kB12-20-93 00:29
DEBUG.PAS898.00 B12-20-93 00:35
EDITOR.PAS42.81 kB01-24-94 01:27
EVALDLG.PAS3.82 kB12-20-93 00:34
EXTEND.PAS2.43 kB06-05-93 17:08
FILE_ID.DIZ98.00 B06-11-97 06:20
FNAMES.PAS2.43 kB12-13-93 12:32
GETOPT.PAS2.44 kB12-10-93 19:42
HELP.PAS38.00 kB01-04-94 02:01
HELPFILE.PAS7.02 kB12-22-93 17:04
HELPHIST.PAS1.92 kB12-27-93 23:03
HELPSCRN.PAS27.09 kB12-28-93 01:24
HELPUTIL.PAS444.00 B12-22-93 14:21
MAKEFILE5.24 kB07-24-94 21:55
MEM.PAS3.51 kB02-12-93 16:21
OUTPUTWN.PAS2.87 kB12-20-93 01:30
PARAMS.PAS1.71 kB12-10-93 19:25
REG.PAS2.18 kB12-29-93 16:22
RUNERR.PAS1,016.00 B12-20-93 00:37
SHELL.PAS889.00 B12-20-93 00:37
STRNAMES.PAS2.62 kB01-04-94 16:23
TCOLORS.PAS9.86 kB12-29-93 16:05
TDINFO.PAS233.00 B12-20-93 00:38
TDOS.PAS16.14 kB12-15-93 13:51
<TEDIT>0.00 B06-11-97 06:19
TEDIT.PAS8.50 kB01-18-94 00:42
ED.INC3.39 kB01-18-94 00:45
EDBLOCK.ASM11.21 kB01-20-94 03:00
EDCHANGE.ASM1.99 kB12-22-93 01:30
EDCURSOR.ASM9.97 kB12-31-93 04:11
EDDELETE.ASM7.17 kB12-29-93 00:00
EDINDENT.ASM2.00 kB03-04-93 14:35
EDINSERT.ASM15.33 kB12-30-93 16:53
EDKEYS.ASM4.87 kB03-04-93 19:36
EDLINES.ASM2.82 kB12-22-93 01:30
EDMAIN.ASM2.75 kB12-22-93 01:30
EDMATCH.ASM3.37 kB03-04-93 19:24
EDPAGES.ASM9.01 kB12-22-93 01:56
EDPOS.ASM10.10 kB01-29-94 17:32
EDREDRAW.ASM9.24 kB01-18-94 00:38
EDREPL.ASM1.47 kB05-19-94 13:28
EDRW.ASM12.47 kB01-18-94 00:37
EDSEARCH.ASM11.79 kB01-18-94 00:39
EDTOGGLE.ASM1,018.00 B03-04-93 14:54
EDUNDO.ASM3.51 kB03-04-93 20:21
TMENU.PAS7.27 kB12-29-93 15:35
TRACER.PAS11.38 kB01-18-94 00:44
TRES.PAS44.22 kB01-04-94 17:40
TSTATUS.PAS4.26 kB01-04-94 16:23
TSTDDLG.PAS54.38 kB01-04-94 15:26
TURBO.CMD796.00 B01-13-93 16:37
TURBO.PAS1.44 kB01-04-94 02:04
TURBO1.PAS7.45 kB01-04-94 17:50
TURBO2.PAS23.41 kB01-04-94 01:21
TVARS.PAS4.75 kB01-03-94 23:25
TWINDOWS.PAS3.65 kB12-29-93 15:30
UTILS.PAS8.71 kB01-04-94 15:14
VFILES.PAS2.26 kB12-13-93 13:02
VIDEOIO.ASM1.37 kB07-08-93 16:21
VIDEOIO.PAS200.00 B12-20-93 00:40
VMEM.PAS11.72 kB12-20-93 00:40
VMEMUTIL.PAS2.24 kB12-15-93 13:54
VSWAP.PAS20.57 kB01-04-94 02:03
WATCHWIN.PAS5.90 kB12-20-93 01:14
...
Sponsored links

BASM.ASM (283.43 kB)

Need 1 point
Your Point(s)

Your Point isn't enough.

Get point immediately by PayPal

More(Debit card / Credit card / PayPal Credit / Online Banking)

Submit your source codes. Get more point

LOGIN

Don't have an account? Register now
Need any help?
Mail to: support@codeforge.com

切换到中文版?

CodeForge Chinese Version
CodeForge English Version

Where are you going?

^_^"Oops ...

Sorry!This guy is mysterious, its blog hasn't been opened, try another, please!
OK

Warm tip!

CodeForge to FavoriteFavorite by Ctrl+D