The homework is to create a pretty simple calculator, and I think I understand how to do all the calculations well enough, but I'm struggling with a different part of the homework. The user inputs some thing like this:

+ooooo

which means add 5 to the running total. Or something like this:

/ooo

which means divide the running total by 3.

I don't understand how to go about having my program decide which calculation to perfom. I found the below code on nasm.us, which makes sense, but I don't know how it would translate to seperating user input.

%substr mychar 'xyzw' 2       ; equivalent to %define mychar 'y' 
%substr mychar 'xyzw' 3       ; equivalent to %define mychar 'z' 
%substr mychar 'xyzw' 2,2     ; equivalent to %define mychar 'yz' 
%substr mychar 'xyzw' 2,-1    ; equivalent to %define mychar 'yzw'

Even this is pretty far beyond what we've been taught in class, so I'm not even sure this is the kind of thing I'm looking for.

Since my program needs to run around the idea of this kind of user choice input, I haven't started on my program yet, so I have no code of my own to post. I feel I need to understand how to determine whether the user wants to add, multiply, subtract or divide before I can get to work.

Any little nudge in the right direction would be appreciated. Thanks in advance.

Just to be clear for anyone reading this later, the example code in the original post is from the NASM online documentation.

I am afraid that it really wouldn't be of any help here. The %substr directive is for working with substrings of strings defined at assembly time, being for use in macro programming. It is mostly there as a convenience - the programmer doesn't need to manually define multiple string constants for the substrings, or manually manipulate them at run time, but can have the assembler figure out the details for them.

The practical upshot of it is that %substr can't be used with user input at all. Sorry.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.