Professional Documents
Culture Documents
Programming Languages: High-Level Languages Object-Oriented vs. Structured Languages Assembly Language
Programming Languages: High-Level Languages Object-Oriented vs. Structured Languages Assembly Language
LANGUAGES
High-level Languages
Object-Oriented vs. Structured Languages
Assembly Language
Outline
• Assembly Language
• Structure Programming, c-programming language
• Object Oriented Programming
• Object-based Perspective of Structured Language
• Mixed C & Assembly Projects
• Modeling time-ordered behavior using State Machines
Introduction
Add_B_To_C DEF_MACRO
MOV A,C
ADD A,B
MOV C,A
END_MACRO
10
Macro Invocation
op_code operand
op_code operand
Add_B_To_C
op_code operand
op_code operand
11
Macro Expansion
op_code operand
op_code operand
Add_B_To_C
MOV A,C ; Assembler inserts
ADD A,B ; these three
MOV C,A ; lines
op_code operand
op_code operand
12
Macros Versus Subroutines
#ifndef __SENSOR_H__
#define __SENSOR_H__
#ifndef __SENSOR_H__
#define __SENSOR_H__
ARM
Passing Arguments C ↔ ASM
Function Code
Structure of Assembly Function
Calling C from Assembly
C Function
Assembly Code
Calling Assembly from C
Assembly Code
C Code
STATE MACHINES
void TickFct() {
switch(State) { // Transitions
case start: State = s0; break; // Initial transition
case s0: if (!A0) { State = s0; } else if (A0) { State = s1; } break;
case s1: if (!A0) { State = s0; } else if (A0) { State = s1; } break;
default: State = start; break;
} // Transitions
switch(State) { // State actions
case s0: break; void main() {
case s1: B0 = A1; break; B = 0x00; // Initialize outputs
default: break; State = start; // Indicates initial call
while(1) { TickFct(); }
} // State actions
}
}
Mealy & More State Machines
timeout
Testing a State Machines