The MASM Forum

Miscellaneous => 16 bit DOS Programming => Topic started by: daydreamer on April 23, 2021, 05:26:11 PM

Title: Memory???
Post by: daydreamer on April 23, 2021, 05:26:11 PM
First what page does my. Com file endup in?
Drawing I use the usual A000, but what pages is best usable for backbuffer and other things, like draw a big image in advance, before showing little part on screen?
Title: Re: Memory???
Post by: LiaoMi on April 23, 2021, 11:50:32 PM
Hi daydreamer,

Duncan, Ray - Advanced MS-DOS programming - the Microsoft guide for assembly language and C programmers (1989, Microsoft Press)
https://archive.org/details/Advanced_MS-DOS_Programming_2nd_Edition_Ray_Duncan
https://archive.org/download/Advanced_MS-DOS_Programming_2nd_Edition_Ray_Duncan/Advanced_MS-DOS_Programming_2nd_Edition_Ray_Duncan.pdf
https://github.com/microsoft/MS-DOS
https://en.wikipedia.org/wiki/DOS_memory_management

(https://i.ibb.co/TBbDXxw/2021-04-23-15-49-18-Duncan.png)
Title: Re: Memory???
Post by: daydreamer on April 24, 2021, 12:17:47 AM
thanks LiaoMi  :thumbsup:
I am after to switch DS to several 64k block and output big images without it crashes and final output to A000(ES)


Title: Re: Memory???
Post by: LiaoMi on April 24, 2021, 01:13:51 AM

Memory allocation table :arrow_right: https://www.hohmann-edv.de/betriebssysteme/dos.php
Title: Re: Memory???
Post by: daydreamer on April 25, 2021, 08:47:56 PM
thanks :thumbsup:
scrolling with a rossler attractor you can control with arrow keys,esc=quit





Title: Re: Memory???
Post by: hutch-- on April 27, 2021, 04:10:40 AM
Somewhere back in the long distant past I used to extract some extra memory for a DOS app by using the VGA address at A000h and going up to B7FF which at the time I used it for some utilities that would struggle to fit into DOS range memory. I think you had to twiddle HIMEM.SYS but it could be done.
Title: Re: Memory???
Post by: daydreamer on April 27, 2021, 06:38:48 PM
Hutch I start simplest segment switching first before use vesa interrupts for vram
Want to finish it like it was meant to be:scrolling thru big racetrack = big memory buffer for map
updated: or waterways


Title: Re: Memory???
Post by: daydreamer on April 29, 2021, 05:46:14 PM
What's best,use [BP] that uses. Ss = cs in. Com file if not changed or cs: override to retrieve LUT data + other data from source file that ends up in cs=ds=Ss=es when loaded?
Mov ax,page
Mov ds,ax
Vs LDS?
reading DOS AoA

Title: Re: Memory???
Post by: FORTRANS on April 30, 2021, 06:20:39 AM
Hi,

Quote from: daydreamer on April 29, 2021, 05:46:14 PM
What's best,use [BP] that uses. Ss = cs in. Com file if not changed or cs: override to retrieve LUT data + other data from source file that ends up in cs=ds=Ss=es when loaded?
Mov ax,page
Mov ds,ax
Vs LDS?

   What is better or best between;
    MOV AX,Seg
    MOV DS,AX
...
    LDS Reg,Pointer ; Load DS and register with long pointer.


depends on your personal tastes.  The only time you need
to use the load segment instruction is when you load the
stack segment and stack pointer (LSS).  That needs to be
atomic to prevent {rare} interrupts between two moves
to do the same thing.  IIRC of course.  Loading DS is less
constrained.  Use whichever makes sense to you.

Cheers,

Steve N.

Title: Re: Memory???
Post by: daydreamer on April 30, 2021, 06:31:45 PM
thanks Steve N. :thumbsup:
LDS probably easier to use with already 32bit pointer (e)si register start of loop,but switching seg in outerloop maybe only need
inc ah
mov ds,ax
had annoying bug because still thinking in 32bit crashes,ret 8 and ret 12(thinking 4 * arguments)

so if I want as much continuious memory buffer,from original CS,SS,DS segment after the code and few variables upto B7ffh,any advice where to move SS:stack?
highest segment or any UMB? or going downward from 0B7ffh ?
seem I have to use a segment  between A000h and memory buffer I copy/scroll from



Title: Re: Memory???
Post by: daydreamer on May 07, 2021, 06:47:09 PM
More advanced, is it possible to copy everything loaded to uppermost segment and jump there?
Title: Re: Memory???
Post by: FORTRANS on May 07, 2021, 10:43:07 PM
Hi,

Quote from: daydreamer on May 07, 2021, 06:47:09 PM
More advanced, is it possible to copy everything loaded to uppermost segment and jump there?

   Should be.  You just end up with two copies in memory.  So I don't see
any advantage for a normal program.  (Not being a device driver, TSR or
some other strange case.)

Regards,

Steve N.
Title: Re: Memory???
Post by: daydreamer on May 09, 2021, 06:49:36 AM
try to get 16bit(word) colors vesa modes,but doesnt get bankswitching to work
fixed thanks Steve N. :thumbsup:


Title: Re: Memory???
Post by: FORTRANS on May 09, 2021, 11:18:32 PM
Hi,

   Set BH to zero to change banks.  BH set
to one is an inquiry of the current settings.

Steve N.
Title: Re: Memory???
Post by: daydreamer on June 05, 2021, 11:34:45 PM
using more FS,GS segment registers help
Title: Re: Memory???
Post by: daydreamer on June 12, 2021, 04:49:48 AM
How do I load a bitmap and controls which segment(s) it's loaded into?
On underpowered computers,it's common with premade Sprites/ tiles 
Title: Re: Memory???
Post by: daydreamer on September 10, 2021, 10:36:30 PM
How do I get no stackframes or custom stack frame, so i can use most of 8 registers, I want to use BP as pointer for Ss segment /original cs segment where my variables are
Ds together with es is for copy backbuffer/screen memory, also copy part of landscape that I scroll thru
Title: Re: Memory???
Post by: FORTRANS on September 11, 2021, 12:29:25 AM
Hi,

Quote from: daydreamer on September 10, 2021, 10:36:30 PM
How do I get no stackframes or custom stack frame, so i can use most of 8 registers,

   Code things directly to avoid any stack frame.  Use a different calling
convention that does not require passing parameters on the stack.  Most
of my code uses variables in the data segment to allow a called procedure
to directly use global data.

   Or write a macro to implement a custom stack frame.

QuoteI want to use BP as pointer for Ss segment /original cs segment where my variables are

   BP defaults to using SS for its segment access.  you can use a CS: or
DS: segment override to use those segments.  I do that fairly often as I
don't normally use a stack frame.  Thus BP is usable as a second base
register to access data in the DS or ES segments.

HTH,

Steve N.
Title: Re: Memory???
Post by: daydreamer on September 15, 2021, 07:30:05 PM
Thanks steve :thumbsup:
I started to use fs,gs too
Any way to use org to place variables in last 1536 bytes in a segment?
Remaining after using 320*200 bytes as backbuffer?
I am using. Com file,so strategy is to keep ss in original segment/variables using BP,forgetting point to right segment LUT is,breaks my code earlier
While changing ds,es to rep Movsd,rep stosd

I think I want to try tile engine approach instead of scroll thru loads of memory
So scroll down/up,first write a line of tiles before change pointer. To backbuffer
A map of tiles + several tiles less memory /cpu demanding

Title: Re: Memory???
Post by: FORTRANS on September 15, 2021, 09:42:56 PM
Hi,

Quote from: daydreamer on September 15, 2021, 07:30:05 PM
Thanks steve

   You're welcome.

Quote
I started to use fs,gs too

   There should not be a problem using overrides for FS and GS.
However, unlike the other segment registers, they are not initialized
on program load.  Since you are creating *.COM programs, pushing
DS and popping FS, or GS, should work.

QuoteAny way to use org to place variables in last 1536 bytes in a segment?
Remaining after using 320*200 bytes as backbuffer?

        ORG     64000
        Back    DB      ?


QuoteI am using. Com file,so strategy is to keep ss in original segment/variables using BP,forgetting point to right segment LUT is,breaks my code earlier

   In a *.COM file, all segments should start out as the same.  Though
see above for FS and GS.  When you change a segment register, to
access video memory for instance,  you can use ASSUME to keep the
assembler happy.  Though that requires a segment declaration.  Thus
an optional program consideration.  Depends on your programming style.

   The stack segment is the same as the code and data segments on
program load. so using BP should not be difficult at all.

Cheers,

Steve N.
Title: Re: Memory???
Post by: daydreamer on November 28, 2021, 01:10:39 AM
Thanks steve  :thumbsup:
Best Memory copy,should that better use fpu load/store 10bytes and write tiles below sprites? Fill 8 bytes x 8 fp regs to write background pattern?
Title: Re: Memory???
Post by: FORTRANS on November 28, 2021, 02:30:06 AM
Hi,

Quote from: daydreamer on November 28, 2021, 01:10:39 AM
Best Memory copy,should that better use fpu load/store 10bytes and write tiles below sprites? Fill 8 bytes x 8 fp regs to write background pattern?

   The best copy routine will vary based on your system, CPU, and
memory.  So you will have to test a number of different copy
routines and select the one you like best.  Using the FPU frees up
the general registers, so it may be useful even if it's not otherwise
the best.  See past postings in the Laboratory subforum discussing
copy routines.  And, of course, let us know what you find out.

Regards,

Steve M.
Title: Re: Memory???
Post by: daydreamer on November 29, 2021, 07:45:39 AM
Quote from: FORTRANS on November 28, 2021, 02:30:06 AM
Hi,

Quote from: daydreamer on November 28, 2021, 01:10:39 AM
Best Memory copy,should that better use fpu load/store 10bytes and write tiles below sprites? Fill 8 bytes x 8 fp regs to write background pattern?

   The best copy routine will vary based on your system, CPU, and
memory.  So you will have to test a number of different copy
routines and select the one you like best.  Using the FPU frees up
the general registers, so it may be useful even if it's not otherwise
the best.  See past postings in the Laboratory subforum discussing
copy routines.  And, of course, let us know what you find out.

Regards,

Steve M.
nice to use extra registers,I more expect emulator act as old cpu timings to not break old retrogames and lowbandwidth requirements compared to modern games on moderen computers
just curious how fast emulated mhz would be when emulator runs on 4.9ghz ryzen?
Title: Re: Memory???
Post by: Gunther on November 30, 2021, 07:25:48 PM
Quote from: daydreamer on November 29, 2021, 07:45:39 AM
nice to use extra registers,I more expect emulator act as old cpu timings to not break old retrogames and lowbandwidth requirements compared to modern games on moderen computers
just curious how fast emulated mhz would be when emulator runs on 4.9ghz ryzen?

Well, it is and remains emulated software. Everything has to be virtualized and that takes time. For correct timings I always start a native DOS from the USB stick.
Title: Re: Memory???
Post by: daydreamer on December 04, 2021, 01:32:26 AM
Quote from: Gunther on November 30, 2021, 07:25:48 PM
Quote from: daydreamer on November 29, 2021, 07:45:39 AM
nice to use extra registers,I more expect emulator act as old cpu timings to not break old retrogames and lowbandwidth requirements compared to modern games on moderen computers
just curious how fast emulated mhz would be when emulator runs on 4.9ghz ryzen?

Well, it is and remains emulated software. Everything has to be virtualized and that takes time. For correct timings I always start a native DOS from the USB stick.
still most people will run dos on emulator
Title: Re: Memory???
Post by: TimoVJL on December 04, 2021, 01:45:06 AM
Also industrial use DosBox with handbrake to use old MS-DOS programs, as it's hard to find a slow PC-MB anymore.
Also when ever, virtual PC can be used to control machines using COMports/UARTS.
Special cards are a real problem, like try to find ISA / PCI MB for those.
Title: Re: Memory???
Post by: daydreamer on December 05, 2021, 07:03:58 AM
Quote from: TimoVJL on December 04, 2021, 01:45:06 AM
Also industrial use DosBox with handbrake to use old MS-DOS programs, as it's hard to find a slow PC-MB anymore.
Also when ever, virtual PC can be used to control machines using COMports/UARTS.
Special cards are a real problem, like try to find ISA / PCI MB for those.
I have old AMD 2ghz with XP,never use it so use it instead for dos?
When I started with assembly, many Algos could be done with fewer bits than 32bit,also fun to make smallest. Com file which is wysiwyg

So algo that works only with 16bit is suitable for fast SIMD version
Also I made. Inc file for all vk_codes constants, so keyboard control can be reused in 32bit


Title: Re: Memory???
Post by: hutch-- on December 05, 2021, 07:21:45 AM
I have seen in the past, industrial spec motherboards that use a 486 dx and they were mainly for process control where you could not have the vaguries of a consumer operating system, so MS-DOS was often used because it was a real mode OS that was much simpler and could use instructions that were not allowed in protected mode consumer OS versions.

Industrial tasks rarely ever needed much memory so a whopping 640k was overkill but if you needed more, you could use HIMEM.SYS to get VGA memory by setting B7FF hex as the top limit as you rarely ever used VGA display in industrial applications.

I learnt this one long ago with Norton SpeedDisk if it spat the dummy in terms of memory.
Title: Re: Memory???
Post by: TimoVJL on December 05, 2021, 08:07:18 AM
A vintage MB
GIGABYTE GA-686LX3 (https://www.gigabyte.com/Motherboard/GA-686LX3/sp#sp)
Title: Re: Memory???
Post by: daydreamer on December 12, 2021, 06:18:43 AM
Quote from: TimoVJL on December 05, 2021, 08:07:18 AM
A vintage MB
GIGABYTE GA-686LX3 (https://www.gigabyte.com/Motherboard/GA-686LX3/sp#sp)
had one when it was new,later used a 451mhz k2 for linux
industrial ISO programming looks similar to opcodes,so might be possible to use switch/case or jumptable to different drawing functions and collision detection for ISO emulator
Hutch I am checking dosbox configure file to see how its possible to change to max B7FFh usage,but I am clueless
640kb is much compared to few assembly proc's


Title: Re: Memory???
Post by: daydreamer on March 12, 2022, 08:05:45 AM
could as well release code