argtest.asm

来自「汇编编程艺术」· 汇编 代码 · 共 60 行

ASM
60
字号

		include 	stdlib.a
		includelib	stdlib.lib


dseg		segment	para public 'data'
ArgCnt		word	0
dseg		ends


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


Main		proc
		mov	ax, dseg
		mov	ds, ax
		mov	es, ax

; Must call the memory manager initialization routine if you use any
; routine which calls malloc!  ARGV is a good example of a routine which
; calls malloc.

		meminit


		argc			;Get the command line arg count.
		jcxz	Quit		;Quit if no cmd ln args.
		mov	ArgCnt, 1	;Init Cmd Ln count.
PrintCmds:	printf			;Print the
		byte	"\n%2d: ",0
		dword	ArgCnt

		mov	ax, ArgCnt	;Get the next command line guy.
		argv
		puts
		inc	ArgCnt		;Move on to next arg.
		loop	PrintCmds       ;Repeat for each arg.
		putcr


Quit:		ExitPgm			;DOS macro to quit program.
Main		endp

cseg            ends



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


;zzzzzzseg is required by the standard library routines.

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

⌨️ 快捷键说明

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