Scanning command line in asm? Please help me

January 8, 2010 at 05:40:25
Specs: Windows XP, 508 MB
Can you help me out with this code. I done understand what the instructions in it do. Can you give me some details on them. I understand it scans for strings in command line.

;scan command line for a file name
mov ch,01h
mov di,81h
mov al,' '
repe scasb
lea dx,[di-1]
dec di
mov al,13
repne scasb
mov byte [di-1],0

I would like to integrate this could in an Encryption program I'm trying to create. It will read the string from cmd-line and encrypt it with the Rot13 encryption format.
Can you help me?

See More: Scanning command line in asm? Please help me

Report •

January 8, 2010 at 13:36:36
mov ch,01h
mov di,81h 81 is the first byte of the cmdline after the command itself
mov al,' ' next two lines: move forward in the buffer until
repe scasb the first space is encountered (usually just
lea dx,[di-1] the first byte, #82h)
dec di now move backward 1 byte in the buffer
mov al,13 scan forward again, this time looking for the car.
repne scasb return that ended the cmdline
mov byte [di-1],0 and punch in a zero there,

(presumably in preparation for a file-open operation which needs that byte to be a zero). essentially all it does is determine the beginning of the filename (into DX for fileopen) and plant a zero at end. just use debug and trace the code and you can watch what it does. (except you need to replace
" " with 20 in line 3 and don't put the "h" after the numbers) not clear if are you intending to open the file and encrypt it, or encrypt the word on the cmdline itself... this snippet is geared toward opening the file.

Report •

January 8, 2010 at 16:38:47
Thanks! Can you give me a tutorial on assembly - (FASM) if you

Report •

January 8, 2010 at 19:52:42
use the google, Luke! (Lol). I wish I could, i can't even point you to good sites offhand. assembler is kind of different from "raw" or "native" (ie debug) code, so a lot of assembler instructions are not "doable" directly in debug, and many of the instructions are set up differently per syntax. I just picked up what little i know from debugging/tracing/hacking .com (and a few .exe) executables, and I'm still not good at it (f/e i had no specific idea what repe scasb did, i just traced them out). ralph browns interrupts gives an exhaustive list of all the interrupts that "dos"has to offer, as well as about a zillion other mostly irrelevant apps. In debug, type ? for the debugger control commands, dump 0:26A0 (approx) to get a list of all the operations that debug supports (like scasb), then just assemble small bits of code and watch what they do, or better yet, hack (debug) some simple .com executables and watch what they do (much patience req'd).
feel free to pm to me, (or post) if you have other questions.
sorry not more help. (use the google! also local library)

Report •

Related Solutions

January 9, 2010 at 03:22:01
Thanks again! I'll post you if I have any other questions.

Report •

Ask Question