Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

segmentation problem.

Status
Not open for further replies.

denc4

Programmer
Feb 17, 2005
107
NL
I want to write data which is >64k from memory to a file.
The problem is the DOS "write file" function, ah=40h, it only
accepts >=64k parameters.

The amount of data to write is in dx:ax. When I divide this
value by 64kb I can write the remainder in dx in one go.
But if ax > 1, how do I access data beyond the first 64k?

function 40h uses the data at ds:dx to write to disk. When I
add 64kb to dx, and it overflows, then how do I calculate
the correct segment value for ds?

thx.

 
From memory (its a long time since I've done any serious assembly programming), function 40h has a problem with 64k of data. I used to split the data into 32k blocks.

Segments are on 16 byte boundaries, therefore (using 32k as an example) divide your total data size by 32k which will determine the number of blocks, and also tell you how many bytes in the final block. Initialise DS to the start of the first block and set DX to 0. In a loop, write the 32k of data from DS:DX, add 800h to DS and reset DX to 0. CX should contain either 32k or (if its the last block) the number of remaining bytes. I can't remember if you can assign directly to DS, if not then use the stack.

Hope this helps.
 
Now you have made me curious about WHAT problem there is
with writing 64k chunks... I'll try it instead of 32k and
see what happens..

And by adding "800h" i assume you meant "8000h", which is
32k.

I knew segments were on a 16 byte boundary, but I also used
to think that for example 127C:0001 is equal to 127D:0000.
I don't know how I got that idea.. I did some experimenting
in DEBUG some minutes ago and found out 127C:0010 is equal
to 127D:0000.

No, you cannot assign directly to ds, I will have to do
the calculations in another register and move the data
to ds when finished..

thank you.
 
I clicked submit too quickly!

0000:0000 = absolute address 0
0001:0000 = absolute address 16
0800:0000 = absolute address 32768
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top