flat assembler
Message board for the users of flat assembler.

Index > Main > How to access high memory position

Author
Thread Post new topic Reply to topic
fafastrungen



Joined: 12 Aug 2006
Posts: 27
fafastrungen 12 Aug 2006, 22:16
Hello, I'm learning asm and I need to know how can I access a high position in memory, this is, I have 256 MB of memory on my system, how can I access to position 134217728 ?
I need something like this (in pascal):

var
Memory :Array [0..268435456] of Byte

begin
Memory [134217728] := 150
end;

so, what is the asm conversion for this ?
I don't understand segments and I know theres is 1 MB of memory limitation, but I don't want to mess or deal with memory management, I just need something like this:

mov [134217728], 150
Post 12 Aug 2006, 22:16
View user's profile Send private message Reply with quote
Matrix



Joined: 04 Sep 2004
Posts: 1166
Location: Overflow
Matrix 13 Aug 2006, 00:40
this is not possible in pascal.

btw, turbo pascal was written on 286.

and there is a built in fpu emulator too.

this 1MB limit comes from the beginning (8086),
"once upon a time, there was an 8086 microprocessor that didn't have 256MB ram, when the 640k base memory was cool..."
"then came the 80286 microprocessors, that could be paired with 80287 floatingpoint units"

the 8086 was working at ~4.77-10MHz, has 29000 transistors, in a 40 pin dip package, 16 bit registers, with its 20bit address line, it can address a maximum of 1MB of memory,
the 80286 was working at ~8-20MHz clock frequency, and does not have any cache memory, has 130000 transistors, in a 68 pin pga, 16 bit registers, with its 24 bit data line, it can address phisically 16MB, virtually 4GB of memory.

the 80286 can work in 2 modes because of the backward compatibility with the 8086:
Real Mode:
the 8086-os is working in this mode. It is possible to address 1MB of memory in this mode.
Protected Mode:
multitasking, virtual memory addressing to a maximum of 16 MBytes phisically, maximum 4GB Virtually after enabling A20 line.

you can use all of your ram in protected mode, or in unreal mode.

i remember Tomasz's kelvar example uses unreal mode.
Post 13 Aug 2006, 00:40
View user's profile Send private message Visit poster's website Reply with quote
fafastrungen



Joined: 12 Aug 2006
Posts: 27
fafastrungen 13 Aug 2006, 00:46
I've red all about memory limitation on old x86.

So, there is not anyway to do this ? :

mov [134217728], 150
Post 13 Aug 2006, 00:46
View user's profile Send private message Reply with quote
0x4e71



Joined: 25 Feb 2004
Posts: 50
0x4e71 13 Aug 2006, 08:18
not without switching to protected mode or flat real mode.

But what Pascal are you using?
Freepascal for DOS comes with GO32V2 dos extender, so you can create multi-megabyte arrays and use them. But is it a large array you want to create or just something to peek/poke memory locations with?
If what you are trying to do is access the memory location at address 134217728, then you'll have to check the docs of the Freepascal and the go32 unit, there may be a 4GB version of TurboPascal's Mem/MemW/MemL pseudo-arrays.
Good luck.
Post 13 Aug 2006, 08:18
View user's profile Send private message Reply with quote
fafastrungen



Joined: 12 Aug 2006
Posts: 27
fafastrungen 13 Aug 2006, 13:44
0x4e71 wrote:
not without switching to protected mode or flat real mode.

But what Pascal are you using?
Freepascal for DOS comes with GO32V2 dos extender, so you can create multi-megabyte arrays and use them. But is it a large array you want to create or just something to peek/poke memory locations with?
If what you are trying to do is access the memory location at address 134217728, then you'll have to check the docs of the Freepascal and the go32 unit, there may be a 4GB version of TurboPascal's Mem/MemW/MemL pseudo-arrays.
Good luck.



Thanks for the answer.
I'm not using pascal at all, I just put the example in pascal becouse I use to program with it.
Now I'm learning a little asm and I need to know how access random memory location without limitations.
Now is more clear, so thanks again.
Post 13 Aug 2006, 13:44
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20448
Location: In your JS exploiting you and your system
revolution 13 Aug 2006, 13:53
If you use a 32bit OS (Windows95+, LINUX, UNIX) then the memory locations won't be linear, this is because of the paging mechanism. Once you allocate memory (with an OS call) you will get the beginning address of the array. Then you use offsets to get to the data position you need.
Post 13 Aug 2006, 13:53
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 13 Aug 2006, 15:33
i used to combine turbo pascal and asm to get access to memory >1MB in DOS
Post 13 Aug 2006, 15:33
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
fafastrungen



Joined: 12 Aug 2006
Posts: 27
fafastrungen 14 Aug 2006, 07:27
In fact, I don't use any OS behind, I made my own boot diskette and I boot with it, then I try the programs I build.
What I want is just program the microprocessor directly without an OS behind. Of course I back up with the BIOS's functions (one way or another I use an OS) but nothing more, no DOS, no Windows, no Linux, nothing, just the things I make.
In this schema I need to know how can I access to high memory areas.
Based on what I've red, 486 and superior machines can directly points to a maximun of 4 GB of memory due to the 32 bits's address bus, but when I try something like this:

Buf byte 134217728 dup (?)
or
mov [134217728], 150

I get an error.
Post 14 Aug 2006, 07:27
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 14 Aug 2006, 11:18
of course, because you start in real mode, where max. allowd offset id 0FFFFh.

i suggest you to search this board for "real mode", "flat real mode", "unreal mode" and read some general info about 386's selectors, protected mode etc.

you need lot of theory to understand these, so prepare to few days of study....
Post 14 Aug 2006, 11:18
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
fafastrungen



Joined: 12 Aug 2006
Posts: 27
fafastrungen 14 Aug 2006, 23:57
vid wrote:
of course, because you start in real mode, where max. allowd offset id 0FFFFh.

i suggest you to search this board for "real mode", "flat real mode", "unreal mode" and read some general info about 386's selectors, protected mode etc.

you need lot of theory to understand these, so prepare to few days of study....


Thanks man for the info.
Post 14 Aug 2006, 23:57
View user's profile Send private message Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3175
Location: Denmark
f0dder 15 Aug 2006, 11:33
matrix wrote:

this is not possible in pascal.

Look up the "absolute" keyword Smile

Dunno if the various 32bit compilers support it, though.
Post 15 Aug 2006, 11:33
View user's profile Send private message Visit poster's website Reply with quote
Matrix



Joined: 04 Sep 2004
Posts: 1166
Location: Overflow
Matrix 31 Aug 2006, 03:56
f0dder wrote:
matrix wrote:

this is not possible in pascal.

Look up the "absolute" keyword Smile

Dunno if the various 32bit compilers support it, though.


i was thinking about the 286 turbo pascal(borland)

ofcourse there are 32 bit pascals already, including many libraries.

btw, there is himem.sys if you want to use ram in dos, but it won't work as "[128*1024*1024]:=150;" either

search for "extended memory usage in asm gate a20"
Post 31 Aug 2006, 03:56
View user's profile Send private message Visit poster's website Reply with quote
Artlav



Joined: 23 Dec 2004
Posts: 188
Location: Moscow, Russia
Artlav 31 Aug 2006, 09:21
About pascal (standard or 32bit) - you can access any memory location this way:

var p:pbyte; {or ^for any other structure}
begin
...
p:=pointer($010020F0);
//Now p^ is the byte at address $010020F0.
//To access next byte do
p:=pointer(dword(p)+1);
...
end.
Post 31 Aug 2006, 09:21
View user's profile Send private message Visit poster's website Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3175
Location: Denmark
f0dder 31 Aug 2006, 13:16
Well, for 16bit code of course you can't directly access high memory - but you can depend on himem.sys and use "windowed" memory.
Post 31 Aug 2006, 13:16
View user's profile Send private message Visit poster's website Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2341
Location: Usono (aka, USA)
rugxulo 01 Sep 2006, 03:16
off-topic: FreePascal 2.0.4 is released!
Post 01 Sep 2006, 03:16
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.