?? fillbuff.c
字號:
/* fillbuff.c
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!! "FILL_INCREMENT" is not implemented yet. !!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
FILL_INCREMENT means to increment starting seed by one every 256 bytes
( 0,1,2 ... 1,2,3 ... 2,3,4,...)
FILL_COMPLEMENT means to "NOT" the SEED after each write
*/
#include <clib1.h>
VOID buffer_fill( VOID *buffer, LONG buffsize, LONG seed, LONG incr, WORD flags )
/* "buffsize" is #bytes.
Entry: buffer - pointer to data location
buffsize - buffer size in bytes
seed - starting data value
incr - value to increment "seed" by.
If buffer size is not a multiple of the requested size (e.g. long accesses
to buffer of 7 bytes), then the remainder is not set up.
ADDR1_SAME is used to say whether to increment the address (addr1).
*/
{
LONG ldata = seed;
VLONG *lptr = buffer;
LONG counter = buffsize;
WORD wdata = (WORD) seed;
VWORD *wptr = buffer;
BYTE bdata = (BYTE) seed;
VBYTE *bptr = buffer;
if ( !incr && !(flags & ADDR1_SAME) )
/* data does not increment, address increments */
{
switch( flags & SIZE_MASK )
{
case SIZE_BYTE:
if ( !(flags & FILL_COMPLEMENT) )
for( ; counter != 0; counter-- )
*bptr++ = bdata;
else
{
for( ; counter != 0; counter-- )
{
*bptr++ = bdata;
bdata = ~bdata;
}
}
return;
case SIZE_WORD:
counter /= 2;
if ( !(flags & FILL_COMPLEMENT) )
for( ; counter != 0; counter-- )
*wptr++ = wdata;
else
{
for( ; counter != 0; counter-- )
{
*wptr++ = wdata;
wdata = ~wdata;
}
}
return;
case SIZE_LONG:
counter /= 4;
if ( !(flags & FILL_COMPLEMENT) )
for( ; counter != 0; counter-- )
*lptr++ = ldata;
else
{
for( ; counter != 0; counter-- )
{
*lptr++ = ldata;
ldata = ~ldata;
}
}
return;
}
}
if ( incr && !(flags & ADDR1_SAME) )
/* data increments, address increments */
{
switch( flags & SIZE_MASK )
{
case SIZE_BYTE:
for( ; counter != 0; counter-- )
{
*bptr++ = bdata;
bdata += (UINT8)incr;
}
return;
case SIZE_WORD:
counter /= 2;
for( ; counter != 0; counter-- )
{
*wptr++ = wdata;
wdata += (UINT16)incr;
}
return;
case SIZE_LONG:
counter /= 4;
for( ; counter != 0; counter-- )
{
*lptr++ = ldata;
ldata += incr;
}
return;
}
}
if ( (flags & ADDR1_SAME) )
/* address stays the same (data may or may not increment) */
{
switch( flags & SIZE_MASK )
{
case SIZE_BYTE:
for( ; counter != 0; counter-- )
{
*bptr = bdata;
bdata += (UINT8)incr;
if ( flags & FILL_COMPLEMENT ) bdata = ~bdata;
}
return;
case SIZE_WORD:
counter /= 2;
for( ; counter != 0; counter-- )
{
*wptr = wdata;
wdata += (UINT16)incr;
if ( flags & FILL_COMPLEMENT ) wdata = ~wdata;
}
return;
case SIZE_LONG:
counter /= 4;
for( ; counter != 0; counter-- )
{
*lptr = ldata;
ldata += incr;
if ( flags & FILL_COMPLEMENT ) ldata = ~ldata;
}
return;
}
}
}
VOID physical_buffer_fill( UINT32 buffer, LONG buffsize, LONG seed, LONG incr, WORD flags )
/* "buffsize" is #bytes.
Same as buffer_fill but uses physical 32-bit addresses.
Caller can use physaddr() to convert C-addresses to physical.
Entry: buffer - 32-bit address of data location
buffsize - buffer size in bytes
seed - starting data value
incr - value to increment "seed" by.
If buffer size is not a multiple of the requested size (e.g. long accesses
to buffer of 7 bytes), then the remainder is not set up.
ADDR1_SAME is used to say whether to increment the address (addr1).
*/
{
LONG ldata = seed;
LONG counter = buffsize;
WORD wdata = (WORD) seed;
BYTE bdata = (BYTE) seed;
if ( !incr && !(flags & ADDR1_SAME) )
/* data does not increment, address increments */
{
switch( flags & SIZE_MASK )
{
case SIZE_BYTE:
if ( !(flags & FILL_COMPLEMENT) )
for( ; counter != 0; counter-- )
xpoke8( buffer++, bdata);
else
{
for( ; counter != 0; counter-- )
{
xpoke8( buffer++, bdata);
bdata = ~bdata;
}
}
return;
case SIZE_WORD:
counter /= 2;
if ( !(flags & FILL_COMPLEMENT) )
for( ; counter != 0; counter-- )
{
xpoke16( buffer, wdata);
buffer += 2;
}
else
{
for( ; counter != 0; counter-- )
{
xpoke16( buffer, wdata);
buffer += 2;
wdata = ~wdata;
}
}
return;
case SIZE_LONG:
counter /= 4;
if ( !(flags & FILL_COMPLEMENT) )
for( ; counter != 0; counter-- )
{
xpoke32( buffer, ldata);
buffer += 4;
}
else
{
for( ; counter != 0; counter-- )
{
xpoke32( buffer, ldata);
buffer += 4;
ldata = ~ldata;
}
}
return;
}
}
if ( incr && !(flags & ADDR1_SAME) )
/* data increments, address increments */
{
switch( flags & SIZE_MASK )
{
case SIZE_BYTE:
for( ; counter != 0; counter-- )
{
xpoke8( buffer++, bdata);
bdata += (UINT8)incr;
}
return;
case SIZE_WORD:
counter /= 2;
for( ; counter != 0; counter-- )
{
xpoke16( buffer, wdata);
buffer += 2;
wdata += (UINT16)incr;
}
return;
case SIZE_LONG:
counter /= 4;
for( ; counter != 0; counter-- )
{
xpoke32( buffer, ldata);
buffer += 4;
ldata += incr;
}
return;
}
}
if ( (flags & ADDR1_SAME) )
/* address stays the same (data may or may not increment) */
{
switch( flags & SIZE_MASK )
{
case SIZE_BYTE:
for( ; counter != 0; counter-- )
{
xpoke8( buffer, bdata);
bdata += (UINT8)incr;
if ( flags & FILL_COMPLEMENT ) bdata = ~bdata;
}
return;
case SIZE_WORD:
counter /= 2;
for( ; counter != 0; counter-- )
{
xpoke16( buffer, wdata);
wdata += (UINT16)incr;
if ( flags & FILL_COMPLEMENT ) wdata = ~wdata;
}
return;
case SIZE_LONG:
counter /= 4;
for( ; counter != 0; counter-- )
{
xpoke32( buffer, ldata);
ldata += incr;
if ( flags & FILL_COMPLEMENT ) ldata = ~ldata;
}
return;
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -