GeneralThis forum is for non-technical general discussion which can include both Linux and non-Linux topics. Have fun!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Well, I began learning assembler about 3 weeks ago, and it's not too shabby. Quite interesting, and takes me back to my days of using int86(&Hxx, AX, BX, CX, DX...) or with qb int86old() on my ol 486.
Though, the only problems I have come across are a few things that just comfuddle me. I had, for the longest time, thought ah, al were the upper and lower bits of ax. Now, it's still the same, but with memory addresses, nope, that's not the case. Somehow al is the byte where ax points to...Oooohkay...At least in one of the programs I wrote testing different ways to get a character from a string that I found that out.
Another problem, well it's really not a problem more of an unknown, is understanding the difference between eax and ax. I know the difference between 32 and 16, it's just trying to figure out what exactly that means data-wise. Of course I still have a bit of reading to do, so...eh...but doing all this has helped me learn how to use gdb, as well. So I'm killing two birds with one stone, so to speak.
Another thing I'm finding fairly fun, is trying out x86, or as, oh holy hell. Not that as is hard, but my fingers are not dexterous enough to use the shift key efficiently enough for $ and % for every single bloody register and number. So I have been mostly sticking with nasm, don't have to press the shift key but every once in a great while. Although, I might switch from nasm once I'm finished with another keyboard layout I'm busy writing, well, once I have an idea for it then I'll begin to write it.
Now there is one thing that I find quite interesting. I have always read how ingrained c was in linux, but I had no idea just how much so. Back in my ol DOS days, if I need to know the registers and interupts, all I had to do was look up the interupts (wherever I'd find them at, which was quite often in many places), read up, and voila, I could get something done with direct calls. However, with linux, it looks like most of the information is written for c. I've found a reference to the system calls, but it's all written for c, doesn't say anything about the registers that are accessed or need to be set to for what needs to be done. Probably means I need to scour the c include files to figure that out. Though there are the man pages, at least from one place I've read that, but all it said was to read the man pages, not "what" to read. Again, more reading...No problem. I ain't expecting to figure this out any time soon...
As of now I'm half way through the pcasmbook, and the first couple or so chapters in another pdf file for x86, as well as I've read quite a few pages of the nasm manual. So much to read, but I think it's fun, even exhilerating. It also helps to drive my wife nuts when I tell her what I'm doing......
Hey, for any of you programmers that happen to make it this far down, what's with the million and one Hello world examples? Just how many Hello World examples need there be? One would think that by now there would be something different. Well, whatever...I'm way passed that now...
I've learned how to pass arguments to functions, though that's another thing that tickles me the wrong way. I see the stack from down up, and right left, not left right top down. Such as when I "push" I expect that I'm shoving it up into the stack. However, when I wrote a small c program to use a function written in nasm, it took me a while to figure out what was wrong. Wasn't until I tested it in reverse that I found out the problem. So I have to tell myself over and over, when I "push" I'm shoving it down into a hole, and to "pop" I'll have to pull it up...Eh, I'm wierd that way...
Eh, anyway, that's my yack. Not very well structured not informative, but I'm bored, and quite frankly I just don't give a damn......
I personally learnt ASM for the first time on my old ZX Spectrum back in 1987, then again in 96/97 when I shifted to the PC, had to adapt myself to the x86.
Programming ASM in Linux somehow just isn't as *satisfying* as on DOS, where you have the whole machine to yourself and can tamper with it as you like. So kudos to you for trying (at least you get the pleasure of a debugger like GDB, as you've mentioned).
Distribution: Damn Small Linux, KateOs, M$ Ickdows Vista, My own OS
Posts: 2,094
Rep:
Quote:
Another problem, well it's really not a problem more of an unknown, is understanding the difference between eax and ax. I know the difference between 32 and 16, it's just trying to figure out what exactly that means data-wise. Of course I still have a bit of reading to do, so...eh...but doing all this has helped me learn how to use gdb, as well. So I'm killing two birds with one stone, so to speak.
your kidding right? AX is to EAX as AL is to AX.
Quote:
Another thing I'm finding fairly fun, is trying out x86, or as, oh holy hell. Not that as is hard, but my fingers are not dexterous enough to use the shift key efficiently enough for $ and % for every single bloody register and number. So I have been mostly sticking with nasm, don't have to press the shift key but every once in a great while. Although, I might switch from nasm once I'm finished with another keyboard layout I'm busy writing, well, once I have an idea for it then I'll begin to write it.
theres a flag you can pass to mimic nasm, don't remember what it is because i don't use gas.
I had thought this, but haven't seen what is to EAX as AH is to AX...That's basically what I'm wondering. <See diagram below>
Code:
EAX
?? AX
?? ?? AH AL
|
|
nibble nibble
bit bit bit bit
This might be just because I'm rather nuts trying to look at RAX, EAX in the same way that I look at AX, the same way I look at binary, 1 bit, 2 bits = nibble, 2 nibbles = byte, 2 bytes = word, etc and wanting to know what it all is, even though I may never need it. Eh, it's not important though. I'll figure it out sooner or later......
I had, for the longest time, thought ah, al were the upper and lower bits of ax.
Yes.
Quote:
Now, it's still the same, but with memory addresses, nope, that's not the case. Somehow al is the byte where ax points to...
I don't know what that means.
Quote:
RAX, EAX in the same way that I look at AX, the same way I look at binary, 1 bit, 2 bits = nibble, 2 nibbles = byte, 2 bytes = word,
A nibble is 4 bits, a byte is 8 bits (2 nibbles), the size of a word is usually the size of the registers (16-bits on a 16-bit compuer, 32-bits on a 32-bit computer) but Intel generally calls 16 bits a word, and 32 bits are a dword (double-word).
Quote:
I had thought this, but haven't seen what is to EAX as AH is to AX
There is no name for the upper 16 bits of EAX, and no name for the upper 32 bits of RAX.
Code:
EAX
_ AX
_ _ AH AL
|
|
nibble nibble
bit bit bit bit bit bit bit bit
Hey, for any of you programmers that happen to make it this far down, what's with the million and one Hello world examples? Just how many Hello World examples need there be? One would think that by now there would be something different. Well, whatever...I'm way passed that now...
Whenever someone embarks on learning a new programming language, typically the first thing they do is learn how to output some characters to the screen. Then they go on about learning other features such as setting variables, loops, etc., the results of which need to be output to the screen, which they have already learned how to do as part of the first lesson.
So, what characters should we output to the screen as our first lesson? Well, why not a nice greeting! A greeting. . . Hmmm. . . How about, "Hello"? Yeah! And who are we greeting? Well, I suppose everybody, or "the world". So the first characters we output to the screen during the first lesson of a new programming language are "Hello, world!"
If it's your first programming language, you might get super excited at having told the computer what to do. "Holy shit!! Look, ma!! It says 'Hello, world!' Woo-hoo!! We could make it say other things! Hey, I bet we could. . .", until Dad whacked me upside the head and barked at me to settle down, for Christ's sake.
Distribution: Damn Small Linux, KateOs, M$ Ickdows Vista, My own OS
Posts: 2,094
Rep:
Quote:
Originally Posted by mjones490
Whenever someone embarks on learning a new programming language, typically the first thing they do is learn how to output some characters to the screen. Then they go on about learning other features such as setting variables, loops, etc., the results of which need to be output to the screen, which they have already learned how to do as part of the first lesson.
So, what characters should we output to the screen as our first lesson? Well, why not a nice greeting! A greeting. . . Hmmm. . . How about, "Hello"? Yeah! And who are we greeting? Well, I suppose everybody, or "the world". So the first characters we output to the screen during the first lesson of a new programming language are "Hello, world!"
If it's your first programming language, you might get super excited at having told the computer what to do. "Holy shit!! Look, ma!! It says 'Hello, world!' Woo-hoo!! We could make it say other things! Hey, I bet we could. . .", until Dad whacked me upside the head and barked at me to settle down, for Christ's sake.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.