flat assembler
Message board for the users of flat assembler.

Index > Linux > hello! about linux fasm segment address a problem

Goto page Previous  1, 2
Author
Thread Post new topic Reply to topic
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20303
Location: In your JS exploiting you and your system
revolution 11 Apr 2016, 08:58
DS is automatically used when you don't specify it. The following are the same:
Code:
mov eax,[esi]
mov eax,[ds:esi] ;exactly the same    
.

kerr: In Linux you can forget about the segment registers. You can't change them from user code like you can from DOS. DOS is RM and Linux is PM.
Post 11 Apr 2016, 08:58
View user's profile Send private message Visit poster's website Reply with quote
kerr



Joined: 24 Feb 2016
Posts: 156
kerr 12 Apr 2016, 09:21
revolution wrote:
DS is automatically used when you don't specify it. The following are the same:
Code:
mov eax,[esi]
mov eax,[ds:esi] ;exactly the same    
.

kerr: In Linux you can forget about the segment registers. You can't change them from user code like you can from DOS. DOS is RM and Linux is PM.


Oh,

I want to ask if you program run in 0x80004000 address ,But you want Specify it visit your data segment address 0x80001000, how do you make it?

_________________
I hope we will be good friends.
Post 12 Apr 2016, 09:21
View user's profile Send private message Reply with quote
l_inc



Joined: 23 Oct 2009
Posts: 881
l_inc 13 Apr 2016, 21:05
Quote:
But you want Specify it visit your data segment address 0x80001000, how do you make it?

mov eax,[0x80001000]

_________________
Faith is a superposition of knowledge and fallacy
Post 13 Apr 2016, 21:05
View user's profile Send private message Reply with quote
kerr



Joined: 24 Feb 2016
Posts: 156
kerr 17 Apr 2016, 04:16
l_inc wrote:
Quote:
But you want Specify it visit your data segment address 0x80001000, how do you make it?

mov eax,[0x80001000]



Oh,I probably know what you mean!
Your's speak 32bit is no segment address + offset address? is Direct call Physical address?

Code:
mov eax,0x80001000
call eax
######################
 Is it right
    

_________________
I hope we will be good friends.
Post 17 Apr 2016, 04:16
View user's profile Send private message Reply with quote
l_inc



Joined: 23 Oct 2009
Posts: 881
l_inc 17 Apr 2016, 10:53
kerr
Quote:
Your's speak 32bit is no segment address + offset address?

It's not about 32 bit. It's about Linux. It sets segment base address = 0 for all relevant segments.
Quote:
is Direct call Physical address?

It's not physical address. It's virtual address. In Linux you cannot work with physical addresses directly, because it works with enabled paging.
Quote:
Is it right

Yes. But if your code is not relocatable then you can just do call 0x80001000 .

_________________
Faith is a superposition of knowledge and fallacy
Post 17 Apr 2016, 10:53
View user's profile Send private message Reply with quote
kerr



Joined: 24 Feb 2016
Posts: 156
kerr 19 Apr 2016, 01:57
l_inc wrote:
kerr
Quote:
Your's speak 32bit is no segment address + offset address?

It's not about 32 bit. It's about Linux. It sets segment base address = 0 for all relevant segments.
Quote:
is Direct call Physical address?

It's not physical address. It's virtual address. In Linux you cannot work with physical addresses directly, because it works with enabled paging.
Quote:
Is it right

Yes. But if your code is not relocatable then you can just do call 0x80001000 .



oh yeah!

well, i can see the writing on the book,i try to write operating system.
is unable to compile.

Code:
jmp _start  ;0x8:0x400  
  
    stack times 128 db 0  
_start:  
    mov ax,ds  
    mov ds,ax  
    mov ss,ax  
    mov es,ax  
    mov fs,ax  
    mov gs,ax  
    mov eax,stack  
    mov esp,eax  
    xor eax,eax 
    

_________________
I hope we will be good friends.
Post 19 Apr 2016, 01:57
View user's profile Send private message Reply with quote
l_inc



Joined: 23 Oct 2009
Posts: 881
l_inc 19 Apr 2016, 11:16
kerr
Quote:
i try to write operating system

That's what you should have told at the very beginning. You also shouldn't have created your topic in the Linux subforum. The answers would have been completely different.

Quote:
unable to compile

You cannot use the word stack as label name. It's reserved. You also cannot declare a label using the times directive: put colon after the label name or use either db 128 dup 0 or rb 128 .

_________________
Faith is a superposition of knowledge and fallacy
Post 19 Apr 2016, 11:16
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20303
Location: In your JS exploiting you and your system
revolution 19 Apr 2016, 14:31
kerr: If you are writing an OS boot loader then your format line should look like this:
Code:
format binary ...    
If you are writing a real mode (RM) OS then you will need to concern yourself with the segment registers. If you are writing a protected mode (PM) OS and you intend to use paging then you can set the selectors to be fixed for all tasks.
Post 19 Apr 2016, 14:31
View user's profile Send private message Visit poster's website Reply with quote
kerr



Joined: 24 Feb 2016
Posts: 156
kerr 20 Apr 2016, 03:54
l_inc wrote:
kerr
Quote:
i try to write operating system

That's what you should have told at the very beginning. You also shouldn't have created your topic in the Linux subforum. The answers would have been completely different.

Quote:
unable to compile

You cannot use the word stack as label name. It's reserved. You also cannot declare a label using the times directive: put colon after the label name or use either db 128 dup 0 or rb 128 .



oh i don't know!

I thought it was compiled on Linux!

_________________
I hope we will be good friends.
Post 20 Apr 2016, 03:54
View user's profile Send private message Reply with quote
kerr



Joined: 24 Feb 2016
Posts: 156
kerr 20 Apr 2016, 07:31
revolution wrote:
kerr: If you are writing an OS boot loader then your format line should look like this:
Code:
format binary ...    
If you are writing a real mode (RM) OS then you will need to concern yourself with the segment registers. If you are writing a protected mode (PM) OS and you intend to use paging then you can set the selectors to be fixed for all tasks.


yeah

So I'm confused
The use of the book is the NASM compiler,I try to use FASM how can not compile.

_________________
I hope we will be good friends.
Post 20 Apr 2016, 07:31
View user's profile Send private message Reply with quote
Trinitek



Joined: 06 Nov 2011
Posts: 257
Trinitek 20 Apr 2016, 07:41
NASM and FASM are different assemblers with different syntax and keywords. Confused Perhaps you should use NASM if you're learning from a NASM book?
Post 20 Apr 2016, 07:41
View user's profile Send private message Reply with quote
kerr



Joined: 24 Feb 2016
Posts: 156
kerr 23 Apr 2016, 02:10
Trinitek wrote:
NASM and FASM are different assemblers with different syntax and keywords. Confused Perhaps you should use NASM if you're learning from a NASM book?


Yes, I want to use FASM to rewrite the Nasm syntax

_________________
I hope we will be good friends.
Post 23 Apr 2016, 02:10
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2

< 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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.