News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

insufficient memory

Started by wogok, June 04, 2007, 06:47:09 AM

Previous topic - Next topic

wogok

i compile this source code using masm6.15 but receive an error message code seg size exceed 64k
i use mix 16bit and 32bit cmd, so now i guess im still running on dos16 platform...
how to change to dos32?
or i need a memory extender? and how to compile it in masm6.15?

[attachment deleted by admin]

MichaelW

ruru,

The size problem is being caused by this:

rept 1000000
mov ax,[memvar]
endm

If this is intended to produce a delay, it should probably be a loop that executes a single instance of the mov instruction 1000000 times, instead of executing 1000000 instances of the instruction one time each.

What I believe to be the code that you started with is available here:

http://www.phatcode.net/res/224/files/html/ch03/03-02.html

I had to correct a large number of errors in the file before it would assemble, mostly missing spaces and illegal characters used in place of single quotes. The code should assemble to an object module that contains three externally callable procedures. To test these procedures I created this test code:

externdef ZTimerOn:FAR
externdef ZTimerOff:FAR
externdef ZTimerReport:FAR
.model small
.stack
.data
.code
.startup
  call ZTimerOn
  call ZTimerOff
  call ZTimerReport
.exit
end

Assembled it, and linked it with the pztimer object module. Using DEBUG I was able to verify that I can call each of the procedures, so the declarations and linking are probably correct, but at some point in the execution of the procedures NTVDM reports that it has encountered an illegal instruction, and terminates the program. The code should be tested under DOS or Windows 9x MS-DOS mode, but at the current time I have no way to do either.

Pztimer.asm is 16-bit DOS code that uses only conventional memory, and not very much of that. Converting the code to use 32-bit instructions should be no problem, but for this code I can see no good reason to do so. Most of the execution time is spent accessing the hardware through 8-bit I/O ports and making interrupt calls to functions that have a 16-bit interface, so there are few opportunities to even use 32-bit instructions, much less benefit from their use.

Unless you intend to run this on a relatively old 286, the MPOPF macro is an unnecessary complexity that can be replaced with a CLI.
eschew obfuscation

wogok

oops!!
yup..im trying to produce a delay to compute the time diff!
im trying to show the approximate memory speed...
i change the source code ady n run it...
but it seems that the time diff is almost same for diff number of loop..(i use cx > 100,000,000)
are there any other way?

[attachment deleted by admin]

MichaelW

I think that unless the code needs to run on old systems, you should consider using the Time Stamp Counter as a timer. The Time Stamp Counter is available on most Pentium-class processors, and virtually all x86 desktop processors produced in the last 10 years. The Time Stamp Counter runs at the processor clock speed, so depending on the clock speed, the resolution of the Time Stamp Counter could be up to several thousand times higher than that of the system timer. The Time Stamp Counter is read with the RDTSC instruction, and to get an idea of how to use it see the Code Timing Macros thread in the Laboratory. This method would actually be easier to implement than the method you are currently using.

Also, if you are trying to time memory accesses, I think a loop may not be a good way to do it. I don't know enough about the operation of the memory and cache systems to have any idea of how you could get a meaningful timing for the actual memory, if that is what you intend to do, unless perhaps there is some reasonably standardized method of disabling the caches.

eschew obfuscation