Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

NASM assembler

Status
Not open for further replies.

ndenhere

Instructor
Mar 2, 2010
1
0
0
SZ
Can someone help me to design a assembly language program that accept a decimal number fron the keyboard and output roman numeral number
for example you input 8 , it should output VIII
 
Appreciate that this is some kind of tutorial, but these days (and probably for the last twenty years at least)there isn't any point in doing application development in assembler. You should restrict its use to areas where assembler is either the best or only option - device drivers, operating system exit points, and similar. This isn't just a mindless whinge about using the right tool for the job. You will find you use a whole different set of machine instructions for this kind of work, and it will be much more useful to you in the real world. Example - I've been writing mainframe assembler routines since the eighties, and I've never had cause to write a single instruction that used floating point arithmentic. But most assembler tutorials seem to want to get stuck in to this kind of thing straight away, as if they expect people to suddenly want to start writing and maintaining amortisation calculators in assembly language.

Steve

[small]"Every program can be reduced by one instruction, and every program has at least one bug. Therefore, any program can be reduced to one instruction which doesn't work." (Object::perlDesignPatterns)[/small]
 
One still needs to be able to do those things, because assembler can be very useful for optimizations. A profiler can be useful for these things to show where most of the time of a program run is being spent in this regard. I agree that other languages are generally useful for most things, but assembler still has its place in general application development.

It also has its place for applications where code size is important.

So stevexff, how should someone learn assembler if you are starting cold and need to learn everything you ever need to know for any and all situations? The best way I can think of is start cold and code logic with it. One can always learn new or different instructions easily enough, but you still have to pick up the logic of how it works.

I'm waiting for the white paper entitled "Finding Employment in the Era of Occupational Irrelevancy
 
Fair point I suppose. I don't dispute that you have to learn on something, but what I was trying to get across was the need for more relevant examples. There is a lot to learn in assembly level programming, and much of it is about addressability, registers and capabilities of the processor, and interaction with the operating system. Why add to this burden by making people learn stuff they are unlikely ever to use in the real world?

Take the example above - reading a number from the terminal, and outputting the roman equivalent. Messrs. Kernighan, Ritchie, and Torvalds have written whole operating systems almost entirely in C. Hands up who thinks you will ever need to do terminal I/O from assembly level code? If we substitute the simple number conversion for a complex and time critical calculation that must be performant, and using the code size and/or optimisation rationale above, you'd still do the terminal I/O from a high level program and call the assembler subroutine to reformat the number before display. So why learn terminal I/O in assembler?

Creating a subroutine to reformat the numbers would be far more useful as a teaching example - it teaches about program linkage, addressability, parameter passing, return variables, integer and modulus arithmetic, and possibly even data validation and table handling. These are all things you need to know, and are applicable to almost every program you write.



Steve

[small]"Every program can be reduced by one instruction, and every program has at least one bug. Therefore, any program can be reduced to one instruction which doesn't work." (Object::perlDesignPatterns)[/small]
 
I don't dispute any of what you say in the last post, that much. Most people that do use assembler today will wrap it in another language via subroutine calls or inline stuff (which I've used).

There's always a need, though, to at least be able to get to that level of all ASM at times. If anything, to look at DOS and Windows, the interrupts in DOS are a lot like the API calls in Windows. And if you get a Windows-centric assembler, you still can do the whole task in assembler simply by calling the API, as you would in a C program (or any other program that doesn't use any frameworks).

From personal knowledge, though, interrupt calls aren't that tough, but are necessary in DOS for different things. I also know that most people that teach assembler are extremely behind the curve in how they teach it. I don't know where or how the OP got the problem (NASM is Windows-based, generally, so the terminal parts involve API calls anyway), but I know I wouldn't insist on assembler all the way through.

OTOH, my problem I find with most tutors when I was trying to learn assembler in earnest is that they don't teach the essentials accurately and well (but that's another topic) to be able to pick up any assembler you find (in other words, no assembler is very standardized). I'll probably pick it up again when time permits though, since I want to pick up much more than I already have.

I'm waiting for the white paper entitled "Finding Employment in the Era of Occupational Irrelevancy
 
Interesting comments.
I am interested in learning assembly.
I use OpenBSD. I am also a newbie at C.
I am not a newbie nor a guru at perl.

The more I learn about C, the more I see why many things are the way they are in perl.

Since C is much closer to assembly, it seems appropriate to me to try and learn them both together.
I am not taking any classes nor will I probably use it at work, but I want to learn it anyway. Heck, I might even work on a device driver at some point.

But I am really having a hard time finding anything consistent for me to learn with.

There is a ton of older stuff for DOS and windows, but that is not really relevant to me.

I have found some FreeBSD stuff, but it is very limited.

I have installed fasm, nasm, yasm and intel2gas.

I like the way nasm has its syntax.

I just need some material to work with. I don't mind buying something, but not sure what to look for.

Frankly, I would be happy just to find some examples of "this " in C, "this" same thing in assembly
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top