This section introduces learners to the various supports offered by programming languages starting with the low-level to the high level programming languages.
Architecture support from low level to high level languages is in the following ways;
Abstraction in software design;
1. Assemble-level abstraction
A programmer who writes directly with the raw machine instruction set. Expressing the program in terms of instructions, addresses, registers, bytes and words
2. High-level languages
Allows the programmer to think in terms of abstractions that are above the machine level. The programmer may not even know on which machine the program will ultimately run. The RISC philosophy focusing instruction set design on flexible primitive operations from which the complier can build its high level operations
3. Data types
a) ARM support for characters
For handling characters is the unsigned byte load and store instruction
b) ANSI (American National Standards Institute) C basic data types
Defines the following basic data types –
- Signedandunsignedcharactersofatleasteightbits–Signedand unsigned short integers of at least 16 bits – Signed and unsigned integers of at least 16 bits – Signed and unsigned long integers of at least 32 bits – Floating-point, double and long double floating-point numbers – Enumerated types – Bit fields (sets of Boolean variables).
- The ARM C compiler adopts the minimum sizes for each of these types
- The standard integer uses 32-bit values
c) ANCI C derived data types
- Defines derived data types – Arrays, Functions, Structures, Pointers, Unions
- ARM pointers are 32 bits long and resemble unsigned integers
- The ARM C compiler aligns characters on byte boundaries, short integers at even addresses and all other types on word boundaries
d) ARM architectural support for C data types
- Provides native support for signed and unsigned 32-bit integers and for unsigned bytes, covering the C integer, long integer and unsigned character types
- For arrays and structures: base plus scaled index addressing
- Current versions of the ARM include signed byte and signed and unsigned 16-bit loads and stores, providing some native support for short integer and signed character types
a) Register use
- The key to the efficient evaluation of a complex expression is to get the required values into the registers in the right order and to ensure that frequently used values are normally resident in registers
- Optimizing this trade-off between the number of values that can be held in registers and the number of registers remaining is a major task for the complier
b) ARM support
- The 3-address instruction format used by the ARM gives the compiler the maximum flexibility
- Thumb instructions (generally 2-address) – restricts the compiler’s freedom to some extent – smaller number of general registers also makes its job harder
c) Accessing operands
- A procedure will normally work with operands that are presented in one of the following ways, and can be accessed as indicated as an argument passed through a register – The value is already in a register, so no further work is necessary as a argument passed on the stack – Stack pointer (r13) relative addressing with an immediate offset known at compile-time allows the operand to be collected with a single LDR
- As a constant in the procedure’s literal pool – PC-relative addressing, again with an immediate offset known at compile-time, gives access with a single LDR
- As a local variable – Local variables are allocated space on the stack and are accessed by
- a stack pointer relative LDR
- As a global variable – Global (and static) variables are allocated space in the static area and are accessed by static base (is usually in r9) relative addressing
d) Pointer arithmetic
- Arithmetic on pointers depends on the size of the data types that the pointers are pointing to
- If a variable is used as an offset it must be scaled at run-time
- If p is held in r0 and i in r1, the change top may be compiled as: ADD r0, r0, r1, LSL #2 ; scale r1 to int
- The declaration: int a; – a reference to a[i] is equivalent to the pointer-plus-offset form *(a+i)
The section lists several supports that can be got by using the various programming level operations. This can include abstraction, pointer arithmetic, arrays etc.
1. Explain the following supports as obtainable in application of the various programming levels
- Abstraction; is a technique for managing complexity of computer systems. It works by establishing a level of complexity on which a person interacts with the system, suppressing the more complex details below the current level.
- Pointer arithmetic: is another way to traverse through an array.
2. Describe Low-level programming language; is a programming language that provides little or no abstraction from a computer’s instruction set architecture—commands or functions in the language map closely to processor instructions. it refers to refers to either machine code or assembly language. The word “low” refers to the small or nonexistent amount of abstraction between the language and machine language; because of this, low-level languages are sometimes described as being “close to the hardware.” Because of the close relationship between the language and the hardware architecture programs written in low-level languages tend to be relatively non-portable. Low-level languages can convert to machine code without a compiler or interpreter. A program written in a low-level language can be made to run very quickly, with a small memory footprint.