Author Topic: DOS segment access  (Read 3938 times)

0 Members and 1 Guest are viewing this topic.

Offline madeyes

  • ZX 81
  • *
  • Posts: 23
  • Karma: 4
    • View Profile
DOS segment access
« on: June 16, 2009 »
Hi,
I'm struggling to remember this from my DOS programming days, so does anyone know if in a DOS (or at least DOS VM under winXP) COM program; is it ok to make use of the unused memory in the code segment or do i have to request memory via an interrupt call to dos? I was hoping to use memory after the offset at the end of my code to the end of the segment for a buffer :) Maybe that's cheating for a 256 byte demo anyway :)

madeyes

Offline ferris

  • Pentium
  • *****
  • Posts: 841
  • Karma: 84
    • View Profile
    • Youth Uprising Home
Re: DOS segment access
« Reply #1 on: June 16, 2009 »
My "Overhead" intro uses fs as an offset in the code segment for data :) nothin' wrong with that.

Code: [Select]
mov ax,cs
add ah,10h
mov fs,ax

;)
http://iamferris.com/
http://youth-uprising.com/

Where the fun's at.
Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: DOS segment access
« Reply #2 on: June 16, 2009 »
I think you get 64Kb allocated in a com program, so you can use the full cs segment for anything.

If you add something like

start_of_space: db ?

at the end of your program, you'll be able to find where this space starts.

Jim
Challenge Trophies Won:

Offline ferris

  • Pentium
  • *****
  • Posts: 841
  • Karma: 84
    • View Profile
    • Youth Uprising Home
Re: DOS segment access
« Reply #3 on: June 16, 2009 »
yup, just use an interrupt to print the value of (*Not at*) start_of_space.

Alternatively, if you're doing this for sizecoding, you already know how large your .com will be :) so you can use the code I gave earlier but with more specific values. 256b could be "add ah,byte 1" to conserve the most memory.

(P.S. just figured the above out, thanks to Jim :) )

Oh and one more thing: .bss sections ARE ok in tinycoding ;)
http://iamferris.com/
http://youth-uprising.com/

Where the fun's at.
Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: DOS segment access
« Reply #4 on: June 16, 2009 »
You can only use bss segments in an exe, not a com file which needs to fit in a single 64kb segment.  If you use an exe you have access to all available memory though, which might be an advantage.

Jim
Challenge Trophies Won:

Offline ferris

  • Pentium
  • *****
  • Posts: 841
  • Karma: 84
    • View Profile
    • Youth Uprising Home
Re: DOS segment access
« Reply #5 on: June 16, 2009 »
You can only use bss segments in an exe, not a com file

Doh :)
http://iamferris.com/
http://youth-uprising.com/

Where the fun's at.
Challenge Trophies Won: