[ACCEPTED]-What's the relationship between assembly language and machine language?-instruction-set

Accepted answer
Score: 41

Assembly language is a convenience mechanism 12 over the machine language. With assembly 11 language you use mnemonic sequences instead 10 of numeric operation codes and can use symbolic 9 labels instead of manually calculating offsets. It 8 also protects you from really dumb errors 7 - like typing a malformed processor instruction.

Otherwise 6 the assembly language is the equivalent 5 of the machine language. Sometimes you will 4 have an old assembler that will not support 3 mnemonics for some instructions of the newer 2 processors - then you can still insert operation 1 codes directly into the program.

Score: 19

Machine language is the "Bit encoding" of 16 a CPU's opcodes.

Assembly langauge is the 15 "Symbolic encoding" of a CPU's opcodes.

So 14 for Example Symbolically:

loop:  dec R1    # Decrement register R1
       bnq loop  # Branch if not equal to zero to
                 # address "loop"

Becomes Bit encoding:

# Mythical CPU Machine code 4 bits operation,
#                           4 bit "option"
       0x41      # 4 is a "dec" and represents r1;
       0x7E      # 7 is bnq and E means PC -2;

Generally 13 it's a one to one relationship, however 12 some assembly languages will ocationally 11 have extra assembly instructions that map 10 to either multiple machine code instructions 9 or reuse another opcode. Such as using 8 machine code "xor R1,R1" as a "clr R1" or 7 something very similar.

In addition assembly 6 languages will tend to support "macro programming" which 5 in the 80's when assembly was used extensively 4 gave the source code a more "high level" appearance. I've 3 personally written assembly macros that 2 looked like "plot x,y" and "Hex Val" to 1 simplify common operations.

For example:

# Mythically CPU Macro
.macro spinSleep x,y
            ld #x,y
localLoop:  dec y
            brq localLoop
.endmacro
# Macro invocation
            spinSleep 100,R1
# Macro expantion
            ld #100,R1
localLoopM: dec R1
            brq localLoopM   # localLoopM is "Mangled" for localization.
Score: 7

I found a really good explanation, thought 27 to post it here, so that others could read 26 it:

Machine language is the actual bits used 25 to control the processor in the computer, usually 24 viewed as a sequence of hexadecimal numbers 23 (typically bytes). The processor reads 22 these bits in from program memory, and 21 the bits represent "instructions" as 20 to what to do next. Thus machine language provides 19 a way of entering instructions into a 18 computer (whether through switches, punched 17 tape, or a binary file).

Assembly language 16 is a more human readable view of machine 15 language. Instead of representing the 14 machine language as numbers, the instructions and 13 registers are given names (typically abbreviated 12 words, or mnemonics, eg ld means "load"). Unlike a 11 high level language, assembler is very 10 close to the machine language. The main 9 abstractions (apart from the mnemonics) are 8 the use of labels instead of fixed memory 7 addresses, and comments.

An assembly language 6 program (ie a text file) is translated 5 to machine language by an assembler. A disassembler 4 performs the reverse function (although 3 the comments and the names of labels will 2 have been discarded in the assembler process).

Source 1 : What is difference between machine language and assembly language?

Score: 5

In Assembly, instructions are easier-to-understand 5 representations of CPU instructions.

But 4 the assembler also makes, for example, addressing 3 easier:

  • In machine language you have to know the distance (in address space) between where you are and where you want to jump to
  • In Assembly language you call one address "iWantToJumpHere" and then you can say "jump iWantToJumpHere"

This makes assembly much easier to 2 maintain, especially when the distance between 1 the addresses changes.

Score: 1

machine language is what the chip understands Assembly 5 is what you understand

Every assembly instruction 4 has a machine language equivalent. x86 3 has a few single-byte instructions, but 2 they're variable length and can be up to 1 15 bytes long (including optional prefixes)

 machine code bytes |   x86 assembly language
8D B0 00 36 65 C4    lea    esi, [eax - 1000000000]     
BB 00 FC FF FF       mov    ebx, -1024
43                   inc    ebx
41                   inc    eax
3B CA                cmp    ecx,edx
C3                   ret

C5 F5 72 D2 01       vpsrld ymm1,ymm2,0x1        ; AVX2
C5 F5 D4 6D 88       vpaddq ymm5,ymm1,YMMWORD PTR [ebp-0x78]
C5 CD D4 AD 68 ff ff ff vpaddq ymm5,ymm6,YMMWORD PTR [ebp-0x98]
Score: 0

Assemble level language is the first conscious 3 step towards making the programming simple 2 by allowing the programmers to write mnemonics 1 instead of binary code(machine code).

Score: 0

Assembly language is first converted to 5 machine language by the assembler. which 4 is stored in memory (RAM) processor/cup 3 fetch it and store in from memory to register 2 and follow the instruction set one after 1 one.

Score: 0

Machine Language

Machine language consists of ones and zeros. so 11 it's so hard to understand by looking at 10 it. so if we want to modify the code , it 9 will be a huge problem. Machine languages 8 is also a programming language(1st Gen).our 7 computer CPU can directly execute that machine 6 code without any assembler.

Assembly Language

assembly language 5 consists of syntax , number , and letter. it's 4 easy to modify existing code. so our machine 3 cannot understand that program. so machine 2 using an assembler to convert that assembly 1 language code into machine code.

More Related questions