ATtiny13_2 - Analysis Report

Static Code Analysis Report — Assembly Language
ESL Assemblomator
AILogicLab Division
Generated: 2026-02-20 00:35:05
Project:
ATtiny13_2
Architecture:
ATtiny13
Files Scanned:
1
Scan Duration:
0.0s
Scan Date:
2026-02-20 00:28
3
Critical
0
High
2
Medium
0
Low
0
Info

Findings Summary

#SeverityRule IDTitle CategoryFileLine
1 Critical ASM-ISR-001 SREG/flags not saved in ISR Interrupt Safety main.asm 311
2 Critical ASM-ISR-002 Registers clobbered in ISR without save/restore Register Usage main.asm 69
3 Critical ASM-ISR-002 Registers clobbered in ISR without save/restore Register Usage main.asm 255
4 Medium ASM-IO-001 Whole-port write may affect unrelated pins Port I/O main.asm 264
5 Medium ASM-VEC-001 Incomplete interrupt vector table Vector Table main.asm 1

Detailed Findings

Critical Finding #1: ASM-ISR-001 — SREG/flags not saved in ISR

Category:Interrupt Safety
File:C:\Amp_demos\AT-Tiny-Assemblomator\Projects\AT_tiny\AT_tiny\main.asm
Line:311

Description: Interrupt service routine 'ISR_DONE' does not save and restore the status register (SREG). Any arithmetic or comparison in the ISR will silently corrupt flags used by the main program.

ISR_DONE:

✅ Recommended Fix

Save SREG on ISR entry and restore before RETI:

    push r0
    in   r0, SREG
    ; ... ISR body ...
    out  SREG, r0
    pop  r0
    reti

Critical Finding #2: ASM-ISR-002 — Registers clobbered in ISR without save/restore

Category:Register Usage
File:C:\Amp_demos\AT-Tiny-Assemblomator\Projects\AT_tiny\AT_tiny\main.asm
Line:69

Description: ISR 'tick16' modifies registers r16, r17, r18, r19, r20, r21, r30, r31 without push/pop. This corrupts main program register values unpredictably.

tick16:     .byte 2         ; 16-bit tick incremented in ISR

✅ Recommended Fix

Push all modified registers on ISR entry and pop before RETI:

    push r16
    push r17
    push r18
    push r19
    push r20
    push r21
    push r30
    push r31
    ; ... ISR body ...
    pop  r31
    pop  r30
    pop  r21
    pop  r20
    pop  r19
    pop  r18
    pop  r17
    pop  r16
    reti

Critical Finding #3: ASM-ISR-002 — Registers clobbered in ISR without save/restore

Category:Register Usage
File:C:\Amp_demos\AT-Tiny-Assemblomator\Projects\AT_tiny\AT_tiny\main.asm
Line:255

Description: ISR 'TIMER0_OVF_ISR' modifies registers r16, r17 without push/pop. This corrupts main program register values unpredictably.

TIMER0_OVF_ISR:

✅ Recommended Fix

Push all modified registers on ISR entry and pop before RETI:

    push r16
    push r17
    ; ... ISR body ...
    pop  r17
    pop  r16
    reti

Medium Finding #4: ASM-IO-001 — Whole-port write may affect unrelated pins

Category:Port I/O
File:C:\Amp_demos\AT-Tiny-Assemblomator\Projects\AT_tiny\AT_tiny\main.asm
Line:264

Description: Writing entire port register at line 264 overwrites all bits, potentially affecting pins used for other purposes. Use SBI/CBI for single-bit operations when only one pin needs to change.

    out PORTB, r16

✅ Recommended Fix

Use atomic bit operations instead of whole-port writes:

    sbi PORTB, PB0   ; Set single bit
    cbi PORTB, PB0   ; Clear single bit

Or use read-modify-write with proper masking:
    in  r16, PORTB
    andi r16, ~(1<
                

Medium Finding #5: ASM-VEC-001 — Incomplete interrupt vector table

Category:Vector Table
File:C:\Amp_demos\AT-Tiny-Assemblomator\Projects\AT_tiny\AT_tiny\main.asm
Line:1

Description: Only 2 vector table entries defined. Unused vectors should point to a safe handler (RETI or error trap) to prevent wild jumps on spurious or unexpected interrupts.

✅ Recommended Fix

Define all vector entries. Unused ones should point to a safe default:

UNHANDLED_IRQ:
    reti           ; or rjmp RESET for fault capture

Fill all unused .org entries with:
    rjmp UNHANDLED_IRQ