Shop OBEX P1 Docs P2 Docs Learn Events
assembly vs. machine code — Parallax Forums

assembly vs. machine code

David BDavid B Posts: 592
edited 2006-04-11 20:30 in Propeller 1
I've been browsing over all the Propeller discussions, coming up to speed, and I'm a little confused by the terminology.

From my computing education and experience, the term "assembly code" used to describe human-readable text, like this:

entry·· mov··· t1,par
· ······· add···· t1,#4 << 2
··· ····· rdlong· t2,t1
····· ··· mov···· rxmask,#1
······· · shl··· ·· rxmask,t2

but what actually runs in the processor was referred to as "machine code" and appears like a list of 32 bit numbers, like this (made-up) example, shown here in hex; often described as the ones and zeroes that hardware understands:

$01FA76AB
$3BFEA76A
$22D3CD4A

With the simpler processors of the past, there was no confusion between the two because all processors ran only machine code.

But as we get into more sophisticated architectures like the Propeller, which can accept both SPIN byte-code tokens and assembly (machine code?), I want to verify my understanding.

Assembly, as conventionally referred to, isn't run in the Propeller, right? That text, entered in the IDE, is translated by the SPIN IDE, using something similar to SASM, into machine code, right?

But with so many people referring to the native Propeller code as assembly, I think I'd be swimming against the tide to insist on using the term "machine code".

So do we use the term "assembly" to refer to both what people can write in the IDE, as shown above, and its translation, formerly known as machine code, that runs in the Propeller?


·

Comments

  • Kaos KiddKaos Kidd Posts: 614
    edited 2006-04-11 18:51
    David:
    Assembly code, as you deplicted above, is the "un assembled" version of the code, the stuff we humans can read with little to no effort.
    This text is then assembled in to the actual machine code the processor executes.
    Machine code is not tokens or spin byte-code, it is the actual instruction as viewed and executed by the processor.
    Machine code can be visulized in HEX, as you deplicted aboce, BIN, as you noted above, or in any numberical system of your choice.
    It's only a repersentaion of the actual command being used.
    Spin Byte-Code, also called Tokens are a intermediary step between the Spin Language and the machine code needed to execute a given Spin command.

    Spin Basic = Ascii commands used to expreass what the programmer wants the controller to do.
    Byte-Tokens = The compiled (this is compiled because of optimizations, inclusions ect) version of the Spin Basic.
    Btye-Tokens are downloaded into either the Propeller's RAM or EEPROM for later or immedate execution by the Spin interperter. <--- very important issue here!
    Assembly = The ascii commnads used to express what the programmer wants the controller to do.
    Machine code = the assembled version of the Assembly code.
    Machine code is downloaded into into the propeller's ram or EEPROM for later or immedate execution of the propeller (not the interperter) <--- very important issue here!

    (Some of the above states are simplifed here, and as noted, they are delibertly simplified.)

    Ok, I hope this helps some.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Just tossing my two bits worth into the bit bucket


    KK
    ·
  • Martin HebelMartin Hebel Posts: 1,239
    edited 2006-04-11 18:51
    Keep in mind the Propeller can be programmed in classic Assembler - With opcodes, operands, etc. It is directly translated to Machince code.

    But, in Spin, byte code tokens are created and stored. The Cog, running an interpreter, reads the byte code and carries out 100-500 machine code instructions to perform that high level operation.

    In your post you were mixing the two up a little I think.

    -Martin

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Martin Hebel
    Southern Illinois University Carbondale - Electronic Systems Technologies

    Personal Links with plenty of BASIC Stamp info
    StampPlot - Graphical Data Acquisition and Control
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2006-04-11 18:56
    Hi David,

    The Propeller runs machine code assembled by the IDE. It also has a built-in interpreter written in machine code that interprets bytecodes compiled by the IDE. Assembly code and machine code are used, loosely, to mean the same thing. But you are right: assembly code is the human-readable version of machine code. But the one-to-one correspondence between them makes it easy to blur that distinction.

    -Phil
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-04-11 19:46
    David -

    Phil's answer is excellent, but I'd like to parse it out a bit, just for emphasis. Please note carefully what Phil has said in each of these two phrases:

    "The Propeller runs machine code assembled by the IDE."

    By "runs" Phil is expressing that the machine code actually executes independently, and at the native code level. This is a one process, stand-alone method of programming, thus it is very fast.

    Here is the next important phrase:

    The "interpreter written in machine code that interprets bytecodes compiled by the IDE."

    Note that the interpreter doesn't run (execute) the "bytecodes" (sometimes called tokens) per se, but the interpreter itself does execute and does so in native mode. In essense it "decrypts" the bytecodes, and based on their contents it knows which internal machine code routines, built-in to the Propeller system, need to be executed, and in which order. It does all this on-the-fly, thus is must be very efficiently coded.

    This is a multi-part process, which is dependent on the interpreter being present, thus it is a good deal slower than the assembler method of programming.

    I hope that breaks it apart for you. There's really no magic here, just two separate methods of programming the Propeller.

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    <!--StartFragment -->

    Post Edited (Bruce Bates) : 4/11/2006 7:55:32 PM GMT
  • David BDavid B Posts: 592
    edited 2006-04-11 20:30
    thanks, everyone. I think I get it.

    The spin byte-code mechanism seems straightforward enough to understand; it was the use of the term "assembly" to mean several different things that was unclear to me.

    I couldn't believe that the Propeller itself was actually accepting text like "mov t1,par" but that's what it seemed like people were saying.

    David
Sign In or Register to comment.