Help an Assembler Noob, it's good karma

Help an Assembler Noob, it's good karma

Yes, I'm a noob. I admit it. I'm taking a summer course in assembler, the prof is useless and doesn't seem to have the knowledge to teach this course. We're working with the 8088/8086 processor instruction set. I have a ton of questions and so far no answers so any help and tips you would like to pass on would be appreciated and passed on to other poor students of this class.

1) MOV DEST,SOURCE .. got it. It's an intel syntax standard. However with the direction bit, this can change the position of source and dest thereby creating a whole new value for the same code. eg. 89C3h and 8BD8h produce the same instruction of MOV BX,AX. Is one more correct than the other, or is it like ansi C where there are a million ways to produce the same results?

2) (MOV) Immediate to Register/Memory vs. Immediate to Register. These to opcodes look like they do the same function in regards to move to register. Is one prefered to another? Are there advantages to using one vs. the other? The book is very vague and the teacher still has yet to answer me.

3) Writing to floppy... (W) command is this even useful anymore?

I know I'll have more questions, as I read more through this book (The 8088 and 8086 Microprocessors: Programing,Interfacing,Software,Hardware, and Application 4th Ed. written by Walter A Triebel). If anyone has any suggestions on a better book, possibily one that explains more in detail the opcodes and when and where to use them, instead of scattered through-out the book that would be great.

7 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Quoting - tyrch
1) MOV DEST,SOURCE .. got it. It's an intel syntax standard. However with the direction bit, this can change the position of source and dest thereby creating a whole new value for the same code. eg. 89C3h and 8BD8h produce the same instruction of MOV BX,AX. Is one more correct than the other, or is it like ansi C where there are a million ways to produce the same results?

2) (MOV) Immediate to Register/Memory vs. Immediate to Register. These to opcodes look like they do the same function in regards to move to register. Is one prefered to another? Are there advantages to using one vs. the other? The book is very vague and the teacher still has yet to answer me.

1) You probably meant 89h C3h and 8Bh D8h? Writing them as one value means the first byte ends up in the higher memory location, for a 'little endian' architecture like Intel: http://en.wikipedia.org/wiki/Endianness. Anyway, yes, there are sometimes multiple ways to create the same operation. One is not better than the other. But note that x86 can only have one memory operand, and whether it's the first or the second operand depends on the encoding. When both operands are registers, you can choose.

2) The encoding for moving an imm to a reg is shorter than imm to mem/reg. So in general you want to use that one to save on code size.

Quoting - c0d1f1ed

1) You probably meant 89h C3h and 8Bh D8h? Writing them as one value means the first byte ends up in the higher memory location, for a 'little endian' architecture like Intel: http://en.wikipedia.org/wiki/Endianness. Anyway, yes, there are sometimes multiple ways to create the same operation. One is not better than the other. But note that x86 can only have one memory operand, and whether it's the first or the second operand depends on the encoding. When both operands are registers, you can choose.

2) The encoding for moving an imm to a reg is shorter than imm to mem/reg. So in general you want to use that one to save on code size.

Thank you,even these little things help me (and others) out. If you or anyone elsehave any other pearls PLEASE post them. I'mm going to give my classmates a link to this forum. Hopefully we can learn this inspite ofour prof.

Then next question is more of an opinion. This is a 7 week course, with little to no instruction. Realistically, how much can/should we be able to learn? I picked up Ansi C in a 7 week course with no problems, in fact I excelled at the class to the point I was getting more adv assignments than others.

Quoting - tyrch

Thank you,even these little things help me (and others) out. If you or anyone elsehave any other pearls PLEASE post them. I'mm going to give my classmates a link to this forum. Hopefully we can learn this inspite ofour prof.

Then next question is more of an opinion. This is a 7 week course, with little to no instruction. Realistically, how much can/should we be able to learn? I picked up Ansi C in a 7 week course with no problems, in fact I excelled at the class to the point I was getting more adv assignments than others.

Seven weeks should be plenty of time to be reasonable comfortable with assembler programming. Depending on the amount of practice you can do, and what kind of help you can get from the teacher and others. It will also partly depend on what kind of platform you are using. Plain 8086 instructions (no newer CPUs) means "Real Mode" and some kind of MS-DOS like posibilities. If you are a experienced programmer in a high level language like C there should be relativly straight forward to get down to the details of Assembler programming.

Knut J. Norway

Quoting - tyrch

Thank you,even these little things help me (and others) out. If you or anyone elsehave any other pearls PLEASE post them. I'mm going to give my classmates a link to this forum. Hopefully we can learn this inspite ofour prof.

Then next question is more of an opinion. This is a 7 week course, with little to no instruction. Realistically, how much can/should we be able to learn? I picked up Ansi C in a 7 week course with no problems, in fact I excelled at the class to the point I was getting more adv assignments than others.

Hi again! Of course Intel has very godd documentation of all instructions. Look here: http://www.intel.com/products/processor/manuals/index.htm

Particularly Volume 2A and 2B are useful.
If you have more questions about details, just ask!

Knut.

For in-depth information about the encoding formats I can highly recommend http://sandpile.org. The Intel documents obviously have all that information as well, but I find sandpile.org handy as a reference, especially the mod R/M byte and SIB byte tables.

I think real mode 16-bit DOS development is extremely outdated. In my opinion it's far more educational to work on an actual modern platform, so you understand how real world applications work these days. One way to do this is to use Visual C++ Express on Windows, where you can use inline assembly (http://msdn.microsoft.com/en-us/library/4ks26t93(VS.71).aspx).

I can recommend this book for beginners:
Detmer, Richard C: Essentials of 80x86 Assembly Language, Jones & Bartlett 2006.

www.agner.org

Leave a Comment

Please sign in to add a comment. Not a member? Join today