1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

basic doubt

Discussion in 'Assembly Language Programming (ALP) Forum' started by sonika jha, Sep 1, 2016.

  1. sonika jha

    sonika jha New Member

    Joined:
    Sep 1, 2016
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    Gender:
    Female
    being a newbie I have a very basic doubt -as in high level language though to some extent assembly level language also uses simple english words in programming then why does the later require knowing the hardware details of the computer??thnku...
     
  2. David Ledger

    David Ledger New Member

    Joined:
    Oct 21, 2010
    Messages:
    11
    Likes Received:
    7
    Trophy Points:
    3
    Location:
    Gloucester UK
    The most direct, lowest level way of programming is binary (or hex, octal ...) where you directly specify which bits are set and unset in each byte (or word) of a part of the computer's memory such that, when the cpu's 'Program Counter' is set to an address that you specify within the range you've set, and the cpu allowed to run, the task you want is performed. Obviously, the bit patterns you set must correspond to the instruction set of the cpu, and so vary according to the model of (in these days) cpu chip. Not only will the the bit patterns required for a program vary from say an Intel IA32 to a Motorola 68000, it can vary between different members of a single cpu family depending on what the differences between the family members are.

    An Assembler is a program that converts some text that's human understandable into the bit patterns required for the target cpu. I haven't done any real assembler programming since moving away from 8-bit systems in '83, but back then I wouldn't have described assembler code as "simple english words". From your question I guess things have moved on since then. We used to write assembly code using three letter codes, each code representing a single declaration or instruction like TCA meaning 'twos compliment add' to add the contents of a memory word into the accumulator, and DCA meaning 'deposit accumulator into a memory location and clear it (the accumulator)'. These were for the PDP8 (12 bit cpu), the second assembler I used, so I can remember them. I've used so many since then that I've forgotten the later ones. The terseness was partially due to the desire to keep keystrokes down and partly because we had so little memory. You had to know what you were doing and the codes were so much easier than hex or octal, that no-one expected anything more. I can't imagine what "simple english words" assembly code would look like unless they are just macros built on top.

    You can compile the same high level language program on multiple architectures, but the compiler still has to know what the target hardware is and be able to convert the higher level thoughts expressed into assembly code for that hardware. That usually isn't a problem because the compiler itself usually runs on the same hardware anyway. Cross-compiling just needs the compiler to contain information about different targets and to be told what the target is.

    So a compiler, assembler and assembly language are target dependent, but the way you express what you want to happen in a high level language isn't.

    David -- hex/octal since '69, assembler since '70, interpreted Basic since '75, Modula in '82, Unix & C since '83, now Unix shell, Perl, PHP ...
     
    sonika jha and shabbir like this.

Share This Page