You can use the `verbatim`

environment to typeset any verbatim code. So

```
\documentclass{article}
\usepackage{xepersian}
\settextfont{Yas}
\begin{document}
\begin{LTR}
\begin{verbatim}
% A MATLAB version of the NAG subroutine C02AFZ
% for computing the zeros of polynomials using
ndeg = length(f) - 1; %degree of polynomial
n = ndeg; N = n+1;
ihalf = 0; ispir=0; iter = 0;
cauchy = 0; %Region containing smallest
\end{verbatim}
\end{LTR}
\end{document}
```

will do. The extra `LTR`

environment is necessary to typeset the verbatim code left to right.