flat assembler
Message board for the users of flat assembler.

Index > Main > distance between variables. In code, not memory.

Author
Thread Post new topic Reply to topic
b1528932



Joined: 21 May 2010
Posts: 287
b1528932 27 Feb 2011, 03:16
Code:
_sector_0_start:

jmp far 0x07c0:_a
_a:
org 0
mov ah, 0
int 16h

mov ah, 0x0E
mov bl, 0
int 10h

jmp _a



db (510 - 64) - ($ - _sector_0_start) dup 0 
db 64 dup 0
dw 0xAA55

    


i want to know the real distance between 2 labels in my code, not in memory. Is it possible? I want to use org as i like, its related to memory.
Post 27 Feb 2011, 03:16
View user's profile Send private message Reply with quote
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium
ouadji 27 Feb 2011, 09:33
Image
Wink

_________________
I am not young enough to know everything (Oscar Wilde)- Image
Post 27 Feb 2011, 09:33
View user's profile Send private message Send e-mail Reply with quote
b1528932



Joined: 21 May 2010
Posts: 287
b1528932 27 Feb 2011, 16:45
but seriously, i want to pad my file. Should i use external program to do that or what.
Post 27 Feb 2011, 16:45
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4333
Location: Now
edfed 27 Feb 2011, 19:22
no way, to know the distance between two labels... just think a little, labels are just values, then, the distance between two values... you can't find?

of course, ones you declare a new adress space with org directive, all labels before are relative to previous adress space.

then, if you do that:
Code:
org 100h
label1: rd 342354
org 100h
label2: rd 5435
org 100h
label 3: rd 3435
    

all three labels will have the same value, then, cannot extract any absolute distance between. because separate adress spaces means: not at the same place, and can't predict effective distance ones in memory... because can be loaderd in distincts zones...
Post 27 Feb 2011, 19:22
View user's profile Send private message Visit poster's website Reply with quote
b1528932



Joined: 21 May 2010
Posts: 287
b1528932 27 Feb 2011, 20:10
ok, so any idea how can i pad to the end of a sector without worrying about org positions?
Post 27 Feb 2011, 20:10
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4333
Location: Now
edfed 27 Feb 2011, 21:38
easy, did you read some code from this board before to ask?

i think you should search in OS construction section.

i posted many of them and the technique is easy.

from FASM manual, $ refer to the current offset... and $$ refer to the origin of the current adress space.

then, to padd a sector, just org it with any value you want (7C00h is better) and then, do the simple:
free=510-($-$$)
padding rb free

did i answer your question? and better, did it help you to understand Smile
Post 27 Feb 2011, 21:38
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.