flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > What About A Fix :P

Author
Thread Post new topic Reply to topic
gumletis



Joined: 18 Dec 2004
Posts: 128
gumletis 07 Feb 2005, 13:59
Hi, I found out with decompile a simply program, that there isn't anything called labels, when you use the "jmp", or "call" its just call or jump to a line, i've tryed to do that without a label, i've tryed alot of things, but doesn't work, and just wanna hear about there should be a bug in it, becuase when you example use "call 0x4" its conveter it to a line, or some shit, donno, are its a bug or its me there is wrong on it... PS like the subject Razz??

_________________
LOOOL
Post 07 Feb 2005, 13:59
View user's profile Send private message Reply with quote
pelaillo
Missing in inaction


Joined: 19 Jun 2003
Posts: 878
Location: Colombia
pelaillo 07 Feb 2005, 16:41
Could you clarify a little? I didn't manage to follow you.

If you decompile a program and there is no debug information nor sources, you cannot figure out what the labels were called. Labels just dissapeared when you assemble a program.
Post 07 Feb 2005, 16:41
View user's profile Send private message Yahoo Messenger Reply with quote
gumletis



Joined: 18 Dec 2004
Posts: 128
gumletis 08 Feb 2005, 15:48
Yes, thats the problem, labels are just illusion, i wanna do a CALL or a jmp command without need to use a label. Like

jmp 0x4 ; JUMP TO
mov ah,0x0 |
int 0x16 \/
mov dx,cx ; here

without need to do like this


jmp mylabel
mov ah,0x0
int 0x16
mylabel:
mov dx,cx


.... please help me, and say if you doesn't understand what im saying, so its my bad english and please ask me again

_________________
LOOOL
Post 08 Feb 2005, 15:48
View user's profile Send private message Reply with quote
beppe85



Joined: 23 Oct 2004
Posts: 181
beppe85 08 Feb 2005, 17:47
You need to know ahead the size of each encoded instruction. That makes hard mantaining of program.

Better if you use anonymous labels, like:
Code:
jmp @f
mov ah,0x0
int 0x16
@@:
mov dx,cx    


@f means the label just after the instruction. @b means the label just before the instruction.
Post 08 Feb 2005, 17:47
View user's profile Send private message Reply with quote
gumletis



Joined: 18 Dec 2004
Posts: 128
gumletis 08 Feb 2005, 18:43
i know, but doesn't wanna use any labels, becuase the compiler change of the labels so there isn't any labels, so i wanna use the only thing that the program do when its assembled, and its just to jump or call a line.

_________________
LOOOL
Post 08 Feb 2005, 18:43
View user's profile Send private message Reply with quote
beppe85



Joined: 23 Oct 2004
Posts: 181
beppe85 08 Feb 2005, 19:02
gumletis wrote:
i know, but doesn't wanna use any labels, becuase the compiler change of the labels so there isn't any labels, so i wanna use the only thing that the program do when its assembled, and its just to jump or call a line.

Sorry, but this is BASIC. Assembly handles bytes.

_________________
"I assemble, therefore I am"

If you got some spare time, visit my blog: http://www.beppe.theblog.com.br/ and sign my guestmap
Post 08 Feb 2005, 19:02
View user's profile Send private message Reply with quote
gumletis



Joined: 18 Dec 2004
Posts: 128
gumletis 08 Feb 2005, 19:48
what you mean that this is the basic? are there away to do it?, if not so i would ask for made so you can do it, fx if the compiler get this "jmp [[0x4]]" so its jump to line 4, or "call [[0x4]]" PLEASE! becuase i've seen that in the source code there is just "jmp 0x4" if you have a label in line 4

_________________
LOOOL
Post 08 Feb 2005, 19:48
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 09 Feb 2005, 13:24
it's like this:
Code:
jmp here
db 100h
here:
    

"jmp" is followed by value which is RELATIVE distance of jump (eg. how far forward / backward you want to jump). So compiler just calculates fifference between target of jump (label here) and "jmp" instruction and this is used as argument for jump
Post 09 Feb 2005, 13:24
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
gumletis



Joined: 18 Dec 2004
Posts: 128
gumletis 09 Feb 2005, 13:53
Yes, but the problem is that i wanna do it without the distance, i wanna do it my self. So instead of this
Code:
jmp here
db 100h
here:
    

i wanna do it some like this
Code:
jmp 0x3             ; donno if its 0x3    or 0x4(becuase of the start point of the file or such thing :-s
db 100h
xor ah,ah
    


Are there a way to do it that way?

_________________
LOOOL
Post 09 Feb 2005, 13:53
View user's profile Send private message Reply with quote
asmdemon



Joined: 18 Jan 2004
Posts: 97
Location: Virginia Beach, VA
asmdemon 09 Feb 2005, 14:41
I think i understand what your looking for. The problem is that you need some form of reference to JMP to.

Code:
org 0x100
jmp 0x0104 ;static value i entered to jump to xor ah,ah
dw 0x0000
xor ah, ah
    


compiles the same as:

Code:
org 0x100
jmp dojump ;label to the unknown location of xor ah, ah
dw 0x0000
dojump:
xor ah, ah
    


To figure out the actuall jump location, you would have to calculate the number of bytes that you are jumping to and insert that as a value after the JMP command. FASM does this automatically because it knows the bytes that each specific command takes, but if you want to do it by hand you would have to manually count the bytes required for the jump, then add that number( 0x04) to your ORG (0x0100). The only downside is what if you want to do this:
Code:
org 0x0100
jmp 0x0104
dw 0x0000
db 0x00  ;you needed more data space, for example.
xor ah, ah
    

now your code jumps to a data db instead of the xor instruction. This could become a pain in debugging your code because just a small change will change all of your data and jmp locations.
I hope i answered your question. Smile
Post 09 Feb 2005, 14:41
View user's profile Send private message Visit poster's website Reply with quote
gumletis



Joined: 18 Dec 2004
Posts: 128
gumletis 10 Feb 2005, 17:08
nice asm-demon, that was what i was looking for, THANKS! i know if i change a single thing it would change all the jmp locations, but K.I.S.S, and i don't want the compiler to do so much for me, Razz
Post 10 Feb 2005, 17:08
View user's profile Send private message Reply with quote
Mota



Joined: 29 Dec 2004
Posts: 22
Mota 10 Feb 2005, 17:44
gumletis, the jmp doesnt jump to a line, it jumps to a certain address, in bytes. jmp 0x104 is just a coincidence that it is , in fact, line 4.

to do what you want (line jmps), you'd need to code a macro to place as a prefix each line, and a new macro for jmps and calls.

Or you could make your own version of fasm, where you can use the word line to change the number after it to the actual address.
Post 10 Feb 2005, 17:44
View user's profile Send private message Reply with quote
gumletis



Joined: 18 Dec 2004
Posts: 128
gumletis 10 Feb 2005, 18:15
lol, my own version of fasm, fasm is almost perfect, only a few things there should be changed in it(if you ask me) and lol, i am not so good to asm that i can do that, and also i just use the "certain" address, becuase i wanna do that the compiled program do, like i don't wanna write

int 21h

i wanna write

int 0x21

just some small things i don't do, for have my compiler not change anything for me
Post 10 Feb 2005, 18:15
View user's profile Send private message Reply with quote
gunblade



Joined: 19 Feb 2004
Posts: 209
gunblade 10 Feb 2005, 21:21
int 0x21 is fine, and is taken to be exactly the same as int 21h by fasm. Smile

i see what you mean, something like jmp +4 would jump 4 bytes ahead, it could be fun, but i really dont see the need for that, very unmaintainable, having labels is much nicer.
Post 10 Feb 2005, 21:21
View user's profile Send private message Reply with quote
gumletis



Joined: 18 Dec 2004
Posts: 128
gumletis 11 Feb 2005, 17:20
lol, my friend call me unhuman becuase i didn't like labels, and want to jump/call to lines instead of using the labels... Razz
Post 11 Feb 2005, 17:20
View user's profile Send private message Reply with quote
bubach



Joined: 17 Sep 2004
Posts: 341
Location: Trollhättan, Sweden
bubach 12 Feb 2005, 15:02
so use:
Code:
jmp line1
dw 0x0000
line1: mov cx, ax    

Wink
Post 12 Feb 2005, 15:02
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8359
Location: Kraków, Poland
Tomasz Grysztar 12 Feb 2005, 15:07
gunblade wrote:
i see what you mean, something like jmp +4 would jump 4 bytes ahead,

You can do just:
Code:
jmp $+4    

to jump 4 bytes ahead.
Post 12 Feb 2005, 15:07
View user's profile Send private message Visit poster's website Reply with quote
THEWizardGenius



Joined: 14 Jan 2005
Posts: 382
Location: California, USA
THEWizardGenius 22 Feb 2005, 22:57
Just do a JMP FAR!
Code:
jmp far cs:[0FFFFh]
    

I think this will assemble, don't know exactly if it would do what you want, but it does what I want... Razz (I have FASM at home, but I'm at school right now...)

Of course, you can use this code:
Code:
jmp far [hi]
;...
hi dd 00000000h ;Address you want to jump to here...
    


I didn't know that that was legal usage of JMP, but I saw something similar used in the sourcecode for some old BIOS, so I guess it probably works...

Good luck Exclamation
Post 22 Feb 2005, 22:57
View user's profile Send private message AIM Address 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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.