Library Design, f0dder's nightmare.
- From: "hutch--" <hutch@xxxxxxxxx>
- Date: 18 Jun 2006 22:55:49 -0700
One of the important piece of criteria for a library module is that it
must work properly, IE, do the thing that such a module is expected to
do and among the thing that are normally expected with a command line
parser is that it can delimit not only on spaces but tabs as well.
For someone who has elected themselves as the critic of other peoples
library design, here is the alternative for any who are mislead by
nonsense of this type.
Here is the input and output from the command line parser that is the
leading edge of f0dder.lib.
H:\ASM2\ARCHIVE\F0DDERCL>main 1 2 3 4 5 6
Arg 0 == <MAIN>
Arg 1 == <1 2 3 4 5 6>
You will note here that the arguments delimited by tabs are all bunched
together as one argument.
Here is how its done using GetCL.
H:\asm2\archive\f0ddercl\stcl>stcl 1 2 3 4 5
6 7 8
1
2
3
4
5
6
7
8
The distinction is about this simple, f0dder.lib as demonstarted with
MAIN.EXE does not properly delimit on tabs where masm32.lib using GetCL
does.
Here is how simple the code is to do it.
;
=========================================================================
include \masm32\include\masm32rt.inc
;
=========================================================================
comment * -----------------------------------------------------
Build this template with
"CONSOLE ASSEMBLE AND LINK"
----------------------------------------------------- *
.code
start:
;
=========================================================================
call main
exit
;
=========================================================================
main proc
LOCAL clbuf :DWORD ; buffer pointer
LOCAL argnm :DWORD ; argument number counter
LOCAL buffer[128]:BYTE
mov clbuf, ptr$(buffer) ; set pointer to buffer
mov argnm, 1 ; start at argument 1
; ----------------------------
; test the command line length
; ----------------------------
cmp len(rv(GetCommandLine)), 128
jbe next
print "Command Line Exceeds 128 Bytes",13,10
ret
next:
invoke GetCL,argnm,clbuf ; get the argument
cmp eax, 1 ; test for valid argument
jne bye ; exit if not
print clbuf,13,10 ; display it at the console
add argnm, 1 ; increment the argument
jmp next
bye:
ret
main endp
;
=========================================================================
end start
Regards,
hutch at movsd dot com
.
- Follow-Ups:
- Re: Library Design, f0dder's nightmare.
- From: randyhyde@xxxxxxxxxxxxx
- Re: Library Design, f0dder's nightmare.
- From: japheth
- Re: Library Design, f0dder's nightmare.
- Prev by Date: Re: Book on Assembly
- Next by Date: Re: Library Design, f0dder's nightmare.
- Previous by thread: Question Regarding the FS segment Register
- Next by thread: Re: Library Design, f0dder's nightmare.
- Index(es):
Relevant Pages
|