I’m a little confused over the concept of machine code…
Is machine code synonymous to assembly language?
What would be an example of the machine code in LC-3?
I’m a little confused over the concept of machine code… Is machine code synonymous
Share
Assembly instructions (
LD,ST,ADD, etc. in the case of the LC-3 simulator) correspond to binary instructions that are loaded and executed as a program. In the case of the LC-3, these “opcodes” are assembled into 16-bit strings of 1s and 0s that the LC-3 architecture is designed to execute accordingly.For example, the assembly “ADD R4 R4 #10” corresponds to the LC-3 “machine code”:
0001100100101010Which can be broken down as:
Note that each opcode has a distinct binary equivalent, so there are 2^4=16 possible opcodes.
The LC-3 sneakily deals with this problem by introducing those flag bits in certain instructions. For
ADD, those two bits change depending on what we’re adding. For example, if we are adding two registers (ie. “ADD R4 R4 R7” as opposed to a register and a value) the bits would be set to01instead of10.This machine code instructs the LC-3 to add decimal 10 to the value in register 4, and store the result in register 4.