flat assembler
Message board for the users of flat assembler.

Index > Linux > Reserved Memory by System Resources

Author
Thread Post new topic Reply to topic
donn



Joined: 05 Mar 2010
Posts: 321
donn 05 Mar 2010, 19:10
Hi, just wondering place to lookup the areas of memory reserved by an OS/system resources, places like Linux Debian would use that an application written in FASM would want to step around. Does FASM adjust code in .asm files that specify memory locations to step around these OS reserved areas?

Ok, any answer helps,
Denat
Post 05 Mar 2010, 19:10
View user's profile Send private message Reply with quote
a115433



Joined: 05 Mar 2010
Posts: 144
a115433 05 Mar 2010, 19:50
read about virtual memory.
you can access dma memory, but only if its mapped to your address space.
Post 05 Mar 2010, 19:50
View user's profile Send private message Reply with quote
kohlrak



Joined: 21 Jul 2006
Posts: 1421
Location: Uncle Sam's Pad
kohlrak 06 Mar 2010, 01:44
Well, everything is reserved unless explicitly asked for, pretty much. You're given the stack, the area in your program, and malloc/brk. I take it you're just beginning, you tried to use [0] and it didn't work?
Post 06 Mar 2010, 01:44
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger Reply with quote
donn



Joined: 05 Mar 2010
Posts: 321
donn 06 Mar 2010, 02:58
Hi, yeah, I've read through some manuals and references, worked out a lot of 'ideas' and got some of the workings down for application ideas. Progressing, but a lot of the plans and ideas aren't translated yet to run. I haven't assembled yet, wondered about how to lay down the memory portion. I must have read about the details you guys are describing in the AMD Memory Model Architecture parts, I might have also gotten virtual memory confused with like parts of 64 bit modes being more opened up in a way. Like I think I read segmentation is not used in some of the 64bit modes. I'm forgetting a lot of what I read though. Ha. I want to get less theoretical and more with results, so the responses you guys gave helped. Yea, I'm learning, to get any of the address space to work in the application, I think theres that ORG instruction, is there a requesting instruction to use before using addresses in brackets?

k,
good to hear from u both,
Denat
Post 06 Mar 2010, 02:58
View user's profile Send private message Reply with quote
Tyler



Joined: 19 Nov 2009
Posts: 1216
Location: NC, USA
Tyler 06 Mar 2010, 05:59
org specifies the offset to be added to all labels, pointers, etc., it prepares your program for the
offset it will be loaded into it's segment at. eg. With .coms under Windows, you use org 0x100
because it will be loaded into the segment provided to it by Windows at an offset of 0x100 in
that segment. Org is a "macro" that is preprocessed by Fasm, it isn't included in the code at all, it
just changes the value of location specific identifiers.
Code:
; org 0 would be implied
start:
mov byte [variable], 0
variable rb 1
    

As it is, Fasm sees "start:" as 0 and will substitute 0(idk if actually does, but in effect it does the same thing) for it anywhere it sees it, and will
substitute all occurrences of "variable" with 3?(idk instruction sizes). But with org, you can tell Fasm that your program isn't going to be loaded at 0, but 0x7c00
Code:
org 0x7c00
start:
mov byte [variable], 0
variable rb 1
    

Now Fasm sees "start:" as 0x7c00 and (assuming "mov byte [variable], 0" is 3 bytes
in size) sees "variable" as 0x7c03
Post 06 Mar 2010, 05:59
View user's profile Send private message Reply with quote
donn



Joined: 05 Mar 2010
Posts: 321
donn 07 Mar 2010, 02:20
Cool, I'll use it like that.

Denat
Post 07 Mar 2010, 02:20
View user's profile Send private message Reply with quote
kohlrak



Joined: 21 Jul 2006
Posts: 1421
Location: Uncle Sam's Pad
kohlrak 08 Mar 2010, 00:58
I noticed you're having trouble with getting started; you may find this useful.


Description:
Download
Filename: main.asm
Filesize: 282 Bytes
Downloaded: 457 Time(s)

Description: not entirely stable, but it's good enough. Might want to learn the ABI while you're at it.
Download
Filename: linhead64.inc
Filesize: 16.62 KB
Downloaded: 452 Time(s)

Post 08 Mar 2010, 00:58
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger Reply with quote
donn



Joined: 05 Mar 2010
Posts: 321
donn 29 Mar 2010, 03:47
So,
Code:
     ;Print
@@:       pop rsi
     invoke printf, msg, null
    dec rbx
     jnz @b    
is the way to print to like a terminal? What does the @@ mean? Does this step always require a dependent include file, like linhead64.inc? A lot of the code in linhead64.inc is very new to me, beyond me for the time being. While trying to assemble, got an error:
Code:
flat assembler  version 1.68  (16384 kilobytes memory)
main.asm [6]:
includes "libc.so.6", printf ;MUST BE BEFORE ANY SEGMENTS
linhead64.inc [16] includes [2]:
             segment interpreter readable
error: extra characters on line.
    
, Is line 16 saying too much? I tried removing readable, but same error. Yes, a lot of this is new, you guys have been great help too.

Denat
Post 29 Mar 2010, 03:47
View user's profile Send private message 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.