Write a sequence of instructions that transfers data from me
Write a sequence of instructions that transfers data from memory to an external I/0 device by using Channel 3 of the 8237. The memory area to be transferred is at location 20000H-20FFFH.
Solution
typedef struct
{
char page;
unsigned int offset;
unsigned int length;
} DMA_block;
Now, how do we find a memory pointer\'s page and offset? Easy. Use
the following code:
void LoadPageAndOffset(DMA_block *blk, char *data)
{
unsigned int temp, segment, offset;
unsigned long foo;
segment = FP_SEG(data);
offset = FP_OFF(data);
blk->page = (segment & 0xF000) >> 12;
temp = (segment & 0x0FFF) << 4;
foo = offset + temp;
if (foo > 0xFFFF)
blk->page++;
blk->offset = (unsigned int)foo;
}
