Page 1 of 1

User-Defined Code?

Posted: Wed May 21, 2014 10:42 am
by bashcommando
How do I make a prompt in assembly and how do I run the code typed by the user?
Example:

Code: Select all

>mov 0x50, 0x45
And then it runs the command the user typed. Ideas?
Does

Code: Select all

int 80h
work? (I use it in LINUX but will it work outside LINUX?)

Re: User-Defined Code?

Posted: Wed May 21, 2014 11:30 am
by Gigasoft
Here is some homework for you:

a) What is the first sentence at the top of the page you're currently reading?
b) Estimate the prevalence of computer illiteracy among operating system developers.
c) From your answer to question b, what can be logically deduced about your profession?
d) Using the above, what would be a pretty absurd activity for you to be involved with on the Internet?

Re: User-Defined Code?

Posted: Wed May 21, 2014 11:57 am
by bashcommando
Gigasoft wrote:Here is some homework for you:

a) What is the first sentence at the top of the page you're currently reading?
b) Estimate the prevalence of computer illiteracy among operating system developers.
c) From your answer to question b, what can be logically deduced about your profession?
d) Using the above, what would be a pretty absurd activity for you to be involved with on the Internet?
a) How do I make a prompt in assembly and how do I run the code typed by the user?
b) 99/100
c) I'm awesome because people don't know what I'm talking about so they pay me
d) Anything that involves trolls and hackers
Anyways, what does this have to do with this subject?

Re: User-Defined Code?

Posted: Wed May 21, 2014 2:02 pm
by Gigasoft
Your score was 0.

The correct answers are:
a) OSDev.org [is] the place to start for operating system developers.
b) The answer is 0. Computer literacy is a prerequisite for developing operating systems.
c) Since there are no computer illiterate operating system developers, we can conclude that you are not an operating system developer.
d) Posting at osdev.org. It makes about as much sense as being a member of Hells Angels and not owning a motorcycle.

Re: User-Defined Code?

Posted: Wed May 21, 2014 2:16 pm
by Combuster
bashcommando wrote:Anyways, what does this have to do with this subject?
It means that you broke the forum rules, and people think they have the privilege to make fun of you because of it.

That doesn't mean they aren't right. You already claimed you do not know assembly, and that you hardly know any C. And yet you're here trying to do the advanced wizardry in the subject. That's just not going to work. To prevent people from making a fool of themselves in ways like this, we officially have the "Required Knowledge" rule.

And in this case, it applies to you.

What you need is practice in the simple things, and quite a bit of it. Try writing C versions of your python apps. By the time that's actually easy for you, you might be good enough to try again.

Re: User-Defined Code?

Posted: Wed May 21, 2014 5:27 pm
by AndrewAPrice
An assembly code interpreter?

It's possible. A line of assembly code is very simple to parse. Simply split a string by white spaces - the first element is the operation, the following elements are the operands.

A very simple interpreter could be written in a few days. But, you have some tougher design decisions to make the thing useful:

1. If you're going to do it line by line then you're going to have to save the processor state before and after every instruction. Imagine entering these lines;
mov ax, 100
add bx, ax

After running the first line the interpreter is most likely going to modify ax while you are typing in the next instruction and it assembles it. You'd need to store processor state.

2. How do you handle and define labels, for things like jumps? How do you enter the code for loops and procedures that you don't actually want executed write now, but after you have defined it?

I think rather than interpret line by line, I would allow the user to enter a block of assembly code, with a special instruction such as "." or "go" which assembles everything above that point and executes it. No need to store processor state as you could call that freshly assembled block like any other and expect the registers to be trashed upon returning. You could handle labels and jumps just like in a normal assembler.

Re: User-Defined Code?

Posted: Wed May 21, 2014 6:18 pm
by bashcommando
Combuster wrote:
bashcommando wrote:Anyways, what does this have to do with this subject?
It means that you broke the forum rules, and people think they have the privilege to make fun of you because of it.

That doesn't mean they aren't right. You already claimed you do not know assembly, and that you hardly know any C. And yet you're here trying to do the advanced wizardry in the subject. That's just not going to work. To prevent people from making a fool of themselves in ways like this, we officially have the "Required Knowledge" rule.

And in this case, it applies to you.

What you need is practice in the simple things, and quite a bit of it. Try writing C versions of your python apps. By the time that's actually easy for you, you might be good enough to try again.
Actually, I took assembly lessons so I know a bit of assembly. That was when I first joined. Anyways sorry about breaking the forum rules. I'll be more careful next time. :D