Page 1 of 1
asm problems [FIXED]
Posted: Tue Feb 20, 2007 12:31 pm
by GLneo
hi all, why does
Code: Select all
EXTERN bss
EXTERN bsslength
mov edi, bss
mov ecx, bsslength
xor eax, eax
rep stosd
( should clear bss ) crashes my kernel, when "rep stosd" is run my kernel breaks, with out it it boots but i don't think the bss is cleared. this above code works on qemu but not on bochs or a real pc, anyone know why?
my link script is here:
http://lemonos.cvs.sourceforge.net/lemo ... iew=markup
( it's where bss and bsslength are defined )
o and bochs says this:
Code: Select all
00004441948i[CPU ] write_virtual_checks(): write beyond limit, r/w
thx
Posted: Tue Feb 20, 2007 2:02 pm
by os64dev
did you print the values of bss and bsslength this to verify the correctness of the values. I had a similar problem that the divide didn't work so i manuallly did the divide in code and worked perfectly. also make sure that the direction is ok cld statement and the ds or es is properly setup.
Posted: Tue Feb 20, 2007 3:07 pm
by proxy
could be be because length is in bytes and your are storing dwords...thus you are clearing 4 times the amount of data as needed.
just add a "shr ecx, 2" before the rep movsd (effectively divides by 4) and i think you will be fine.
**EDIT: scratch that, your length is in dwords, dunno what's wrong
**EDIT2: perhaps you need a "cld" to make sure addresses are incrementing and not decrementing?
proxy
Posted: Tue Feb 20, 2007 3:23 pm
by Candy
If bsslength + base of segment > limit then you get an error. Since you have the same item...
Is this in rmode, pmode or lmode?
As said before, it could be the direction bit but I doubt it since I think bochs cleans it as well...
Posted: Tue Feb 20, 2007 4:16 pm
by Combuster
Do you have paging setup properly and enabled? otherwise you'll be clearing miles beyond end of memory at 0xC01xxxxx ...
Posted: Tue Feb 20, 2007 4:49 pm
by GLneo
ok, i set e,f,g(s):
Code: Select all
mov ax, 10h
mov ds, ax
mov ss, ax
mov es, ax ; added
mov fs, ax ; added
mov gs, ax ; added
now it boots... but i still have other problems, i'll report them if i cant figure them out
thx all!
p.s. what is this: "cld" ?
Posted: Tue Feb 20, 2007 10:09 pm
by m
CLD:Clear the direction flag(DF) in the (E)FLAG.(i.e. Set Bit 10 to 0.)
If this flag is set,the SI and DI will be decremented when executing most of the string instructions(e.g. MOVS family,CMPS family,STOS and LODS family etc.).When the operands are 8-bit ones,they will be decremented by 1 at every loop,and 16-bit for 2,and 32-bit for 4,etc.,respectively.If the DF is cleared,they will be incremented with an appropriate value.
Posted: Wed Feb 21, 2007 10:26 am
by GLneo
O, thx!