flat assembler
Message board for the users of flat assembler.

Index > Linux > sub r8, 8 => error ?

Author
Thread Post new topic Reply to topic
raphi



Joined: 25 Jul 2005
Posts: 3
raphi 25 Jul 2005, 14:04
Hello,

i use an Athlon64 with Linux and i have an error here :
sub r8, 8
The message is
Error: not encodable with long immediate ... yes, i know !
But i don' t find the good code Sad

could you help me ?

Regards,
Raphi
Post 25 Jul 2005, 14:04
View user's profile Send private message Reply with quote
Feryno



Joined: 23 Mar 2005
Posts: 509
Location: Czech republic, Slovak republic
Feryno 26 Jul 2005, 05:55
raw opcodes for sub r8,8
db 49h, 83h, 0E8h, 8

sub r8,8 is encodable in long mode = 64 bit OS, not in 32 bit mode (you tell it to FASM by "ELF64" for Linux, "MS64 COFF" or "PE64" for win64)
You can compile on 16bit (DOS), 32 bit (win32, Linux 32 bit), 64 bit (win64, Linux 64), but for execute you need 64 bit Linux (e.g. Fedora Core 4 64 bit)

To have an AMD64 CPU isn't enough to execute, you need 64 bit OS too. But it's still enough to compile on many OS platforms supported by FASM.

My small experiences:
I have some problems in win64 with add rsp,value and sub rsp,value. Value is immediate from 20h to 78h. I don't know why. Sometimes FASM output error message "not encodable with long immediate" then I must use raw opcode (db ...), and after I add some lines to source, I can try to use add rsp,value and this is done without error message.

I see, this is your 1st post on this forum... Try Linux 64 source samples on my homepage http://feryno.host.sk . This isn't an expert stuff, but can help for somebody with start of coding in Linux64. Maybe you are an expert and you needn't this... If you aren't, you'll be !
You can find on my samples, how to debug ELF64 executables by gdb, I don't know if other free debugger for Linux 64 exist. File .gdbinit in debug directory contain the stuff needed for output registers rax,rbx,rcx,rdx,rsi,rdi,rbp,rsp every debug step, you must add here something for display r8-r15 regs if you want, or something for xmm regs, as you like.

cd debug
gdb ./a02
r
n
n
n
n
You must remove breakpoint (db 0CCh = INT 03h) in debug/a02.fasm after finishing debug before release ELF64 for direct execute outside of debugger.
Maybe I'am lamer and breakopint can be placed by debugger after load ELF64 before execute and needn't place it in source and ELF64, but I tried this without success - maybe wrong command... I don't know gdb good enough. Place INT 03 in source and code work for me.

At the end of post is working source sample, if you can't compile it on your PC, try use
db 49h, 83h, 0E8h, 8
instead of sub r8,8
It subtract value 8 from reg r8 and then exit
You can see how r8 changes only in debugger, or add something after subtraction to display reg r8

-----cut here-----
format ELF64 executable

section readable executable writeable

entry $

sub r8,8

exit:
xor rbx,rbx ; exit code 0
mov eax,1 ; syscall_exit number
int 80h
Post 26 Jul 2005, 05:55
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
raphi



Joined: 25 Jul 2005
Posts: 3
raphi 26 Jul 2005, 07:28
Hello,

thank you very much for your long post.
I am not an expert but i know your site so i could learn Wink
I' ll try gdb and your code.
It' s not an elegant solution so it means there is a problem...

Regards,
Raphi

PS:
I use mandrake 10.1 on long mode. Before i worked with yasm but there is a problem with the instruction div and i don't yet succeed in changing yasm.
I am doing a library for long numbers for pleasure.
Post 26 Jul 2005, 07:28
View user's profile Send private message Reply with quote
raphi



Joined: 25 Jul 2005
Posts: 3
raphi 26 Jul 2005, 13:19
Hello Feryno,

GREAT !!! your code "db 49h, 83h, 0E8h, 8" runs.

Tanks Razz
Post 26 Jul 2005, 13:19
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8353
Location: Kraków, Poland
Tomasz Grysztar 28 Jul 2005, 15:06
The problem might actually have been caused by the bug in fasm, see this thread: http://board.flatassembler.net/topic.php?p=27932
Post 28 Jul 2005, 15:06
View user's profile Send private message Visit poster's website 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.