The ellipse command honors whatever osnaps are active when you feed a point to the command. In this case you left the perpendicular osnap active. Adding the line setting OSMODE to zero meant the ellipse command used the points "as is" rather than snapping to (in this case) a perpendicular osnap point.
(command "_ellipse" "_non" pnt1 "_non" pnt2 (/ (distance pnt1 pnt2) 4.0)) would be another option. Each "_non" cancels any active osnap for the following point only.
I create ellipses using ENTMAKEX.
(defun c:test2 (/ oldecho oldos pnt1 pnt2 axismaj axismin)
(defun *error* (msg)
(if (/= s "Function cancelled")
(princ (strcat "\nError: " s))
)
(setvar "osmode" oldos)
(setvar "cmdecho" oldecho)
(princ)
)
(setq oldecho (getvar "cmdecho"))
(setq oldos (getvar "osmode"))
(setvar "osmode" 512)
(setq pnt1 (getpoint "\nFirst Point: "))
(setvar "osmode" 128)
(setq pnt2 (getpoint "\nSecond Point: " pnt1))
(setq ellipse_center (list (/ (+ (car pnt1) (car pnt2)) 2.0) (/ (+ (cadr pnt1) (cadr pnt2)) 2.0)))
(setq major_axis_point (polar '(0 0 0) (+ (angle pnt2 pnt1) (/ pi 2.0)) (* (distance pnt2 pnt1) 2.0)))
(setq axis_ratio 0.25)
(entmakex (list (cons 0 "ELLIPSE")
(cons 100 "AcDbEntity")
(cons 100 "AcDbEllipse")
; (cons 6 linetype)
; (cons 8 layer)
(cons 10 ellipse_center)
(cons 11 major_axis_point)
(cons 40 axis_ratio)
(cons 41 0.0)
(cons 42 (* PI 2.0))
; (cons 62 color)
)
)
(setvar "cmdecho" oldecho)
(setvar "osmode" oldos)
(princ)
)
ENTMAKEX is faster than using COMMAND and it avoids the osnap issue. I commented out the lines where you could set linetype, layer, or color if you didn't want to use the active defaults. I moved the *error* definition inside the function. *error* is automatically set up (at least in Bricscad) so you don't have to manually set and restorethe error handler.
The tricky part of using ENTMAKEX for an ellipse is the major axis point. The angle and distance are the same as for a vector from the ellipse center to a point where the major axis crosses the ellipse, but the point is calculated from the origin.