Table 1. Software Hierarchy Levels. Level Description Application Program Software designed for a particular class of applications. High-Level Language (HLL) Programs are compiled into either assembly language or machine language. Each statement usually translates into multiple machine language instructions. Examples are C++, Pascal, Java, and Visual Basic. Operating System Contains procedures that can be called from programs written in either high-level language or assembly language. This system may also contain an application programming interface (API). Assembly Language (ASM) Uses instruction mnemonics that have a one-to-one correspondence with machine language. Machine Language (ML) Numeric instructions and operands that can be stored in memory and directly executed by the computer processor. Essential Tools • An assembler is a program that converts source-code programs into a machine language (object file). • A linker joins together two or more object files and produces a single executable file. • A debugger loads an executable program, displays the source code, and lets the programmer step through the program one instruction at a time, and display and modify memory. Figure 1. Machine Language Generation by ASM and HLL programs. ASM ML ML HLL ML ML ML Table 2. Comparison of Assembly Language to HLLs. Type of Application High-Level Language Assembly Language Business application software, written for single platform, medium to large size. Formal structures make it easy to organize and maintain large sections of code. No formal structure. Programmer must impose an artificial structure. Hardware device driver. Language may not provide for direct hardware access. Awkward coding techniques must be used, resulting in possible maintenance problems. Hardware access is straightforward and simple. Easy to maintain when the programs are short and well documented. Business application written for multiple platforms (different operating systems). Usually very portable. The source code can be recompiled on each target operating system with minimal changes. Must be recoded separately for each platform, often using an assembler with a different syntax. Difficult to maintain. Embedded systems and computer games requiring direct hardware access. Produces too much executable code, and may not run efficiently. Ideal, because the executable code is small and runs quickly. Figure 2. Assembly Language Subroutines Used as Hardware Interfaces. Application Program Interface Subroutine Hardware Operating System Device Driver Subroutine Machine Language • Consists of binary numbers • The "native" language of the computer • Each ML instruction contains an op code (operation code) and zero or more operands. • Examples: Opcode Operand Meaning ------------------------------------------------40 increment the AX register 05 0005 add 0005 to AX Page 7: Bits, Bytes, and Doublewords: byte byte 0 0 1 0 0 1 1 0 0 1 1 0 1 01 0 word Each 1 or 0 is called a bit. bit Table 3. Storage Sizes and Ranges of Unsigned Integers. Storage Type Bits Range (low - high) Unsigned byte 8 0 to 255 Unsigned word 16 0 to 65,535 Unsigned doubleword 32 0 to 4,294,967,295 Unsigned quadword 64 0 to 18,446,744,073,709,551,615 Table 4. Digits in Various Number Systems. System Base Possible Digits Binary 2 01 Octal 8 01234567 Decimal 10 0123456789 Hexadecimal 16 0123456789ABCDEF Page 9. ASCII Digit String. Format ASCII binary Value "01000001" ASCII decimal "65" ASCII hexadecimal "41" ASCII octal "101" Table 5. Binary Bit Position Values. 2n Decimal Value 2n Decimal Value 20 1 28 256 21 2 29 512 22 4 210 1024 23 8 211 2048 24 16 212 4096 25 32 213 8192 26 64 214 16384 27 128 215 32768 Figure 3. Converting Binary to Decimal. 8 +1 9