logs archiveIRC Archive / Undernet / #asm / 2006 / April / 12 / 1
Xezaw
hi
_sin
why do you figure the bound and into instruction are rarely used considering the obvious security implications they have?
lutz
(Action) afk
corex
does anyone what's the purpose of an assembler program (or many modules of an assembler program ) having sections ( like .sect , or .bss .. and so on ) ?
I know that in some sections you can put only data , in other sections you can put code , and in other sections like .sect you can put both ... but what's the purpose of this ?
ike`
so you can put rights to the sections
code has read and execute
data has read write
and you can`t have initialized and uninitialized data in one section
corex
ok, you said "code has read and execute " , so who can read and execute those ssections of code ?
ike`
the system...
and you
if you try to write to that section a segfault occurs
corex
you mean write from within the program (the .asm file ) or from where ?
ike`
ok, let me explain
your program has these sections
they are separated in the exe file
and loaded separately
text is copied i the memory
uninitialized data is zeroed out
and initialized data is also copied
do you understand now?
         

corex
text is the .asm file , right ?
ike`
NO
text is compiled code
the sh*t that actually runs
the bytecode
corex
ok
so uninitialise data and initialised data is not part of the text ?
ike`
no
corex
ok, and when I say uninitialised data I should think of .. like a variable which is not initialised , ? and when say initialised data it's like a variable to which I gave a value in my .asm program ?
ike`
yup
corex
my English is not that good so I have to ask : what's "zeroed out " ?
ike`
what is your lang?
corex
romanian, :)
ike`
eh, asa mai mere :)
corex
:)
ike`
deci, umpluta cu zeroaie
corex
ya :) , da aici se poate vorbi altceva decat engleza ?
ike`
cui ii pasa?
corex
:)
ike`
deci, loaderu incarca programu, vede sectiune neinitializata, aloca memoria, o umple cu zero...
vezi ca pe stiva nu ti`o goleste nimeni.. oricum daca scrii asm adevarat, fara magareli delea cu proc si altele, cum scrii in masm, atunci o vezi ca`i ebp-x
corex
da io nu-nteleg o chestie , de exemplu daca sistemu pe care o sa ruleze programul e de fapt un microcontroler, atunci loader-ul este pe microcontroler si nu pe pc (unde e asamblorul cu linkerul) nu ?
ike`
mmm... daca e pe microcontroller atunci se schimba lucrurile...
corex
da ..? pai de ce ca si asta are sectiuni ..
ike`
dah, dar astea `s mapate direct pe memoria chestiunii in cauza
de ex .code o sa fie undeva in rom
.data in ram
astea trebuie specificate cu mana
         

corex
da am vazut si io asta cu Rom si Ram, da de fapt le specifici cu mana in .asm acolo unde zici ca incepi o sectiune , deci unde scrii de ex. " .sect sau .bss , nu ?
ike`
cand declari sectiunea o sa`i scrii undeva pe langa si adresa, si accesu. oricum daca`i dai accesu gresit si incerci sa scrii in rom o sa`ti crape
corex
pai aia cu adresa am vazut ca se scrie , da' de acces n-am vazut nimic , aia cu accesul cum ar trebui sa arate in .asm ?
ike`
depinde ce asamblor folosesti
io nu prea ma pricep la astea, am scris programe de windows/linux pe calc si n`am programat microcontrolere pana acuma
oricum, se gaseste in doxurile asamblorului
corex
oka, da de-asta zic ca in doxuri n-am vazut nimic legat de acces, numa despre adresele sectiunilor zice, si-atunci ma gandesc ca se poate sa nu fie partea cu accesu/drepturile , si-atunci tre sa revin la prima mea intrebare : ce rost are sa faci sectiuni , ca ziceai ca pt. a le da drepturi , da daca asamblorul asta al meu nu stie drepturi , atunci de ce naiba l-o facut sa stie sectiuni :) ?
ike`
ca sa separi capra de varza
corex
:), da .pai io n-am prea separat pana acuma capra de varza ...
ike`
deci mai, cand ii zici .code si adresa, atunci ii zici compilatorului: vezi ca codul e aici, ai grija cum asamblezi
daca e vorba de un microcontroller atunci e obligatoriu sa separi datele de cod. pai daca asamblezi cu date in cod si sectiunea vine flash`uita in memorie si tu incerci sa scrii iti dai seama ca o sa crape
corex
pai la ucontrolerul meu , asamblorul lui stie o sectiune (.sect ) in care poti sa pui si cod si date si poti s-o denumesti cum vrei , si-atunci ma gandesc ca explicatia e ca sectiunea asta (.sect) nu e flash-uita , nu ?
ike`
probabil .. weird
cauta niste documentatie, asa pe neve nush peste ce o sa mai dai
corex
da ..ok .. oricum loader-ul ma gandesc ca poate sa fie numa pe ucontroller , nu ? ca doar n-are ce sa caute pe PC ..
ike`
dah, io vorbeam de prog in windows/linux
pe microcontrolere ai numa o adresa de unde se incepe executia, deci trb sa`ti pozitionezi codu` sa` pice unde trebuie
corex
aha
da, pai atuncea asta o fi diferenta , ca daca asamblorul e pe PC si e pentru program ce-o sa ruleze pe PC atunci probabil ca aadresa de start a programului nu tre sa fie intotdeauna aceeasi , pentru ca este memorie mai multa decat pe ucontroler si se ocupa loader-ul sistemului de operare sa incarce la adresa la care ai zis tu in .asm ca incepe sectiunea
ike`
nope
corex
la ucontroler ma gandesc ca tot loadeerul se ocupa sa incarce la adresa la care ai zis ca incepe sectiunea in asm, numai ca adresaa e intotdeauna aceeasi ca este memorie mai putina , nu ?
nope ?
da de ce ?
ike`
de ex toate programele incep la 0x4000000
cred ca am pus un 0 in plus
pe windows
:)
dll`urile sunt incarcate care si pe unde
corex
pai is 6 de zero acolo, cati tebuiau sa fie ?
aha
ike`
oricum, os`ul isi permite sa faca rebase, si alte alea pe cand pe microcontroller aia e prima instructiune care se executa...
corex
rebase e totuna cu relocation ?
ike`
aha
dbtid
i'm glad you found someone who speaks your language.
disc
(Action) snickers.
corex
da , tipul se bucura.. ... acuma ideea e ca n-am stiut de canalul asta ca intram mult mai devreme :) .. .. si acuma l-am gasit ca am zis : hai sa-ncerc sa-i dau join : #asm , poate exista canalu :) , asa l-am gasit :)
BoR0
o_O
corex
stie cineva care-i diferenta intre macro instructiuni si functii/proceduri intr-un limbaj de asamblare ?
sorry
does someone know what the difference is between macro instructoins and functions/procedures in an assembller language ?
BoR0
those are 2 totally different terms
so you want differences, where should i start ;)
corex
let's say the main difference !
_sin
a macro doesn't imply a procedure/function?
Deathmaster
lol
BoR0
macro and functions are both set of instructions
except if you call the macro 3 times it will take 3x(bytes of code) and for procedures 1x(bytes of code) (no matter the n times you call it)
ike`
macrourile se execut INAINTE de compilare ... sunt bune ca sa iti tzii codul portabil si ca sa iti simplifici munca, sa nu mai scrii aceleasi bucati de j ori
corex
so when you say "bytes of code " I guess you mean machine code , right ?
ca sa tii codul portabil , in ce sens ?
se executa inainte de compilare chiar si in cazul limbajelor de asamblare ?
ike`
macrourile nu sunt cod
BoR0
either talk English or whatever, i will now stop answering your questions
ike`
let`s talk in english
corex
ok , sorry , my question was : so when you say "bytes of code " I guess you mean machine code , right ?
BoR0 ?
BoR0
if your macro takes 3 bytes of code, and you call it 3 times, it will take 9 bytes
if your function takes 3 bytes of code, and you call it n times, it will take 3 bytes (+ the CALL instruction)
Deathmaster
corex: i already explained you what you had asked, why bother with the same question ?
BoR0
macros are invented for readability of code
say you have
m2m macro reg1
push reg1
pop reg1
m2m endm
and in code you have "m2m eax" the assembler will just replace every m2m found with the code in the macro
you can download ollydbg (www.ollydbg.com) which will show you what its translated to so you can see it far better than explained here :)
_sin
are you familar with C or C++ ?
Deathmaster
=))
corex
ok, and that eplacement is done before assembling ?
ike`
let me give you an example: i have a function a that differs in implementation from os to os. i can write a macro that detects on what os i am compiling and enable only the implementation for the machine i am compiling on, thus keeping the code portable
BoR0
yes, preprocessor
corex
ike' , is that possible on assembly language ?
ike`
ofcourse
BoR0
ike: portability with assembler? thats a very bad idea
_sin
presuming each os runs on the same type of processor
ike`
well, you can use it to tune your app for a specific processor
BoR0
ike: what assembler are you referring to?
ike`
and that`s a verry GOOD idea
BoR0
is there an assembler that runs on every processor?
corex
I'm confused here, I've only seen that in c, o c++, and I thought that were called directives ...
_sin
he's talking about different version's of the same processor
ike`
yup
_sin
i.e. 80486 and Pentium
ike`
yup
_sin
not intel and sparc
BoR0
ah, that is different
_sin
corex
think of macro's as #define's
because thats exactly what they are
ike`
they are called macros even in c..
_sin
#define foo(msg, fmt) do { printf(fmt, msg); } while (0)
eh that was a bad example as i dont want to type that all out in asm ;]
corex
so #define is called a macro and not a directive in c ?
_sin
no, its a macro
it may be called a directive somewhere as well
but ive never heard it called that
BoR0
corex: its the preprocessor thing
_sin
when you compile a c program
BoR0
as ike's macro, compare it with #IF and #ELSEIF
_sin
the preprocessor is first run over it
« prev 1 2 next »