char * trouble??

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
carbonBased

RE:char * trouble??

Post by carbonBased »

Aside from a (minor) problem with your descriptors, I can't think of anything offhand ('course, I haven't slept in days...)... what do your descriptors look like?  ie, the actual bytes...

Cheers,
Jeff
nicky_girl

RE:char * trouble??

Post by nicky_girl »

gdt: dw 0
     dw 0
     db 0
     db 0
     db 0
     db 0
;Linear data segment
LINEAR_SEL equ $-gdt
     dw 0xFFFF
     dw 0
     db 0
     db 0x92
     db 0xCF
     db 0
;code segment descriptor
SYS_CODE_SEL equ $-gdt
gdt1: dw 0xFFFF
      dw 0
      db 0
      db 0x9A
      db 0xCF
      db 0
;data segment descriptor
gdt2: dw 0xFFFF
      dw 0
      db 0
      db 0x92
      db 0xCF
      db 0

That's about it, this is the same code that is found in Alex F.'s pmode
tutorials.  And I use the method he uses to set the bases of each
descriptor by placing the value of the current code segment (I think that's
what it does!) in the base field.  However his code [ORG 0] and mine
[ORG 0x7c00] so I think setting the bases might be superflous, but, hell I
don't know what I'm doing ;)  All I know is when I read the bochs's output
file it has every segment loaded with a selector with a base of 0 and a limit
of fffff, except that the CS is loaded with the code segment.

I was curious that even though I've set SS, I have never set the value of ESP
and I didn't know if that was important.  Also if I needed local stack space for
assembly functions.  I wouldn't think so because the function works fine if an
actual character is passed to it.  But who knows.....Thanks once again everyone.
Carbon get some sleep!  ;)

Thanx,
Nicole
carbonBased

RE:char * trouble??

Post by carbonBased »

Hmm... that is truely bizarre... I don't know what to say.  You're descriptors are fine... and yes, you're right, there's no need to adjust the base of them.  If you're running with an org of 0x7c00, then the real mode base = pmode base = 0x0

You definitly should set esp, though.  Who knows where your return pointers are being pushed each time you make a call?  I usually set it to a 4kb block in the BSS, however, for simplicity, you could even just set it to 0x90000, or some place you know isn't currently used.  That prob'ly won't fix your problem... but... might fix others in the future :)

Cheers,
Jeff

Oh, and yeah... one of these days I'll get some sleep, I promise :)
Post Reply