# Category : Assembly Language Source Code

Archive : ASM_SUBR.ZIP

Filename : SCALE

; from BLUEBOOK OF ASSEMBLY ROUTINES FOR IBM PC & XT.

; page :173

; NAME SCALE

; ROUTINE FOR LINEAR SCALING

;

; FUNCTION: This routine performs a linear scaling, converting a fixed

; point number between 0 and 1 to an integer between X1 and X2, where

; X1 and X2 are 16-bit integers.

; INPUT: Upon entry CX has a binary fixed point number between 0 and

; 1. The binary point is to the left of the leftmost bit. X1 and X2 are

; variables stored in memory.

; OUTPUT: Upon exit CX contains the 16-bit integer result.

; REGISTERS USED: Only CX is modified.

; SEGMENTS REFERENCED: The data segment must contain the variables X1

; and X2.

; ROUTINES CALLED: None

; SPECIAL NOTES: None

;

; ROUTINE TO SCALE LINEARLY

;

scale proc far

;

push dx ; save registers

push ax

;

; compute width

mov ax,x2 ; get x2

sub ax,x1 ; subtract x1

;

; multiply width by input parameter

mul cx ; multiply

mov cx,dx ; move top part of quotient into CX

;

; add lower limit

add cx,x1 ; add x1

;

pop dx ; restore registers

pop dx

ret ; return

;

scale endp

;-------------------------scale routine ends---------------------------+

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

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

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/