Do you receive the Programmer's Heaven newsletter? If not, why not subscribe?

x86 Assembly

Moderators: None (Apply to moderate this forum)
Number of threads: 4465
Number of posts: 15772

This Forum Only
Post New Thread

Report
output format Posted by sunion on 14 Nov 2009 at 1:14 PM
Hi, i got some problems where I can't find a solution for.

Let's say I wrote something like this:
global kernel
kernel:
	mov ax, 0xb800
	mov ds, ax
	mov ax, 0
	mov si, ax
	mov al, 'x'
	mov byte [ds:si], al
ret
loop1: jmp loop1

This put the letter 'x' directly in the video memory.
So if I assemble it in a flat binary, put it on a floppy and boot from it, it works perfectly.

Now the problem is, if I want to combine my assembly object file with a object file from let's say a 'c' program, I can't use the flat binary format.
So i have to use the elf format.
So if I use "nasm kernel.asm -f elf -o kernel.o"
and dissasmble the file and check the specific code it looks like this:

00000000  66B800B88ED8      mov eax,0xd88eb800
00000006  66B800006689      mov eax,0x89660000
0000000C  C6                db 0xC6
0000000D  B078              mov al,0x78
0000000F  3E678804C3        mov [dword ds:ebx+rax*8],al
00000014  EBFE              jmp short 0x14

You see that my "
mov ds, ax
mov si, ax

aren't there anymore. And as you could think the code doesn't work anymore.

So is it possible to link assembly with other files using a flat binary?
Or is it possible to fix the problem of my disapearing code?
btw: if I use inline assembly in gcc and write the same code and compile it, the exact code dissapears.
So its not only the problem of nasm, also of gcc.


I hope someone understands me? And knows an answer?

If you want more info, just tell me :) thanks..



 
Popular resources and forums for programmers on Programmersheaven.com
Assembly, Basic, C, C#, C++, Delphi, Java, JavaScript, Pascal, Perl, PHP, Python, Ruby, Visual Basic
© Copyright 2009 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Publisher: Lars Hagelin. Read the latest words from the publisher here.
Be the first to sign up for Lars Hagelin’s In-depth Outsourcing Newsletter here.
bootstrapLabs Logo A bootstrapLabs project.