> By: serbanmm
>
> Hello! I need to do a program in NASM language and I have no idea how to do
> it! The problem is the following:
Homework? Or do you just happen to need this? :)
> Write a NASM program that does the following:
> (i) prompts the user to input a line,
You know how to do this part?
(i-a) input the line.
You know how to do *this* part?
You know about "gets()" and buffer overruns, and stuff? If you *don't* understand why this is a Very Bad Thing, get someone to explain it! The "professionals" do this all the time. We have to do better! I think you'll find it easy to avoid a buffer overrun in asm, but keep it in mind.
Okay, we've got a line...
> (ii) detects if the input line contains ‘ end.’, and
Question on the specification: if the pesky user enters just "end." - first thing on the line - no leading space - do we *not* want to stop?
There are "sophisticated" ways to search for a string in a buffer (Boyer-Moore, etc.). Since these "lines" will presumably be short, and we're looking for a specific string, a simpler routine is probably what's expected. You might look into "scasb"... or "rep scasb". I think I'd put "end." into a register and look for that first. If found, compare the byte before that to ' ' (or beginning-of-line?)...
> (iii) if so, echoes the line up to the first instance of‘ end.’
Okay... this implies that we *don't* print the " end.", I guess. Either way, it shouldn't be too hard to do...
> and returns
> control to the kernel;
I suppose you know how to do this part...
> otherwise repeats all over again at (i).
... and this part...
> Assemble your program using the NASM assembler
Okay... no mention of a linker... does this imply we're doing a dos .com file? It *does* make a difference what OS this is intended to run on!
> and run the resulting executable.
> Debug the program until it works correctly.
What??? This implies that it isn't going to run correctly, first shot! Have they no faith??? Well, might happen... You know how to run a debugger (whatever one you've got)?
> Thanks in advance for your answers!
> PLS. give me the program code....to study and understand more easier this language!
If you give us your instructor's email, we can hand it in for ya, too! Or maybe you'd rather show us how far you *can* get, and indicate what parts you need help with?
Best,
Frank