  In this paper, we prove a Kastler-Kalau-Walze type theorem for perturbations
of Dirac operators on compact manifolds with or without boundary. As a
corollary, we give two kinds of operator-theoretic explanations of the
gravitational action on boundary. We also compute the spectral action for Dirac
operators with two-form perturbations on $4$-dimensional compact manifolds.
