flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > weird error, seems like bug

Author
Thread Post new topic Reply to topic
ProphetOfDoom



Joined: 08 Aug 2008
Posts: 120
Location: UK
ProphetOfDoom 09 Sep 2013, 19:32
Using fasm 1.70.03 for Linux. First of all, this code isn't intended to do anything useful - it's just a small snippet to illustrate the problem. Look at the two commented lines.

Code:
format ELF64

section '.data' writable

public main

extrn "exit" as exit:qword
extrn "printf" as printf:qword

align 8
SC1 db "Hi.",0

section '.text' executable

main:

push rbp
mov rbp, rsp

mov qword [rbp - 16], rdi ; assembler accepts this instruction

mov rdi, SC1
mov rax, 0
call printf

call func
call exit

func:

push rbp
mov rbp, rsp

mov qword [rbp - 16], rdi ; this (identical) instruction causes assembly to fail, and it says that "call printf" has a "value out of range" error. Changing the - to a + stops it complaining
ret
    


This nasm equivalent assembles fine:

Code:
global main

extern printf
extern exit

section .DATA

align 8
SC1: db "Hi.",0

SECTION .TEXT

main:

push rbp
mov rbp, rsp

mov qword [rbp - 16], rdi ; nasm accepts this instruction

mov rdi, SC1
mov rax, 0
call printf

call func
call exit

func:

push rbp
mov rbp, rsp

mov qword [rbp - 16], rdi ; nasm accepts this instruction too
ret
    
Post 09 Sep 2013, 19:32
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8357
Location: Kraków, Poland
Tomasz Grysztar 09 Sep 2013, 20:59
Yes, it is an ugly bug, thank you for reporting it. I have fixed it and I'm uploading the new release (1.71.13).
Post 09 Sep 2013, 20:59
View user's profile Send private message Visit poster's website Reply with quote
ProphetOfDoom



Joined: 08 Aug 2008
Posts: 120
Location: UK
ProphetOfDoom 09 Sep 2013, 21:18
You're welcome. Thanks a lot for fixing! Smile And thanks generally for an amazing piece of software.

Regards,
Me
Post 09 Sep 2013, 21:18
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.