0% found this document useful (0 votes)
88 views7 pages

Timing Diagrams

The document discusses key concepts in assembly language programming, particularly for the 8085 microprocessor, including differences between high-level and assembly languages, directives, instruction mnemonics, and machine cycles. It provides an example program for basic arithmetic operations and explains the timing diagrams for instruction execution. Additionally, it covers macros, the distinction between machine and instruction cycles, and assembly directives like ORG, END, and EQU.

Uploaded by

DropDip
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
88 views7 pages

Timing Diagrams

The document discusses key concepts in assembly language programming, particularly for the 8085 microprocessor, including differences between high-level and assembly languages, directives, instruction mnemonics, and machine cycles. It provides an example program for basic arithmetic operations and explains the timing diagrams for instruction execution. Additionally, it covers macros, the distinction between machine and instruction cycles, and assembly directives like ORG, END, and EQU.

Uploaded by

DropDip
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Assembly Language Programming & Timing Diagram – Short

Answer Questions
( ⚡ Exam-ready wording with key terms teachers look for)
1. What is the main difference between a high-level language and
assembly language?
●​ High-level language (HLL) uses English-like statements (e.g., C, Python)
and is machine independent.
●​ Assembly language uses mnemonics (MOV, ADD, STA) that directly
correspond to processor instructions and is machine dependent.

2. Define a directive in 8085 assembly language. Give an


example.
A directive is an instruction to the assembler (not the CPU) that guides how to place
data or code in memory.​
➡️ Example: ORG 2000H sets the starting address of the program to 2000H.
3. Explain the purpose of the HLT instruction in the 8085
instruction set.
HLT halts the microprocessor by stopping program execution and placing the CPU
in a halt state until a reset or interrupt occurs.

4. What is a macro? How is it different from a subroutine?


A macro is a named group of instructions that is expanded in place during assembly.

●​ Macro → No CALL/RET, faster execution, but increases program size.


●​ Subroutine → Uses CALL/RET, saves memory by reusing the same block.
5. What does the term "T-state" refer to in the context of
microprocessor timings?
A T-state is one clock period of the microprocessor’s clock signal.​
👉 All machine and instruction cycles are measured as a fixed number of T-states.
6. What is the purpose of an instruction mnemonic?
A mnemonic is a human-readable abbreviation (like MOV, ADD, HLT) used to
represent a machine instruction, making programming easier to read and write.

7. Define a machine cycle.


A machine cycle is the time required by the microprocessor to complete one basic
operation such as fetching an opcode, reading data from memory, or writing data to
memory.

8. What is the significance of the STA instruction in 8085


programming?
STA (Store Accumulator) stores the contents of the accumulator into a specified
16-bit memory address.​
➡️ Example: STA 2050H stores the accumulator’s value into memory location
2050H.

✅ Memory Hook:
●​ T-state → single clock tick
●​ Machine cycle → group of T-states for one basic operation
●​ Instruction cycle → all machine cycles to finish one instruction
1. Write an 8085 assembly language program to add, subtract,
multiply, divide two 8-bit numbers stored at memory locations
2050H and 2051H and store the result at 2052H, 2053H, 2054H,
2055H, 2056H. Include appropriate comments to define memory
locations.

Program
; Program: Add, Subtract, Multiply, Divide two 8-bit numbers
; Data locations:
; 2050H → First number
; 2051H → Second number
; 2052H → Sum
; 2053H → Difference
; 2054H → Product
; 2055H → Quotient
; 2056H → Remainder

ORG 2000H ; Starting address of the program


LDA 2050H ; Load first number into accumulator
MOV B, A ; Copy first number into register B
LDA 2051H ; Load second number into accumulator
MOV C, A ; Copy second number into register C

; ----- Addition -----


MOV A, B ; A = first number
ADD C ; A = A + second number
STA 2052H ; Store sum at 2052H

; ----- Subtraction -----


MOV A, B ; A = first number
SUB C ; A = A - second number
STA 2053H ; Store difference at 2053H

; ----- Multiplication (Repeated Addition) -----


MVI A, 00H ; Clear accumulator for product
MVI D, 00H ; D = Counter for repeated addition
MOV E, C ; E = Second number
MUL_LOOP:
ADD B ; Add first number repeatedly
DCR E ; Decrease counter
JNZ MUL_LOOP ; Repeat until counter is zero
STA 2054H ; Store product at 2054H

; ----- Division (Repeated Subtraction) -----


MOV A, B ; A = Dividend (First number)
MVI D, 00H ; D = Quotient
DIV_LOOP:
CMP C ; Compare A with divisor
JC DIV_END ; If A < divisor, stop
SUB C ; A = A - divisor
INR D ; Increment quotient
JMP DIV_LOOP
DIV_END:
STA 2056H ; Store remainder at 2056H
MOV A, D
STA 2055H ; Store quotient at 2055H

HLT ; Stop execution


END

Explanation
●​ Addition/Subtraction use direct 8085 instructions (ADD, SUB).
●​ Multiplication is done by repeated addition.
●​ Division is done by repeated subtraction to get both quotient and
remainder.
●​ All results are stored in consecutive memory locations for easy verification.

2. Explain the concept of a timing diagram for a microprocessor.


Draw and explain the timing diagram for the MOV A, B instruction
of the 8085.
A timing diagram represents the relationship between control signals, clock
cycles (T-states), and data flow during the execution of an instruction. It shows
when operations like fetching, decoding, and reading/writing occur.

MOV A, B Instruction
●​ Opcode: 78H (Copy contents of B into A).
●​ Requires 1 machine cycle (Opcode Fetch).
●​ Takes 4 T-states.

Timing Steps:
1.​ T1: Address of the program counter (PC) is placed on the address bus,
and ALE goes HIGH to latch the lower byte.
2.​ T2: The control signal RD goes LOW to read the opcode (78H) from
memory.
3.​ T3: The opcode is transferred to the microprocessor and stored in the
instruction register.
4.​ T4: Instruction is decoded and executed (A ← B).
The timing diagram shows the address bus, data bus, RD, ALE, and clock pulses
changing over T1–T4.

3. Describe the steps involved in fetching and executing an


instruction in the 8085 microprocessor. Use the MVI A, 32H
instruction as an example to illustrate the process.
The process of fetching and executing an instruction consists of:

​ Opcode Fetch Cycle:


○​ The Program Counter (PC) places the memory address of the
instruction on the address bus.
○​ The control signal RD goes LOW, and the opcode (3EH) is fetched
and loaded into the instruction register.
○​ PC increments to the next memory location.
​ Operand Fetch Cycle:
○​ For MVI A, 32H, the next byte (32H) is fetched from memory.
​ Execution:
○​ The immediate data (32H) is loaded into accumulator A.

Thus, the instruction MVI A, 32H takes 2 machine cycles (Opcode Fetch + Memory
Read) and 7 T-states.

4. What are macros and why are they used in assembly language
programming? Write a macro in 8085 assembly to find the larger
of two numbers.
A macro is a group of instructions defined once but expanded inline by the
assembler whenever called.

●​ Purpose: Reduces repetitive coding and increases readability.


●​ Unlike subroutines, macros do not require CALL/RET instructions.
Macro Example: Find Larger of Two Numbers
LARGER MACRO
MOV A, B ; A = B
CMP C ; Compare B with C
JC STORE_C ; If C > B, jump
MOV D, B ; Larger is B
JMP DONE
STORE_C:
MOV D, C ; Larger is C
DONE:
ENDM

Usage in program: LARGER​


Here, register D stores the larger of B and C.

5. Differentiate between machine cycle and instruction cycle with


the help of a suitable example. Explain how multiple machine
cycles make up one instruction cycle. Explain the use of different
assembly language directives in the 8085, such as ORG, END,
and EQU. Give an example for each and describe its function.

Machine Cycle vs Instruction Cycle


Feature Machine Cycle Instruction Cycle

Definitio Time required to complete one Time required to complete one


n basic operation (e.g., fetch, instruction (may include multiple
read, write). machine cycles).

Example Memory Read cycle (3 MVI A, 32H requires two machine


T-states). cycles (Opcode Fetch + Memory
Read).

➡️ Relationship:​
Instruction cycle = Sum of all machine cycles needed to execute the instruction.

Assembly Directives

Directives tell the assembler how to process the program but are not executed by the
microprocessor.
Directive Function Example

ORG Sets starting address ORG 2000H


of program/data.

END Marks end of source END


program.

EQU Assigns a constant VALUE EQU 32H


value to a label.

6. What is a machine cycle? Draw and explain the timing diagram


for a memory write machine cycle of the 8085 microprocessor.
A machine cycle is the time taken by the microprocessor to complete one basic
operation such as opcode fetch, memory read, memory write, or I/O operation.

Memory Write Cycle (Example: STA instruction)

Steps:

1.​ T1: Address of the memory location is placed on the address bus; ALE
goes HIGH to latch the lower address.
2.​ T2: Data to be written is placed on the data bus; WR goes LOW to start
writing.
3.​ T3: Data is written into memory; WR returns HIGH to end the cycle.

The timing diagram shows:

●​ Address bus active during T1.


●​ Data bus carrying output data during T2 and T3.
●​ WR signal LOW during the write period.

✅ Memory Hooks for Last-Minute Recall


●​ Machine cycle = one operation.
●​ Instruction cycle = sum of machine cycles.
●​ ORG → Origin, END → Finish, *EQU → Equal to value.

You might also like