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

📄 testdate.asm

📁 汇编编程艺术
💻 ASM
字号:
		.xlist
		include 	stdlib.a
		includelib	stdlib.lib
		.list


dseg		segment	para public 'data'
DateBuf		db	64 dup (0)
SampleDate1	db	"2/4/86",0
SampleDate2	db	"2/29/88",0
SampleDate3	db	"2/29/91",0
SampleDate4	db	"2/28/2000",0
SampleDate5	db	"2/29/2000",0
SampleDate6	db	"2/29/2004",0
SampleDate7	db	"2-15-82",0
SampleDate8	db	"2=15=82",0

SampleTime1	db	"0:0:0",0
SampleTime2	db	"23:59:59.99",0
SampleTime3	db	"12:00:00",0
SampleTime4	db	"24:00:00",0
SampleTime5	db	"00:60:00",0
SampleTime6	db	"00:00:60",0
SampleTime7	db	"00:00:00.100",0
SampleTime8	db	"1:2:3.4",0

dseg		ends



cseg		segment	para public 'code'
		assume	cs:cseg, ds:dseg

;
; Variables that wind up being used by the standard library routines.
; The MemInit routine uses "PSP" and "zzzzzzseg" labels.  They must be
; present if you intend to use getenv, MemInit, malloc, and free.
;
;
		public	PSP
PSP		dw	?


TestTheDate	proc
		puts
		print
		db	" through atod produces ",0

		atod
		jnc	GoodAtod
		print
		db	"AN ERROR!",0
		jmp	WasBadAtod

GoodAtod:	dtoam
		puts
		free
WasBadAtod:	putcr
		putcr
		ret
TestTheDate	endp




TestTheTime	proc
		puts
		print
		db	" through atot produces ",0

		atot
		jnc	GoodAtot
		print
		db	"AN ERROR!",0
		jmp	WasBadAtot

GoodAtot:	ttoam
		puts
		free
WasBadAtot:	putcr
		putcr
		ret
TestTheTime	endp







Main		proc
		mov	cs:PSP, es		;Save pgm seg prefix
		mov	ax, seg dseg		;Set up the segment registers
		mov	ds, ax
		mov	es, ax

		mov	dx, 0
		meminit
		jnc	GoodMemInit

		print
		db	"Error initializing memory manager",cr,lf,0
		jmp	Quit
GoodMemInit:

		print
		db	"Testing xDTOA/xDTOA2",cr,lf,lf
		db	"Today is: ",0
		lesi	DateBuf
		xDTOA
		puts
		putcr

		print
		db	"Multiple Dates: ",0
		lesi	DateBuf
		xDTOA2
		xDTOA2
		xDTOA2
		xDTOA
		lesi	DateBuf
		puts


		print
		db	cr,lf,lf,lf
		db	"Testing DTOA/DTOA2",cr,lf,lf
		db	"Today is: ",0
		mov	ah, 2ah			;DOS GetDate Call.
		int	21h
		lesi	DateBuf
		DTOA
		puts
		putcr

		print
		db	"Multiple Dates: ",0
		lesi	DateBuf
		mov	ah, 2ah			;DOS GetDate Call.
		int	21h
		DTOA2
		DTOA2
		DTOA2
		DTOA
		lesi	DateBuf
		puts


		print
		db	cr,lf,lf,lf
		db	"Testing DTOAm/xDTOAm:",cr,lf
		db	"Today's date: ",0
		mov	ah, 2ah			;DOS GetDate Call.
		int	21h
		DTOAm
		puts
		free
		print
		db	cr,lf,lf
		db	"Also today's date: ",0
		xDTOAm
		puts
		free

		print
		db	cr,lf,lf,lf
		db	"Long date tests:",cr,lf,lf
		db	"Today's date (xLDTOA): ",0
		lesi	DateBuf
		xLDTOA
		puts
		print
		db	cr,lf
		db	"Also today's date (LDTOA): ",0
		mov	ah, 2ah			;DOS GetDate Call.
		int	21h
		lesi	DateBuf
		LDTOA
		puts


		print
		db	cr,lf,lf,lf
		db	"Long date tests #2:",cr,lf,lf
		db	"Today's date (xLDTOAm): ",0
		xLDTOAm
		puts
		free
		print
		db	cr,lf
		db	"Also today's date (LDTOAm): ",0
		mov	ah, 2ah			;DOS GetDate Call.
		int	21h
		LDTOAm
		puts
		putcr

		printf
		db	cr,lf,lf
		db	"Testing ATOD:",cr,lf,lf
		db	0

		lesi	SampleDate1
		call	TestTheDate

		lesi	SampleDate2
		call	TestTheDate

		lesi	SampleDate3
		call	TestTheDate

		lesi	SampleDate4
		call	TestTheDate

		lesi	SampleDate5
		call	TestTheDate

		lesi	SampleDate6
		call	TestTheDate

		lesi	SampleDate7
		call	TestTheDate

		lesi	SampleDate8
		call	TestTheDate


; Test the time routines:

		print
		db	"Testing xTTOA/xTTOA2",cr,lf,lf
		db	"The time is: ",0
		lesi	DateBuf
		xTTOA
		puts
		putcr

		print
		db	"Multiple Times: ",0
		lesi	DateBuf
		xTTOA2
		xTTOA2
		xTTOA2
		xTTOA
		lesi	DateBuf
		puts


		print
		db	cr,lf,lf,lf
		db	"Testing TTOA/TTOA2",cr,lf,lf
		db	"The time is: ",0
		mov	ah, 2ch			;DOS GetTime Call.
		int	21h
		lesi	DateBuf
		TTOA
		puts
		putcr

		print
		db	"Multiple Times: ",0
		lesi	DateBuf
		mov	ah, 2ch			;DOS GetTime Call.
		int	21h
		TTOA2
		TTOA2
		TTOA2
		TTOA
		lesi	DateBuf
		puts


		print
		db	cr,lf,lf,lf
		db	"Testing TTOAm/xTTOAm:",cr,lf
		db	"The time is: ",0
		mov	ah, 2ch			;DOS GetTime Call.
		int	21h
		TTOAm
		puts
		free
		print
		db	cr,lf,lf
		db	"Also the time: ",0
		xTTOAm
		puts
		free


		printf
		db	cr,lf,lf
		db	"Testing ATOT:",cr,lf,lf
		db	0

		lesi	SampleTime1
		call	TestTheTime

		lesi	SampleTime2
		call	TestTheTime

		lesi	SampleTime3
		call	TestTheTime

		lesi	SampleTime4
		call	TestTheTime

		lesi	SampleTime5
		call	TestTheTime

		lesi	SampleTime6
		call	TestTheTime

		lesi	SampleTime7
		call	TestTheTime

		lesi	SampleTime8
		call	TestTheTime



Quit:		ExitPgm
Main		endp

cseg            ends



; Allocate a reasonable amount of space for the stack (2k).

sseg		segment	para stack 'stack'
stk		db	256 dup ("stack   ")
sseg		ends


; zzzzzzseg must be the last segment that gets loaded into memory!

zzzzzzseg	segment	para public 'zzzzzz'
LastBytes	db	16 dup (?)
zzzzzzseg	ends
		end	Main

⌨️ 快捷键说明

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