; ---- Math Routines for Ultrabasic
; ---- Gabriel Fernandez
; ---- You are not allowed to use this code without permission

; - SGN

SGNeax:
  CMP EAX, 0
  JG NEAR positive1
  JL NEAR negative1
    mov eax, 0
  RET
positive1:
  mov eax, 1
RET
negative1:
  mov eax, -1
RET

SGNebx:
  CMP EBX, 0
  JG NEAR positive2
  JL NEAR negative2
    mov ebx, 0
  RET
positive2:
  mov ebx, 1
RET
negative2:
  mov ebx, -1
RET

; --- ABS

ABSeax:
  CMP EAX, 0
  JNLE skipabs1
    NEG EAX
skipabs1:
  RET

ABSebx:
  CMP EBX, 0
  JNLE skipabs2
    NEG EBX
skipabs2:
  RET

