Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

segmentation problem.

segmentation problem.

segmentation problem.

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?


RE: segmentation problem.

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.

RE: segmentation problem.

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

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.

RE: segmentation problem.

800h is correct (remember your adjusting the segment register)

RE: segmentation problem.

I clicked submit too quickly!

0000:0000 = absolute address 0
0001:0000 = absolute address 16
0800:0000 = absolute address 32768

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close