flat assembler
Message board for the users of flat assembler.

Index > Main > converting Fasm to gas

Author
Thread Post new topic Reply to topic
fpga



Joined: 22 Sep 2009
Posts: 36
fpga
Although it runs fine I'm struggling to profile my c++ program having linked it with a Fasm.o file. I'm therefore converting it to gas using the '.intel_syntax noprefix' directive in the hope that gprof will like it.

I'm unsure how you ensure that all of "some_string", 0 goes into ebx?
In Fasm I have
Code:
section ".text" ;=================
mov ebx, label_1
section ".data" ;=================
label_1  db "some_string", 0     
In Fasm its as if these two statements work out that 'label_1' represents the address and length of the .asciz string "some_string".

I'm unsure of how you'd instruct ebx to take this number of bytes from the correct address using standard intel syntax.

I think 'movzx ecx, byte [some_label]' is done by saying 'movb ecx, [some_label]'
Post 07 Oct 2009, 20:03
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
Quote:

In Fasm its as if these two statements work out that 'label_1' represents the address and length of the .asciz string "some_string".
Just to clarify, are you saying that EBX is loaded with the string's address and length?
Post 07 Oct 2009, 21:58
View user's profile Send private message Reply with quote
fpga



Joined: 22 Sep 2009
Posts: 36
fpga
Thank you for your response.
I did think that last night but not any more.
I couldn't work out how the end of the string "some_string" was detected.
I now think the two statements above just load only the address (label_1) of the asciz string into ebx.
The string is a device file name and last night I was wondering how the program "knew" where the end of that filename, ie the 0, was.

I now think the system call, denoted by 5 in eax, which opens the file, named "some_string", only needs the string's start address in ebx i.e. I think it then moves along from that address until it finds the '0' and then opens the file with that string name.
Here's the Fasm code.
Code:
section ".text" ;=================
   mov eax, 5                 ;open the file
   mov ebx, label_1           ;file name
   mov ecx, 02o                   ;read and write    
   mov edx, 600o         ;read and write for the user
   int   80h                            ;open
section ".data" ;=================
   label_1  db "some_string", 0
    


I asked on the masm32 forum and Greg very kindly posted this conversion
Code:
.intel_syntax noprefix
.arch pentium
.global _start
.data
    label_1: .asciz "some_string"
.text
    mov ebx, OFFSET label_1
.end
    
Post 08 Oct 2009, 09:13
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-2020, Tomasz Grysztar.

Powered by rwasa.