flat assembler
Message board for the users of flat assembler.
Index
> Linux > hello! about linux fasm segment address a problem Goto page 1, 2 Next |
Author |
|
revolution 02 Apr 2016, 01:04
I didn't realise Linux supported 16-bit code.
What is in your "format ..." line? |
|||
02 Apr 2016, 01:04 |
|
system error 02 Apr 2016, 01:32
mr kerr, I suggest you stop reading 16-bit examples (int 21h, cs, ds etc) because you'll be confusing yourself. We will sue you if you keep reading them and then trying to implement them on 32-bit Linux. Yeahhh!
|
|||
02 Apr 2016, 01:32 |
|
kerr 02 Apr 2016, 23:32
kerr wrote: Do you know how FASM will move the segment address to DS or CS? I is want speak fasm How to take the segment address move to ds segment? _________________ I hope we will be good friends. |
|||
02 Apr 2016, 23:32 |
|
revolution 03 Apr 2016, 00:38
kerr: What is your format?
Code: format ... ;<--- what do you have here? |
|||
03 Apr 2016, 00:38 |
|
kerr 05 Apr 2016, 09:34
revolution wrote: kerr: What is your format? is use ld -m elf_i386 -Ttext 0x10000 you know fasm use segment address move to ds register? _________________ I hope we will be good friends. |
|||
05 Apr 2016, 09:34 |
|
revolution 05 Apr 2016, 13:21
kerr: Do you have a line in your source "format ..."? I ask because there is no ELF format that supports 16-bit code.
And if you are using 32-bit mode then there are no segments in 32-bit mode. 32-bit mode has selectors which you can't (or at least shouldn't try to) change from user code. Last edited by revolution on 05 Apr 2016, 15:05; edited 2 times in total |
|||
05 Apr 2016, 13:21 |
|
system error 05 Apr 2016, 14:29
mr kerrrrrrrrr,
You mixed up too many things that are not even compatible with each other. You are referring to 16-bit MASM code that don't even compile in Linux. MASM sticks with Windows-only. Then I suspect you are referring to 16-bit NASM code that use ld as linker on Linux or Windows or probably both. If you want to learn FASM 16-bit program, use Windows, don't use Linux. I give you one code template that you can use to start programming 16-bit FASM Code: format MZ entry CSEG:main segment DSEG msg db 'Hello World',0dh,0ah,'$' segment CSEG main: mov ax,DSEG mov ds,ax mov dx,msg mov ah,9 int 21h mov ah,4ch int 21h Now you can start practicing your 16-bit code. Come back if you still have problems. I haven't tested this code but I think they should run (you have 32-bit Windows, right?) |
|||
05 Apr 2016, 14:29 |
|
kerr 06 Apr 2016, 01:07
revolution wrote: kerr: Do you have a line in your source "format ..."? I ask because there is no ELF format that supports 16-bit code. You Misunderstanding my meaning! iI Just want Ask fasm move segment address! _________________ I hope we will be good friends. |
|||
06 Apr 2016, 01:07 |
|
kerr 06 Apr 2016, 01:09
system error wrote: mr kerrrrrrrrr, I just Want ask linux for fasm move segment address ! With this Independent! _________________ I hope we will be good friends. |
|||
06 Apr 2016, 01:09 |
|
revolution 06 Apr 2016, 01:14
kerr: You misunderstand the Linux system. It doesn't have segments. It has selectors, and you have no control over them from the source code, and thus you can't give them a name and set them to whatever you want.
You can always access the DS (or CS, or whatever) register, that is trivial, but it is not a segment. All OSes that use protected mode do not have segments. So you are asking for something that does not exist. |
|||
06 Apr 2016, 01:14 |
|
kerr 06 Apr 2016, 17:12
revolution wrote: kerr: You misunderstand the Linux system. It doesn't have segments. It has selectors, and you have no control over them from the source code, and thus you can't give them a name and set them to whatever you want. oh yeah! Even if you're right, I wont do it. because if computer it doesn't have segments how to run your program? objdump eg: Code: $ objdump -d -j .plt libfoobar.so libfoobar.so: file format elf32-i386 Disassembly of section .plt: 000003a4 <__gmon_start__@plt-0x10>: 3a4: ff b3 04 00 00 00 pushl 0x4(%ebx) 3aa: ff a3 08 00 00 00 jmp *0x8(%ebx) 3b0: 00 00 add %al,(%eax) ... 000003b4 <__gmon_start__@plt>: 3b4: ff a3 0c 00 00 00 jmp *0xc(%ebx) 3ba: 68 00 00 00 00 push $0x0 3bf: e9 e0 ff ff ff jmp 3a4 <_init+0x18> 000003c4 <cos@plt>: 3c4: ff a3 10 00 00 00 jmp *0x10(%ebx) 3ca: 68 08 00 00 00 push $0x8 3cf: e9 d0 ff ff ff jmp 3a4 <_init+0x18> 000003d4 <fwrite@plt>: 3d4: ff a3 14 00 00 00 jmp *0x14(%ebx) 3da: 68 10 00 00 00 push $0x10 3df: e9 c0 ff ff ff jmp 3a4 <_init+0x18> 000003e4 <fprintf@plt>: 3e4: ff a3 18 00 00 00 jmp *0x18(%ebx) 3ea: 68 18 00 00 00 push $0x18 3ef: e9 b0 ff ff ff jmp 3a4 <_init+0x18> 000003f4 <__cxa_finalize@plt>: 3f4: ff a3 1c 00 00 00 jmp *0x1c(%ebx) 3fa: 68 20 00 00 00 push $0x20 3ff: e9 a0 ff ff ff jmp 3a4 <_init+0x18> readelf eg: Code: $ readelf -r bar.o Relocation section '.rel.text' at offset 0x4bc contains 6 entries: Offset Info Type Sym.Value Sym. Name 00000008 00000b02 R_386_PC32 00000000 __i686.get_pc_thunk.bx 0000000e 00000c0a R_386_GOTPC 00000000 _GLOBAL_OFFSET_TABLE_ 00000025 00000d04 R_386_PLT32 00000000 cos 0000002e 00000e03 R_386_GOT32 00000000 stdout 00000044 00000509 R_386_GOTOFF 00000000 .rodata 00000050 00000f04 R_386_PLT32 00000000 fprintf I just want ask use fasm how to move the program head address to ds segments. if use ld linker eg: Code: format elf public _start section ".data" readable writeable msg db "hello world!",0xa section ".text" executable _start: mov eax, data mov ds, eax mov eax,msg …… …… $ fasm hello.asm $ ld -s hello.o -o hello if no use linker fasm is no segment mark, I don't know how to move the segment address to ds register! Code: format elf executable entry _start segment readable writeable msg db "hello world!",0xa segment executable _start: mov eax,??? mov ds,eax mov eax,msg …… …… $ fasm hello.asm what do you know my say? _________________ I hope we will be good friends. |
|||
06 Apr 2016, 17:12 |
|
revolution 06 Apr 2016, 23:43
kerr: fasm doesn't move the segment address to DS because there are no segment address registers in 32-bit protected mode. DS is a selector and it does not correspond to any address directly. The OS assigns the values for the selectors and user code can't control that. You simply do not need to change the value of any of the CS, DS, ..., SS registers.
|
|||
06 Apr 2016, 23:43 |
|
kerr 10 Apr 2016, 09:49
revolution wrote: kerr: fasm doesn't move the segment address to DS because there are no segment address registers in 32-bit protected mode. DS is a selector and it does not correspond to any address directly. The OS assigns the values for the selectors and user code can't control that. You simply do not need to change the value of any of the CS, DS, ..., SS registers. oh, you speak i don't know. so what do you move program header address to DS register? _________________ I hope we will be good friends. |
|||
10 Apr 2016, 09:49 |
|
revolution 10 Apr 2016, 12:33
kerr: For 32-bit protected mode (this is what Linux runs in) you do not need to touch DS for anything. If you do try to change DS then bad things will happen.
If you want to access any address in the program you should address it directly: Code: format elf ... ;... label1: ;... mov eax,label1 mov eax,[label1] lea eax,[label1] jmp label1 call label1 ;... |
|||
10 Apr 2016, 12:33 |
|
kerr 11 Apr 2016, 02:10
revolution wrote: kerr: For 32-bit protected mode (this is what Linux runs in) you do not need to touch DS for anything. If you do try to change DS then bad things will happen. okey thank you good idea ! but my idea is move program header address to ds registar! _________________ I hope we will be good friends. |
|||
11 Apr 2016, 02:10 |
|
revolution 11 Apr 2016, 02:17
You can't. DS can't do that for you, it is not a segment register in PM32. You seem to have completely missed the point about DS being a selector.
|
|||
11 Apr 2016, 02:17 |
|
kerr 11 Apr 2016, 05:36
revolution wrote: You can't. DS can't do that for you, it is not a segment register in PM32. You seem to have completely missed the point about DS being a selector. oh ! that i don't know! You say what mean! in memory isn't Physical address = Segment address +OFFSET address? that how do you use segment +offset form physical address? eg: [ds:esi]? According to what you mean no segment, that DS segment cannot plus offset address... _________________ I hope we will be good friends. |
|||
11 Apr 2016, 05:36 |
|
revolution 11 Apr 2016, 06:34
For most PM OSes the DS, ES, CS and SS selectors are simply set so that the base address is 0x00000000. And you can't know the RAM physical address in most cases, you only know the logical address before paging is applied. So whether you use DS, or ES, or whatever, you always get the same address.
Note that, for example, the DS and CS registers will have different values but they will still point to the same memory address after translation through the selector tables. |
|||
11 Apr 2016, 06:34 |
|
kerr 11 Apr 2016, 08:43
revolution wrote: For most PM OSes the DS, ES, CS and SS selectors are simply set so that the base address is 0x00000000. And you can't know the RAM physical address in most cases, you only know the logical address before paging is applied. So whether you use DS, or ES, or whatever, you always get the same address. I'm confused. can you tell me how to use ds segment +esi offset _________________ I hope we will be good friends. |
|||
11 Apr 2016, 08:43 |
|
Goto page 1, 2 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.