Introduction to Assembly
Programming and Compilers
• • Assembly is a low-level language closely tied
to machine code.
• • Compiler: Translates high-level languages (C,
C++) into machine code.
• • Assembler: Converts assembly language into
machine code.
Instruction Classification
• • Data Transfer – MOV, PUSH, POP
• • Arithmetic – ADD, SUB, MUL
• • Logical – AND, OR, XOR
• • Branch – JMP, CALL, RET
• • Control – NOP, HLT
Instruction Set
• • Collection of all instructions a CPU can
execute.
• • Example (8051): MOV A, #0x25 – Load 0x25
into Accumulator A.
Addressing Modes - Part 1
• • Immediate: Operand directly in instruction –
MOV A, #25H
• • Register: Operand in register – MOV A, R1
• • Direct: Memory address – MOV A, 30H
Addressing Modes - Part 2
• • Indirect: Address in register – MOV A, @R0
• • Relative: Offset from PC – SJMP +5
Assembler Directives
• • ORG: Set starting address – ORG 0000H
• • END: End of program – END
Assembly Programming Features
(with Example)
• • Efficient and fast
• • Direct hardware control
• • Precise register access
• Example:
• ORG 0000H
• MOV A, #0AH
• ADD A, #05H
• END
Introduction to 8051 Programming
in C
• • Easier to read/write than Assembly
• • Can use standard control structures
• • Access hardware using keywords like sbit
8051 C Code Example: LED Blinking
• #include <reg51.h>
• sbit LED = P1^0;
• void delay() {
• ...
• }
• void main() {
• while(1) {