What is an an assembler?

Discussion in 'Programmer's Corner' started by David Waddell, May 26, 2015.

  1. David Waddell

    Thread Starter New Member

    Dec 3, 2014
    24
    0
    Why do we use an assembler in the production of our program code?

    What purpose does it serve and could we produce code without it?

    I can find any specific answers
     
  2. MaxHeadRoom

    Expert

    Jul 18, 2013
    10,550
    2,374
    Assembler takes the simple mnemonics of the instruction set of a particular CPU and convert directly to the machine binary code used by the particular CPU.
    It is the most direct way of programming, short of actually physically setting binary digits in each instruction location.
    The assembler converts the mnemonics to machine code.
    Max.
     
    wmodavis likes this.
  3. MaxHeadRoom

    Expert

    Jul 18, 2013
    10,550
    2,374
    Incidentally some of the first digital computers in the 70's etc such as PDP8/PDP11 had a row of 12 or 16 switches that had to be set to a certain binary instruction, then an enter switch was used to load the instructions one at a time.
    The program was 'Assembled' before hand by writing the code down word by word to be entered.
    Max.
     
  4. ericgibbs

    AAC Fanatic!

    Jan 29, 2010
    2,503
    380
    Back in the early 1970's, writing the machine code directly was the only way to do it.
    You could buy preprinted coding sheets which showed the address location and code on which you wrote in the details of the program.
    Then each byte of machine code had to be entered manually into the PC via the keyboard.

    The Assembler programs are a big time saver.:)
    E
     
    MaxHeadRoom likes this.
  5. joeyd999

    AAC Fanatic!

    Jun 6, 2011
    2,686
    2,748
    Check the decade, man! Assemblers (as well as high-level languages) have been around since the 50s.

    Jeeze, you probably think we rode our dinosaurs to the discotheque.

    Oh, wait...you're not by chance related to Barry, Robin or Maurice, are you?

    [​IMG]
     
  6. DickCappels

    Moderator

    Aug 21, 2008
    2,656
    632
    An assembler is a lot like a compiler, though it deals directly with the computer hardware and does not use much in the way of abstractions like higher level language such as Pascal and C do.

    An example:

    One might want to load the value 123 (decimal)directly into the accumulator (a common name for a frequently used register in a cpu).

    The programmer would write in the assembler source file:

    LDI, 123

    And the assembler would generate two bytes: 10101001, 01111011 and place them in memory.
     
  7. MaxHeadRoom

    Expert

    Jul 18, 2013
    10,550
    2,374
    ...Or you could do it this way!;)

    Max.

    [​IMG]
     
    cmartinez likes this.
  8. shteii01

    AAC Fanatic!

    Feb 19, 2010
    3,393
    497
    homework
     
    DickCappels likes this.
  9. djsfantasi

    AAC Fanatic!

    Apr 11, 2010
    2,809
    834
    I did it that way on a DECSystem 20 one day when the machine crashed.
     
  10. MaxHeadRoom

    Expert

    Jul 18, 2013
    10,550
    2,374
    I did, I would rather put it behind me!:(
    Max.:)
     
  11. ericgibbs

    AAC Fanatic!

    Jan 29, 2010
    2,503
    380
    Hi Joey,
    I was posting my reply in context of the Home PC in the UK.

    I have been programming and servicing industrial/commercial computers since the late 1950's, notably the Stantec Zebra computer, that initially was programmed using key switches and a telephone dial, I first got my hands on a PDP early the 1960's.

    Regarding dinosaurs, I am a Assemblersaurus I've been at it that long.:rolleyes:.

    Sorry, no relation to the Bee Gees, been asked that question so many times I have lost count.

    Eric
     
    MaxHeadRoom likes this.
  12. Papabravo

    Expert

    Feb 24, 2006
    10,145
    1,791
    I started with FAP (Fortran Assembly Program) for the IBM 7090 in 1962. Probably not many folks left that can make an earlier claim.
     
  13. WBahn

    Moderator

    Mar 31, 2012
    17,750
    4,797
    You might consider working through the Nand2Tetris project. You can probably work through the first six projects, which includes writing the Assembler, in a week or two (I did the first five projects in about four hours, but then things slow down considerably). Everything you need for all the projects plus the textbook contents for the first six projects, are available completely free from the authors' website.
     
  14. Joseph Watson

    New Member

    May 27, 2015
    7
    11
    The computer front panel shown in the photo by MaxHeadRoom is of a PDP-8/f. The PDP-8/m, like the PDP-8/f, followed on the heels of the PDP-8/e. In my early days (not quite as early as those of Papabravo), I programmed PDP-8/m computers, preceded by PDP-8/e, preceded by PDP-8/I, preceded by PDP-8/L, and preceded by PDP-8/S. I still own a PDP-8/S minicomputer that was built in 1966. The "m" and "f" models had LEDs in their front panels. (The first LED I ever saw was in a PDP-8/m.) All the earlier models had light bulbs.

    Nearly all the PDP-8 work was done in assembly language. There were two assemblers: PAL3 and MACRO-8. PAL3 (later called PAL8) was a simple three-pass assembler. MACRO8 also included the ability to create and reference macros.

    Since the PDP-8 architecture was a simple one, its assembly language might make a good one to use as an example for answering these questions.

    In the PDP-8 assembly language, symbols were limited to 6 characters in length. The instruction set was based on a 12-bit word of which 3 bits were the opcode. Therefore, there were basically 8 instructions. One of them was microprogrammed to perform many operations that did not need to reference an operand. All the numbers were expressed in octal (using only the digits 0 through 7).

    Here is an example of an assembler listing for a very small assembly language program for a PDP-8 series computer:
    Code (Text):
    1.  
    2. 0020              *0020        /SET THE ORIGIN FOR MEMORY VARIABLES
    3. 0020 0002 NUM1,   2            /NUM1 CONTAINS ONE NUMBER TO BE ADDED
    4. 0021 0005 NUM2,   5            /NUM2 CONTAINS ANOTHER NUMBER TO BE ADDED
    5. 0022 0000 RESULT, 0            /RESULT WILL RECEIVE THE SUM OF THE TWO NUMBERS
    6.  
    7. 0200              *0200        /SET THE ORIGIN FOR THE START OF THE PROGRAM
    8. 0200 7200         CLA          /CLEAR THE ACCUMULATOR REGISTER
    9. 0201 1020         TAD   NUM1   /ADD THE CONTENTS OF NUM1 TO THE ACCUMULATOR
    10. 0202 1021         TAD   NUM2   /ADD THE CONTENTS OF NUM2 TO THE ACCUMULATOR
    11. 0203 3022         DCA   RESULT /STORE THE CONTENTS OF THE ACCUMULATOR INTO RESULT
    12. 0204 7402         HLT          /STOP RUNNING[/FONT]
    13.  
    The first column of numbers consists of memory addresses. The next column indicates the numeric data that is to be stored at those memory addresses. As far as the computer is concerned when the program is eventually run, the program consists only of the numeric information in those first two columns of numbers. The computer does all of its work by decoding those numeric codes stored in its memory.

    Unfortunately, humans do not relate very well to understanding and composing a program in those strictly numeric terms.

    On each line of the program listing, everything appearing to the right of those two columns of numbers is called the source file and is what the programmer writes. In this case, it is in PDP-8 assembly language.

    The assembler is also a computer program, usually provided by the manufacturer of the computer system. The purpose of the assembler is to be able to read the human-written assembly language source file and translate it to the numbers that appear in the listing and which will then be stored into the computer to allow the program to be run. So the assembler is a tool that alleviates the tedious work of turning computer instruction mnemonics into the numeric codes for the computer's memory.

    Yes, there are other ways to produce code for a computer. The most common one uses high-level languages that let programmers express their ideas on a more abstract level. This relieves the programmer of having to think about many of the details involving the computer's hardware at all. Most compilers take the approach of first translating the processing steps set forth in the programmer's high-level language source file to a lower-level assembly language source file. Then the compilation process uses an assembler to convert its automatically-generated assembly language source file to the numeric information that is to be stored into the computer's memory.
     
    absf, MaxHeadRoom and djsfantasi like this.
  15. MrChips

    Moderator

    Oct 2, 2009
    12,446
    3,362
    I cut my teeth on a PDP-8/S.

    To be more precise, only the second column of numbers are stored in the computer's memory. You will notice that the first column, which is the memory location, increases sequentially and hence only the first location of the next segment of code is needed, for example 0200.

    Note that the data 7200 is really stored as 111010000000 in the computer. The computer uses binary notation, not decimal, hexadecimal nor octal.
     
  16. MaxHeadRoom

    Expert

    Jul 18, 2013
    10,550
    2,374
    I forget the version I worked on, but I know you could visibly see each bit of memory!
    Being magnetic core data storage, if an arc welder was used close by, it would wipe the memory.
    Max,
     
  17. Papabravo

    Expert

    Feb 24, 2006
    10,145
    1,791
    Many people that worked on early DEC computers like PDP-1, PDP-5, and PDP-8 used the venerable ASR Model 33 Teletype machine as the primary input output device. It had a continuous roll of paper to print on, a mechanical keyboard, a paper tape reader, and a paper tape punch. This machine is what led to the original Line Oriented Editors.
     
  18. djsfantasi

    AAC Fanatic!

    Apr 11, 2010
    2,809
    834
    If you were lucky enough, you could score a DEC Tape and store your programs on it. I worked on several DEC machines (one with a round monitor on which we played Space War) at MIT while I was in High School.
     
  19. Papabravo

    Expert

    Feb 24, 2006
    10,145
    1,791
    I believe it might have been a 338 display. It was a vector graphic that could use DMA to pick up the vectors from memory. The first one I saw was at PPL.
     
Loading...