• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 944
  • Last Modified:

Why There Are So Many Assembly Languages? General Questions About Assembly & Conversion to Binaries

1. I have learned Assembly language long time ago. I learned Assembly language of IBM-PC which these assembly instructions recognized by a number of different microprocessors in the intel family, e.g. 8086, 8088, 80186, . . ., and Pentium. Now why there isn't one standard assembly language, like C?

2. If there many assembly languages, which one the most used among microprocessors? Is the one i learned for IBM-PC is the most used? Note, i used to debug on MASM

3. Is 8086 and x86 are microprocessor that just uses different names? If yes, does x here mean 80?

4. Assembly language takes one instruction per line only. It can't do x = y + z in one line. High level language, can do it. So when we compile x = y + z in a high level language, it get translated to assembly first then to machine language. Is this right?

If no, how come machine language takes all these instructions at once, CPU fetches one instruction at a time only, so it will be looking for an assembly code for instructions as the high level language does more than one instruction in a line.....

5. If i code in Assembly & compile my code. What language the compiler is? If the compiler in assembly, then there is no need for a compiler because CPU can read instruction from my assembly code directly! right?

6. I still do not understand, how such a hardware read my instruction?! My instruction is something written on screen, the signal is produced while i was typing these instructions from keyboard, but after that there is signals going out anymore, there just bunch of texts output on screen! so how come my machine read these bunch of texts? If my machine reads my instruction in a binary format, where the major compiler of my OS that compiles everything happens on PC?

7. Why we have base 10, base 8, binary, hex? binary is important for machine code, base 10 is for human to read....base 8, is kind of useless, why do we need it? remember base 10 is readable! so no need for base 8 .......

8. Hex, computers does not understand hex, right? machines deals hex like when it deal with base 10. Hex is used to make long base 10's in a more organized looking. Hence, human cares about base 10 & understand it instantly, no one really understands Hex instantly, so why we bother using it? Remember, we usually convert hex to decimal to know whats behind the hexs, thats why i see no point for us to use it....

9. Is the method of converting "from hex to binary, decimal to binary & vice versa, etc" that we do in pen and paper is exact same algorithm that our machine uses to convert hexes and decimals to binaries? If no, what kind of algorithm our CPU follows to convert decimal & hexes?!

10. Compilers usually written in Assembly, right? Some compilers are written in the same language of its high language, e.g. C has a compiler written in C, as far as i know, so the compiler will need another compiler to compile it. Right? and this can cause slow compilation process....

These questions always confuses me & sounds dummy. I hope i asked them clearly, please answer what you know. I hope i will hear from you.....

sorry for the long boring questions. i got to ask. Otherwise, i'll never learn...
0
F-J-K
Asked:
F-J-K
4 Solutions
 
ai_ja_naiCommented:
1. Because processors are effectively different. And Assembly reflects the microinstructions that the bare metal is capable of execute natively. Think about MMX. Or Vanderpool/Pacifica. Those capabilites added new instructions that sometimes modified so much the entire architecture that a detach from the past was needed.
Event AMD, which is 100% IBM compatible has different instruction sets from Intel ones.

2. Depends on the spreading of a microprocessor model. The more an architecture is widespread, the more that language is used.

3.Because after 8086, we got 80286; and the 80386, 486, 586 (Pentium), 686 (Pentium 4 and after). But a layer of retrocompatibility has always been mantained. So we say that is a x86 (because x is variable) family of processors.

4. Right. A microprocssor, beside the pipelining and parallelism, can do just and instruction per clock cycle. Assembly reflects this limitation.

5. Well, you need before or after to translate those instructions (mov, jmp, ...) to bits, right? :)
The compiled program is just in zeros and ones, remember.

6. Hehe, this is a long and complicated subject, it takes a university course to explain this. I suggest you to get "Computer Architectures" by Andrew Tanenbaum. It's really well written and explained.
HOWEVER, an instruction is interpreted by a rom on microprocessor that has a map which translates instructions in strings of impulses, bit signals. Signals are stored in tiny ram memories, very fast, called registers and then executed by the Arithmetical Logic Unit. Then, the result is stored in another register to be used by other instructions...

7. You say this! Base hex is extremely important, it has the power of representing lots of information in fewer digits. Remember that hex is 16 values , while 10 has only..10 values. Hex holds more information in one. Base octal is useful because a byte has 8 bit. To manipulate bytes octal base serves well.

8. Look the past answer.

9. Yes, it's the same. If not, why should teachers bore us with those nasty operations? :)

10. Yes and no. Actually, C compiler was built with a B compiler in B language; and then they translated the code in C code and RECOMPILED AGAIN with the just produced C compiler. The result was a new C compiler, but written in C and much more performing..
0
 
moorhouselondonCommented:
1.  I programmed with various microprocessors: 8080 series which you know about; the Motorola 6800 which had two Accumulators and less ancillary Registers; the 6502 which was like the 6800 but had improved pointer operations; the RCA Cosmac was the weirdest one, it had several Registers which could each be used as an accumulator - this looked versatile until starting to code with it: I seemed to remember that some registers had to be tied up for things which were behind the scenes with other architectures - such as pushing and popping.

4. Though Assembler appears on one line, the CPU needs to pick up the command from (in many cases) a variable number of memory locations MOV A,C takes up one location, MVI A,01 takes up two, etc.  If the manufacturer had chosen to do something more sophisticated, they could have done, I suspect, but didn't because programmers tended to steer clear of the more esoteric commands in any case.

5.  You need to convert as ai ja na says.  Assembler or compiler will produce a program, but in many cases this is insufficient to run it as the Memory addresses within the program will be relative to the program and will have no knowledge of where things are inside the PC, such as Serial Ports.  The program generally needs to be linked in order for the program to be Loaded and Run.  (Or that's how things used to be, at least).

6.  The Operating System is a program which does lots of very boring things, like wait for a character to be typed at the keyboard.

7.  Octal isn't useful these days (sorry to disagree with ajn on this one - 3 doesn't go into 8 - octal bundles up things three bits at a time).  HP used to use Octal for their Instruction Set.  A real pain in the butt because some instructions were big endian based, others were small endian based.  (counting from the most significant bit to the least significant bit or vice versa - there'd always by an odd bit, or odd two bits left over).  Neither the Address bus nor the Data bus widths were divisible by 3 so it was sometimes difficult to work out that two different looking instructions were the same, they were just bialsed differently.  London Transport used to use Octal for their running numbers on the Tube, they used these things called Programme Machines which were like massive paper tape.  Trains were identified by a 3-bit running number consisting of three octal-digits - you would never see a Metropolitan Line train with a running number with an 8 or 9 in it!  Unix systems I've used used Octal for IP Addresses, confusing when running packet analysis, but not the end of the world - Incidentally IP addresses are simply Radix 256 numbers stitched together with dots.  Hex is absolutely vital in the computer world.








0
 
DJDecayCommented:
1. I have learned Assembly language long time ago. I learned Assemblylanguage of IBM-PC which these assembly instructions recognized by anumber of different microprocessors in the intel family, e.g. 8086,8088, 80186, . . ., and Pentium. Now why there isn't one standardassembly language, like C?

The mnemonic for x86 assembly is fairly standard, if you go outside of that family of processors the mnemonic changes.  Such as RISC Sparc assembly etc..
Assembly mnemonic for x86 is very standadized acrross the different assembly builders you will find, aside from GNU. Instruction pneumonics for 32bit ASM and 64bit ASM is extended with wider registers, no need EAX, EBX etc.. to jump around segments and offsets in byte size addresses and all the good old DOS days MASM/TASM stuff...


2.If there many assembly languages, which one the most used amongmicroprocessors? Is the one i learned for IBM-PC is the most used?Note, i used to debug on MASM

Assembly is a "mnemonic" for CPU instructions a way to represent binary code and data payload and memory allocation into a somewhat humanly readable form. This text is then processed by an "assembler" and a linker if needed to turn it into its native form executable binary. The designer of the mnemonic is responsible for how it is translated into complete machine code.


3. Is 8086 and x86 are microprocessor that just uses different names? If yes, does x here mean 80?

8086 is a MicroProcessor with out 386 or 32 bit capabilities. x86 is a generic term for Intel-based CISC (Complete Instruction Set) families of processors. Including Pentium, Core Duo, VIA/Cyrix and AMD.


4.Assembly language takes one instruction per line only. It can't do x =y + z in one line. High level language, can do it. So when we compile x= y + z in a high level language, it get translated to assembly firstthen to machine language. Is this right?

Depending on the compiler. Very vague question. But yes ultimately it will be turned into one linear type instructions.  


If no, how comemachine language takes all these instructions at once, CPU fetches oneinstruction at a time only, so it will be looking for an assembly codefor instructions as the high level language does more than oneinstruction in a line.....

NO, A High level language turns it into one instruction at a time, based on its optimization and the number of passes it takes to compile it may (in a debugger) look nothing like what you originally expected. For math operations it may even summon the help of a general library of those routines that are already pre-built/pre-written and tried and tested such as c-lib.


5. If i code in Assembly &compile my code. What language the compiler is? If the compiler inassembly, then there is no need for a compiler because CPU can readinstruction from my assembly code directly! right?

>This question makes no sense, sorry.  You don't "compile" assembly code. Many languages >give you the ability to insert processor optimized "in-line" assembly code in a higher end >language like C or other, those will be mostly-touched, but everything else around them will >be turned into machine code. If you're just taking about a ASCII file you're feeding to >TASM/MASM there is no "compilation" of any kind involved. Just translation.

6. I still donot understand, how such a hardware read my instruction?! Myinstruction is something written on screen, the signal is producedwhile i was typing these instructions from keyboard, but after thatthere is signals going out anymore, there just bunch of texts output onscreen! so how come my machine read these bunch of texts? If my machinereads my instruction in a binary format, where the major compiler of myOS that compiles everything happens on PC?

>It reads binary files, there are many standards for these executable files, they contain >HEADERS to allow the operating system to recognize what is in them, and what is the first >instruction to run and how much memory to allocate for the executable and more.




7. Why we have base10, base 8, binary, hex? binary is important for machine code, base 10is for human to read....base 8, is kind of useless, why do we need it?remember base 10 is readable! so no need for base 8 .......

Hex exists as an easy way to represend a BYTE in 2 digit notation.  Bytes value range from 0 to 255 in decimal however in hex you can represent it in 00-FF hence only using two characters, therefore making it easier to present more information on the screen at once.

Also hex is a very handy way of splitting a byte into least significant and most significant bits without doing crazy binary conversion.

So if you have F0   that means   1111:0000 in binary.  FF would be 1111:1111


9.Is the method of converting "from hex to binary, decimal to binary& vice versa, etc" that we do in pen and paper is exact samealgorithm that our machine uses to convert hexes and decimals tobinaries? If no, what kind of algorithm our CPU follows to convertdecimal & hexes?!

CPU does not convert, EACH byte has a value, ultimately stored in BINARY, including your Decimal values. Your high level decimal values in C or other languages have DATATYPES.
Like
integer, signed integer, float etc.. each one of those is converted into binary and depending on the platform you are using are stored in a N amount of bytes and have a _ULTIMATE_ high and low value.

Back in 8086 ASM bit a INT max value was 65535  (which is FF:FF) two bytes, 16 bits.




10. Compilers usually written in Assembly,right? Some compilers are written in the same language of its highlanguage, e.g. C has a compiler written in C, as far as i know, so thecompiler will need another compiler to compile it. Right? and this cancause slow compilation process....

This is a very long question. Google a book on complier design.


These questions alwaysconfuses me & sounds dummy. I hope i asked them clearly, pleaseanswer what you know. I hope i will hear from you.....





sorry for the long boring questions. i got to ask. Otherwise, i'll never learn...
0
 
MysidiaCommented:
(1) Assembly instructions are based on processor instruction set.   Processor instruction sets are uniquely designed for different families of processors.

(2) Generally, the more software written to use the processor, the more popular its assembly language.   X86  is among the most widely used, due to PCs.   But there are other specialized processors like PowerPC  used in various consumer electronics.

(3) No.  x86 refers to  "8086-like" CPUs, the family of processors used in the IBM PCs.

(4) Eventually it will be converted into the machine language.  Whether there is true assembly or not in the middle depends on compiler.

(5) The compiler may be written in its own language.. i.e. a C compiler may be written in C.    In that case, there was at one point a need to bootstrap the compiler.

At some point someone wrote a MINIMAL  C compiler in assembly that was good enough to compile the compiler.     Once the compiler was compiled,  that bootstrapped compiler could be used to compile future versions of the compiler.

At some point someone wrote a MINIMAL assembler in machine language, so they could assemble an assembler written in assembly to machine language, and from then on  use the already-generated executable to prepare future versions of the assembler.


(7)  Base 8 is useful because it is easily converted to binary, and it is useful for representing a byte of text , such as the ASCII character set.

It is more easily converted to binary than Base 10.

(8) Hex is used because it is conveniently used to represent binary bits.
Much more convenient than Base 10,  since  Base16 is a power of 2, and
Base 10 is not.

(9) No.  Your CPU doesn't know anything about hex or decimal, only binary.
Conversion to hex or decimal is done by software, and is purely for
the benefit of humans.

Your OS, application, and compiler software implements the conversion algorithms.

For conversion from binary to hex, a table would typically be used.
Every 3 binary bits corresponds to one octal digit, it is a very simple table lookup.
Every 4 binary bits corresponds to one hex digit, it is a very simple table lookup.

No long sequence of arithmetic operations like division need be involved.








0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now