Category : C Source Code
Archive   : IMDSRC78.ZIP
Filename : RESCALE.ASM

 
Output of file : RESCALE.ASM contained in archive : IMDSRC78.ZIP
;
; RESCALE.ASM - routines to perform various precision conversion on arrays
;
; Written 2/91 by A. Warnock, ST Systems Corp. for use with IMDISP
;-------------------------------------------------------------------------
;
; b2w - scales 8-bit unsigned integer data to 16 bits
; from C:
; b2w (in8, out16, num_pix);
;
;-------------------------------------------------------------------------

.MODEL LARGE
.CODE
PUBLIC _b2w
_b2w PROC

push bp ; Entry sequence - save old bp
mov bp, sp ; set stackframe pointer

mov dx, [bp+6] ; move in8 address to dx
mov bx, [bp+10] ; move out16 address to bx
mov cx, [bp+14] ; move count to cx

b2wtop: mov si, dx ; stash the 8-bit array address
mov al, [si] ; grab the byte value from the array
cbw ; convert to word value with sign extend
xor ah, ah ; clear the high byte (was unsigned)
mov [bx], ax ; and shove the result into out16
;
; bump the pointers and the count
;
inc dx ; point to next byte in in8
add bx,2 ; point to next word in out16 - 2 bytes
dec cx ; take 1 from the count
jcxz b2wret ; bail out if cx=0
jmp b2wtop ; or else do the next value

b2wret:
pop bp ; Exit sequence - restore old bp
ret ; Return

_b2w ENDP

;-------------------------------------------------------------------------
;
; w2b - scales 16-bit integer data to 8 bit unsigned
; from C:
; w2b (in16, out8, num_pix);
;
;-------------------------------------------------------------------------

PUBLIC _w2b
_w2b PROC

push bp ; Entry sequence - save old bp
mov bp, sp ; set stackframe pointer

mov dx, [bp+6] ; move in16 address to dx
mov bx, [bp+10] ; move out8 address to bx
mov cx, [bp+14] ; move count to cx

w2btop: mov si, dx ; stash the 16-bit array address
mov ax, [si] ; grab the word value from the array
mov di, bx ; stash the 8-bit array address
mov [di], ah ; put high word of input into output address
;
; bump the pointers and the count
;
add dx,2 ; point to next word in in16
inc bx ; point to next byte in out8
dec cx ; take 1 from the count
jcxz w2bret ; bail out if cx=0
jmp w2btop ; or else do the next value

w2bret:
pop bp ; Exit sequence - restore old bp
ret ; Return

_w2b ENDP

END


  3 Responses to “Category : C Source Code
Archive   : IMDSRC78.ZIP
Filename : RESCALE.ASM

  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/