Category : Assembly Language Source Code
Archive   : C--C0200.ZIP
Filename : MATH.H--

 
Output of file : MATH.H-- contained in archive : C--C0200.ZIP
/*
SPHINX Programming (C) 1993.
NAME: MATH.H--
DESCRIPTION: This file contains some math procedure definitions.
PROCEDURES DEFINED IN THIS FILE ARE:
: int ABS(number)
: word SQRT(number)
: dword SQRT_386(number) // NOT YET TESTED!!! 🙂
*/


: int ABS () /* AX = signed number to get absolute value of */
{
IF( int AX < 0 )
-AX;
}
/* Returns: AX = absolute value
*/


: word SQRT () /* AX = number to root */
{$ MOV BX,128 // initial guess
$ MOV DI,BX
$ MOV CX,AX
TOP:
$ MOV AX,CX
$ XOR DX,DX
$ DIV BX
$ ADD AX,BX
$ SHR AX,1
$ CMP AX,BX
$ JE FINISHED
$ CMP AX,DI
$ MOV DI,BX
$ MOV BX,AX
$ JNE TOP
$ CMP AX,DI
$ JL FINISHED
$ MOV AX,DI
FINISHED:
}
/* returns: AX = square root
BX,CX,DX,DI = undefined
*/


: dword SQRT_386 () /* EAX = number to root */
{$ MOV EBX,32768 // initial guess
$ MOV EDI,EBX
$ MOV ECX,EAX
TOP:
$ MOV EAX,ECX
$ XOR EDX,EDX
$ DIV EBX
$ ADD EAX,EBX
$ SHR EAX,1
$ CMP EAX,EBX
$ JE FINISHED
$ CMP EAX,EDI
$ MOV EDI,EBX
$ MOV EBX,EAX
$ JNE TOP
$ CMP EAX,EDI
$ JL FINISHED
$ MOV EAX,EDI
FINISHED:
}
/* returns: EAX = square root
EBX,ECX,EDX,EDI = undefined
*/


/* end of MATH.H-- */

  3 Responses to “Category : Assembly Language Source Code
Archive   : C--C0200.ZIP
Filename : MATH.H--

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/