Page 18 - DCAP102_DCAP_401_Foundations of Computer Programming
P. 18

Unit 1: Foundation of Programming Languages




          Some other examples of using these directives are:                                    Notes

          TEMP           DB     0111001B      ; Binary value in byte operand
                                              ; named temp
          VALI           DW     7341Q         ; Octal value assigned to word
                                              ; variable
          Decimal        DB     49            ; Decimal value 49 contained in
                                              ; byte variable

          HEX            DW     03B2AH        ; Hex decimal value in word
                                              ; operand
          ASCII          DB     ‘EXAMPLE’     ; ASCII array of values.

          1.6 Machine Level Language

          Although computers can be programmed to understand many different computer languages,
          there is only one language understood by the computer without using a translation program,
          this language is called the machine language or the machine code of the computer. Machine code
          is the fundamental language of a computer and is normally written as strings of binary 1s and
          0s. the circuitry of a computer is wired in such a way that it immediately recognizes the machine
          language and converts it into the electrical signals needed to run the computer.
          An instruction prepared in any language has a two part format, as shown in Figure 1.1. The fi rst
          part is command or operation, and it tells the computer what function to perform. Every computer
          has an operation code or opcode for each of its functions. The second part of the instruction is the

          operand, and it tells the computer where to find or store the data or other instructions that are to
          be maintained. Thus, each instruction tells the control unit of the CPU what to do and the length
          and location of the data field are involved in the operation. Typical operations involve reading,

          adding, subtracting, writing and so on.
                                     Figure 1.1: Instruction Format


                                 OPCODE                 OPERAND
                              (operation code)       (Address/Location)


          We already know that all commuters use binary digits (0s and 1s) for performing operations.
          Hence, most computers machine language consists of strings of binary numbers and is the only
          one the CPU directly understands. When stored inside the computer, the symbols which make
          up the machine language program are made up of 1s and 0s.

                 Example: A typical program instruction to print out a number on the printer might be.

          101100111111010011101100110000111001
          The program to add two numbers in memory and print the result look something like the
          following:
          001000000000001100111001

          001111000000111111000111





                                           LOVELY PROFESSIONAL UNIVERSITY                                    11
   13   14   15   16   17   18   19   20   21   22   23