Programmers view
- A programmer
- writes the program instructions that carryout the desired functionality.
- may need not to know detailed information about the processors architecture or operation.
- Instead may deal with architectural abstraction.
- The level of abstraction depends on the level of programming.
The Two-levels of programming are
- Assembly language programming.
- Structured-language programming.
- Assembly language programming:- represents processor specific instructions as mnemonics.
- Structured language programming:- uses processor independent instructions.
- A compiler automatically translates processor independent instructions into processor specific instructions.
Instruction set
The assembly language programmer must know the processors instruction set.
- The instruction set describes the bit configurations in IR forms assembly instructions which in turn forms assembly program.
- Instructions are classified into three categories.
- Data transfer instructions:- move data between memory and registers, between input-output channels and registers and between registers themselves.
- Arithmetic Logical instructions:- configure the ALU to carry out a particular function.
- Channel data from the registers to the ALU, ALU to registers.
- Branches can be further categorized as being unconditional jumps, conditional jumps or procedure call and return instructions.
- Unconditional jumps always determine the address of the next instruction.
- While conditional jumps checks the condition to jump to a particular address.
- An instruction set has two parts opcode field, operand field.
- Opcode field:- specifies the operation to take place during the instruction.
- Operand field:- specifies the location of the actual data that takes part in an operation.
- Source operands serve as input to the operation, while a destination operand stores the output.
- The number of operands per instruction varies among processors.
- The operand field may indicate the data’s location through one of several addressing modes.
Addressing modes
- In immediate addressing, the operand field contains the data itself.
- In register direct addressing, the operand field contains the address of a datapath register in which the data resides.
- In register-indirect addressing, the operand field contains the address of a register, which in turn contains the address of a memory location in which the data resides.
- In direct addressing, the operand field contains the address of a memory location in which the data resides.
- In indirect addressing, the operand field contains the address of a memory location, which in turn contains the address of a memory location in which the data resides.

- Figure 2.6 shows a (trivial) instruction set with 4 data transfer instructions, 2 arithmetic instructions, and 1 branch instruction, for a hypothetical processor.

- Figure 2.7(a) shows a program, written in C, that adds the numbers 1 through 10. Figure 2.7(b) shows that same program written in assembly language using the given instruction set.

Program and data memory space
- The ES programmer
- must be aware of the size of program and data memory.
- must check on chip program and data memory.
- must not exceed program and data memory limits.
Registers
- The assembly-language programmer
- Must know how many registers are available for data storage.
- Must be familiar with registers with special functions.
- Such registers are used for configuring built-in timers, counters, and serial communication devices.
I/O
- The programmer
- should be aware of the processor’s (I/O).
- can read or write a port by reading or writing a special register.
- One common I/O facility is parallel I/O.
- Another common I/O facility is a system bus, consists of address and data ports.
Interrupts
- An interrupt causes the proessor to suspend execution of the main program, jumps to an ISR.
- The processor stores the current PC, and sets it to the address of the ISR.
- After executing the ISR control returns to main program by restoring the PC.
- The programmer
- Should be aware of the types of interrupts.
- Places each ISR at a specific address in program memory.
Operating system
- An operating system is
- a layer of software that provides low-level services to the application layer.
- decides what program is to run next on the CPU and for how long.
- It does process/task scheduling.
- It services various H/W interrupts.
- Implements an environment for management of high-level application programs.
- A system call is the one for an application to invoke the operating system.
- operating system generates a predefined software interrupt required by a program.
- Parameters are typically passed from (to) the application program to (from) the operating system through CPU registers.

