Docstoc

Second Generation of PL

Document Sample
Second Generation of PL Powered By Docstoc
					    Second Generation of
Programming Language (1950s)
           Group 2
      Levels of Programming Languages
                          class Triangle {
  High-level program            ...
                            float surface()
                              return b*h/2;
                                   }
  Low-level program          LOAD r1,b
                             LOAD r2,h
                             MUL r1,r2
                             DIV r1,#2
                                RET
Executable Machine code   0001001001000101
                          0010010011101100
                           10101101001...
Second Generation of PL

• The second generation of code was
  called assembly language.
• Assembly language turns the
  sequences of 0s and 1s into human
  words like 'add'.
• Assembly language is always
  translated back into machine code by
  programs called assemblers.
2GL: Assembly Language

• Assembly language programs are made
  up of instructions written in mnemonics.
• A mnemonic system for representing
  machine instructions
  – Mnemonic names for op-codes
  – Identifiers: Descriptive names for
    memory locations, chosen by the
    programmer
2GL: Assembly Language (con’td.)

 -Each instruction had two parts:
   Operation code, Operand
Assembly Language Instructions
 • Built from two pieces
         Add R1, R3, 3



   Opcode            Operands
What to do with     Where to get
   the data         data and put
(ALU operation)      the results
 Types of Opcodes
• Arithmetic, logical
   – add, sub, mult
   – and, or
   – Cmp
• Memory load/store
   – ld, st
• Control transfer
   – jmp
   – bne
• Complex
   – movs
 Operands
• Each operand taken from a particular
  addressing mode:
• Examples:
Register        add r1, r2, r3
Immediate       add r1, r2, 10
Indirect        mov r1, (r2)
Offset          mov r1, 10(r3)
PC Relative     beq 100

• Reflect processor data pathways
2GL: Assembly Language syntax
   • An assembly language program consists of
     statements. The syntax of an assembly language
     program statement obeys the following rules:
     - Only one statement is written per line
     - Each statement is neither an instruction or an assembler
     directive
     - Each instruction has an op-code and possibly one or more
     operands
     - An op-code is known as a mnemonic
     - Each mnemonic represents a single machine instruction
     - Operands provide the data to work with
      Program Statement
• The general format for an assembly
  language program statement is as follows:
Name mnemonic operand (destination), operand (source) ; comment




MOV    AX,    0867H         ; Statement line with a label field
  Assembled, Compiled, or
   Interpreted Languages
• All programs must be translated
  before their instructions can be
  executed.
• Computer languages can be grouped
  according to which translation
  process is used to convert the
  instructions into binary code:
  – Assemblers
  – Interpreters
  – Compilers
 Assembled, Compiled, or
  Interpreted Languages
• Assembled languages:
  – Assembler: a program used to translate
    Assembly language programs.
  – Produces one line of binary code per
    original program statement.
    • The entire program is assembled before the
      program is sent to the computer for
      execution.
            Assembly
              code




Assembler

                       Object code
Tools for Assembler Programmer
Flat Assembler
8085 SDK ( System Design Kit)
Netwide Assembler
NewBasic x86 assembler
Pass32 Assembler
  Assembled, Compiled, or
   Interpreted Languages
• Interpreted Languages:
  – Interpreter: A program used to translate high-level
    programs.
  – Translates one line of the program into binary code
    at a time:
     • An instruction is fetched from the original source code.
     • The Interpreter checks the single instruction for errors. (If
       an error is found, translation and execution ceases.
       Otherwise…)
     • The instruction is translated into binary code.
     • The binary coded instruction is executed.
     • The fetch and execute process repeats for the entire
       program.
   Assembled, Compiled, or
    Interpreted Languages
• Compiled languages:
  – Compiler: a program used to translate high-level
    programs.
  – Translates the entire program into binary code before
    anything is sent to the CPU for execution.
     • The translation process for a compiled program:
       – First, the Compiler checks the entire program for syntax errors in
         the original source code.
       – Next, it translates all of the instructions into binary code.
          » Two versions of the same program exist: the original source
             code version, and the binary code version (object code).
       – Last, the CPU attempts execution only after the programmer
         requests that the program be executed.
Assembly Language Examples:
                                                        Data Allocation
Programs that calculates the average of 2 numbers         Directives
                   .model small

                   .stack 200.data   max temp DB 92h
                                     min temp DB 52h        Predefined equates
Memory Model
 Directives                          avg temp DB ?              Directive
                   .code
                   .startup
                                     mov ax, @data
                                     mov ds, ax
                                     mov al, max temp
                                     add al, min temp
                                     mov ah, 00h
                                     adc ah, 00h
                                     mov bl, 02h
                                     div bl
                                     mov avg temp, al

                   .exit
                   end
Assembly Language Examples:
      The Hello word program in Assembly
     .model small
     .stack 200

     .data
             greeting db ‘hellow world!’, 13, 10, ‘$’
     .code
      mov ax, @data
      mov ds, ax
      mov ah, 9
      mov dx, offset greeting
      int 21h
      mov ah, 4ch
      int 21h
     end
Group 2 Members:
Renante Rebucas
Amy Alvarado
Sheryl Autida
Claire Apolo
Jamiela Tano
Marie Mae Laspiñas

				
DOCUMENT INFO
Description: The second generation of code was called assembly language. Assembly language turns the sequences of 0s and 1s into human words like 'add'. Assembly language is always translated back into machine code by programs called assemblers.