@# Quotes DB     useful, funny, interesting





Google
 
Web www.quotesdb.info
Undernet  |  EFnet  |  Quakenet  |  Freenode  |  Dalnet  |  Ircnet  |  Galaxynet
Page: 1 2 3



Comments:

<0> why my toy boot loader worked with just 'org 0x7c00' after removing lines that set ds to ZERO??? Doesn't look like ds=0 really needed after all?!?!
<1> possibly your bios sets ds to 0 already.
<1> it's BAD to depend on it. other bioses can do it other way. DON'T do it.
<0> mwk: ok
<0> what is required to be set before can switch to protect mode?
<0> looks like something called lgdt is required to be set?
<2> nothing need to be set before entering to pm
<0> edcba: entering pm is as easy as putting a 1 in cr0...i don't see why boot loaders don't escape real mode as fast as possible
<2> because then you need to load data from disks
<0> edcba: so do it in pm!
<2> do you know how to do it ?
<0> edcba: i found real mode interrupt code....does it translate over into pm easily?
<2> not at all
<0> edcba: wow, i didn't know that....OH WAIT!!! All the bios code is real mode...that's why right?
<2> yes
<3> Realmode interrupt code?



<0> edcba: AHA! ok makes sense
<0> _mikem: real mode bios interrupt handler
<3> What do you mean Real Mode Interupt code?
<3> Oh
<3> I thought it was a code that could switch the computer to real mode
<2> maybe it could work if you set a 40h selector but it would be a really ugly hack
<3> You mean setting your computer to real mode in a userspace app is posible?
<2> we were talking about bootloading
<3> Oh
<4> hello
<4> anyone can tell me if there is any ***embler that has some high level macros like if/else and structs?
<5> ktne: a C compiler ;)
<4> oggis__ :)
<4> i have to write quite a lot of code and such macros would be really handy
<4> something like: if eax==0 then inc eax else dec eax :)
<6> Can someone explain what a segment is exactly, Im a bit confused when somthing like mov dx, OFFSET firststring?
<6> ..is done
<4> hi
<6> hello
<4> ok first thing you have to understand is that segments originate on 16bit machines
<4> with a 16bit cpu you have a maximum of 2^16 values in a register
<4> this means that you can store a number from 0 to 65535 in dx for example
<4> now if you use this as an index in memory this would mean that the mrmory can have a maximum of 64kb addressable bytes (65536 bytes)
<4> do you get it so far?
<6> yeh
<4> so.. back in the day all 16bit cpus were limited to 64Kb of ram, just as today 32bit computers are limited to 4gb of ram
<4> (this is why you see all this amd64 craze right now)
<4> but when intel investigated options to expand this limit concluded that a full 32bit processor would be too expensive
<1> *cough* m68k *cough*
<4> mwk m68k is 32bit :)
<1> that's what i'm saying.
<4> so intel decided to make a 16bit and a half processor of sort.. :)
<4> basically they added the concept of segments where each segment is 16bytes long
<1> 16bit and one quarter, actually.
<6> lol mwk
<4> mwk :)
<4> so each segment is 16bytes long and memory access is done using the old 16bit method to which a 16*default_segment offset is added
<1> they were 64kb long, they just started 16bytes apart
<4> so for example if you do some memory write, the default segment for this operation is DS so when you do mov address, dx
<4> a value of 16*content_of_DS is added to address and it forms the actual real address that is placed on the memory bus
<4> since DS is 16bit too this means max 65546segments, each of 16bytes, this means 1Mb maximum of addressable memory
<4> so this is how they cheated and avoided to create a full 32bit processor and created a zombie instead :)
<1> ktne: not 16 bytes long. 64kb long, just starting each 16 bytes in memory.... 16byte segments would be a HORROR. horror, i tell you.
<1> otoh... segments are horror anyway
<4> mwk yes you can say that too, 65536 segments each starting 16bytes away :)
<6> So what is "mov dx, offset firststring" doing exactly in terms of the whole segment thing (firststring is in the .data segment)?
<4> g-guest mov dx, offset firststring just loads a 16bit value in dx
<4> it loads the offset of firststring (offset relative to the start of firststring's segment)
<6> but how does it know where it stored?
<4> who?
<6> where "firststring" is
<4> well when you compile the ***embly file, the ***embler creates a list with the offset of each label/symbol (like firststring)
<4> and it replaces that in the executable driectly with a number
<4> so mov dx, offset firststring is replaced with something like mov dx, 24545
<6> ahhh ^^
<4> so the CPU doesn't need to know where firststring is
<6> I get it now ^^
<4> :))
<6> What happens when you dynamically add data into a segment, can you give it any number for later accesing or is aceess number tabled?
<1> i'm actually sure we confused poor guy enough with all this segment stuff that he doesn't really get it, but just thinks he does... oh well, that's intrinsic to segmentation, i guess...
<1> er, what?



<1> what do you mean by 'dynamically adding data into a segment'?
<4> g-guest when you dynamically allocate data from the OS the OS returns to you the address where that allocated data is
<6> I do get it mwk - its just reading these tutorial which go "code code" and they dont say oh yeh the complier is doing this bit behind the scene
<4> for example if you allocate 356 bytes at runtime from the OS, the OS will return segment and address of those bytes (that you can access next)
<4> or what exactly did you meant about dynamic data?
<6> well that hard for me to explain what i mean err :p
<4> you mean malloc()?
<4> have you coded in C?
<6> coded in C nah
<4> in what other language have you coded?
<6> Ruby
<4> hmm
<4> how do you create a new object in ruby?
<6> i learn CFM and php aswell
<4> using some sort of new operator?
<4> "new"
<6> yeh
<6> you define a cl*** /method then set that all up then obect1 = method.new
<4> ok when you call new, ruby calls the OS to alloc a block of certain size (the size required to store the object, the size is known by ruby), the OS looks for a free place in memory (and large enough place), marks that place as used now and returns the address of that place to ruby which in turn stores it in the variable
<6> I see, then you store that memory location for later accessing?
<4> when the object is collected, ruby runs the destructors and the call the OS with a call like "free_this_block(address)" where address is the address of the block that was previously allocated
<4> yes when you do something like car= new Car() //this is not ruby; the program will store the value returned by the OS in the car variable
<4> the object variable is the one that actually stores this address
<6> Ok i think I understand it all now thanks ^^
<4> ok :)
<4> actually as a more indepth information, ruby doesn't call the OS each time because OS calls are slow, instead it calls from time to time and allocs larger chunks which then are used to store the objects
<6> how does it collect large chunk is storing it requires a OS call?
<6> if storing*
<1> it does OS call.
<1> but rarely.
<1> say, if you allocate ~100 bytes per new() call each time
<1> it'll allocate 4000 bytes from OS per one shot
<1> and then divide up this portion and give it to you
<1> so that it still does OS calls, but 40 times more rarely.
<4> for exame if you start a loop to alloc 100 objects of 100bytes each, then ruby will alloc a large chunk (like 40000 byes) and use this through the loop, therefore avoiding 100 os calls
<4> mwk haha :) i've wrote this without actually looking what you wrote
<4> g-guest so it does call the OS just more rarely and with calls for bigger chunks
<6> I see - i thought in order to "store" a big chunk would mean youd have to call the OS to store like the small values in the registers
<6> to make a big chunk
<4> no, you use mov to store values in the data block after you allocated it
<6> and then dump it all out of the data block?
<4> what do you mean by "to make a big chunk"? the OS doesn't make chunks, it just keeps a list with all free memory chunks, then when you want to alloc one it looks for one large enough, the OS removes it from the free list and returns the address of the first byte in the chunk to the program
<7> sweet :)
<7> whats the purpose of lines like "test eax, eax" ???
<4> if the free chunk is larger than what you need the OS will create a small one in order to save that unnecesary memory and put it in the free list
<4> thi way the OS starts at boot time with one large big chunks that spans the entire memory
<1> ChrOnX: it tests eax register.
<7> for ?
<7> against ?
<4> then when you alloc from it, it chops it into smaller parts as required
<1> ChrOnX: 'test' instruction is like 'and' instruction. except it doesn't actually store the result anywhere.
<7> i understand that to be "test to see if eax = eax"
<1> ChrOnX: all it does is setting flags.
<1> ChrOnX: NO. it is NOT eax = eax.
<1> ChrOnX: test eax, eax sets flags to reflect the state of result of 'eax AND eax'
<4> g-guest have you read that?
<1> ChrOnX: which, effectively, is the same as simply eax.
<7> in this app i'm debugging it requires a string to be entered and if the string is equal to the set "p***word" it displays an admin msg or w/e
<1> ChrOnX: so, ZF will be set if eax is zero, SF will be set if it's negative, and so on.
<7> i need to jump to that admin part even if the string i give isn't the "p***word"
<6> yeh ktne i think i get it - i guess i just need to "do it" now really :p
<4> and if the eax register is 0 then after test eax,eax ZF is set to 1
<7> hmm
<7> so i'm looking for the cmp command ?
<7> er.. instruction ?
<1> yeh.
<4> ChrOnX test eax, eax can be used instead of cmp in order to speed up comparison by zero
<1> using test when you don't know what it is... well, it's good way to screw yourself
<7> heh
<1> speewhat? both are one-cycle.
<7> i've always semi-wanted to learn asm
<7> but C++ owns asm
<7> ^.^
<4> mwk are you sure? or was it always that? (both 1 cycle)


Name:

Comments:

Please enter the result of the sum 63 + 46 (to avoid spam):






Return to #asm
or
Go to some related logs:

#xorg
#xine
#perl
bonbonthejon
#perl
#math
#linux
nvidia setting tty resolution ubuntu
#linux
rescheduling sector fedora boot



Home  |  disclaimer  |  contact  |  submit quotes