walls@killer.DALLAS.TX.US (Monty Walls) (09/06/88)
-------------------------------------------------------------------------- I recently came up with a faster version of cp_mess in klib88.s. By replacing the multiple mov instructions used to set up the block copy with 'les' & 'lds' you can shave a few cycles from a routine that is used by every system call. I've been using it for about 2 weeks this way with no ill affects. -Monty Walls ---------------------------cut here--------------------------------------- |*===========================================================================* |* cp_mess * |*===========================================================================* | This routine is makes a fast copy of a message from anywhere in the address | space to anywhere else. It also copies the source address provided as a | parameter to the call into the first word of the destination message. | It is called by: | cp_mess(src, src_clicks, src_offset, dst_clicks, dst_offset) | where all 5 parameters are shorts (16-bits). | | Note that the message size, 'Msize' is in WORDS (not bytes) and must be set | correctly. Changing the definition of message the type file and not changing | it here will lead to total disaster. | | this routine only preserves the registers the 'C' compiler | expects to be preserved (es, ds, si, di, sp, bp). Msize = 12 | size of a message in 16-bit words _cp_mess: push es | save es push ds | save ds mov bx,sp | index off bx because machine can't use sp | also we don't have to preserve bx! pushf | save flags cli | disable interrupts push si | save si push di | save di mov di,14(bx) | di = offset of destination buffer les si,10(bx) | use 32 bit load(ds is our base) | si = offset of source message | es = clicks of destination lds ax,6(bx) | use 32 bit load .... | ax = process number of sender | ds = clicks of source message seg es | segment override prefix mov (di),ax | copy sender's process number to dest message add si,*2 | don't copy first word add di,*2 | don't copy first word mov cx,*Msize-1 | remember, first word doesn't count cld | clear direction flag rep | iterate cx times to copy 11 words movw | copy the message pop di | restore di pop si | restore si popf | restore flags (resets interrupts to old state) pop ds | restore ds pop es | restore es ret | that's all folks! ---------------------------end here--------------------------------------- Monty Walls MIS Division, Tech. Support Oklahoma Tax Commission 2501 N. Lincoln OKC, OK, 73194