Having some trouble with my multitasking system

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.
Pyrofan1
Member
Member
Posts: 234
Joined: Sun Apr 29, 2007 1:13 am

Post by Pyrofan1 »

Okay, so i rewrote my entire Tasking code with the suggestions you made, but it just freezes.
i've attached my code
Attachments
task.h
(3.09 KiB) Downloaded 62 times
User avatar
t0xic
Member
Member
Posts: 216
Joined: Sat May 05, 2007 3:16 pm
Location: VA
Contact:

Post by t0xic »

I would suggest writing the code in assembly. Theres still a lot you are missing. Re-read the links. Just use some assembly (not inline, as gcc chooses which registers to use).

Also, I know the string declaration is legal and not related to the problem, but it's always better to use a safe method anyways. (better safe than sorry)
Pyrofan1
Member
Member
Posts: 234
Joined: Sun Apr 29, 2007 1:13 am

Post by Pyrofan1 »

I think i have the problem nailed. The iret skips over the code that acknowledges the interrupt which explains why it freezes.
Now i've added this code

Code: Select all

out $0x20, $0x20
But GAS chokes on it with Error: suffix or operands invalid for `out'
And unless i'm mistaken that is proper syntax.
User avatar
bewing
Member
Member
Posts: 1401
Joined: Wed Feb 07, 2007 1:45 pm
Location: Eugene, OR, US

Post by bewing »

Ah, sorry, no.

Either the port number has to be in DX, or the value has to be in AL. You cannot use immediates for both values at the same time.
Pyrofan1
Member
Member
Posts: 234
Joined: Sun Apr 29, 2007 1:13 am

Post by Pyrofan1 »

this doesn't work either

Code: Select all

mov $0x20, %dx
out $0x20, %dx
User avatar
t0xic
Member
Member
Posts: 216
Joined: Sat May 05, 2007 3:16 pm
Location: VA
Contact:

Post by t0xic »

try putting 0x20 into both al and dx. and doing 'out dx, al'
Pyrofan1
Member
Member
Posts: 234
Joined: Sun Apr 29, 2007 1:13 am

Post by Pyrofan1 »

that didn't work either
User avatar
bewing
Member
Member
Posts: 1401
Joined: Wed Feb 07, 2007 1:45 pm
Location: Eugene, OR, US

Post by bewing »

The out instruction may not use proper AT&T syntax.

Try ALL of the following:

Code: Select all

mov $0x20, %al
out $0x20, %al

mov $0x20, %dx
out %dx, $0x20

mov $0x20, %al
out %al, $0x20
Oh, and don't you have to put out.b in stupid AT&T syntax? Does it default to byte size?

And then write a nasty email to the gcc people, and tell them to drop the stupid AT&T syntax, and switch to nice intel syntax. Or turn on the intel syntax asm flag in gcc.
User avatar
t0xic
Member
Member
Posts: 216
Joined: Sat May 05, 2007 3:16 pm
Location: VA
Contact:

Post by t0xic »

or just link in nasm files :?
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Post by Brynet-Inc »

Simple:

Code: Select all

movb <data>, %al
outb %al, $0x20
It's logical, mov "source" to "destination" - unlike the unappealing look of mov "dst" to "src".

bewing, stop attacking the syntax... it's pretty. ;)
Pyrofan1 wrote:

Code: Select all

out $0x20, $0x20
But GAS chokes on it with Error: suffix or operands invalid for `out'
And unless i'm mistaken that is proper syntax.
The out instruction doesn't support 2 immediate operands, regardless of the syntax.

If you use an immediate operand for the IO address, you'll have valid range of 0 to 0xff, otherwise, use the dx register.
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post by Combuster »

The key thing is that you need to suffix b/w/l on the out to make it work.
i.e. use outb, outw or outl (as Brynet-Inc did)
It's logical, mov "source" to "destination" - unlike the unappealing look of mov "dst" to "src".

bewing, stop attacking the syntax... it's pretty.
You're starting a holy war here. Many people are more comfortable with dst = src over src = dst notation.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Post by Brynet-Inc »

Combuster wrote:You're starting a holy war here. Many people are more comfortable with dst = src over src = dst notation.
8-[ Alright alright.. apologies.
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
User avatar
bewing
Member
Member
Posts: 1401
Joined: Wed Feb 07, 2007 1:45 pm
Location: Eugene, OR, US

Post by bewing »

Heh. I was just kidding. :wink:

And intel syntax is not dest = src, is is "register/address being modified, data". It is a small philosophical difference, that leads to a different paradigm. I just think that extraneous punctuation is the farthest thing from "pretty". And in this particular case (assuming -- as is reasonable -- that Combuster is right), it is precisely that extraneneous punctuation that caused Pyrofan1's code to fail. This is Not a Good Thing.
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Post by Brynet-Inc »

bewing wrote:Heh. I was just kidding. :wink:

And intel syntax is not dest = src, is is "register/address being modified, data". It is a small philosophical difference, that leads to a different paradigm. I just think that extraneous punctuation is the farthest thing from "pretty". And in this particular case (assuming -- as is reasonable -- that Combuster is right), it is precisely that extraneneous punctuation that caused Pyrofan1's code to fail. This is Not a Good Thing.
I meant from a visual perspective.

mov eax, 5 for example, could look very confusing to a beginner...

I guess now that I think about it more.. from the eyes of someone deeply intimate with the "mv" command, it's scary, but from a C programmer it's simply "var = 5".

I'll just shut up now... resist the urge to purge ;)
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Post by Brynet-Inc »

bewing wrote:.And in this particular case (assuming -- as is reasonable -- that Combuster is right), it is precisely that extraneneous punctuation that caused Pyrofan1's code to fail. This is Not a Good Thing.
Whoops, I missed this portion of your reply.. ;)

That's incorrect, I only included the suffixes for added clarity... habit.

Code: Select all

movb $0x20, %al
outb %al, $0x20
and

Code: Select all

mov $0x20, %al
out %al, $0x20
Are valid syntax, producing the same object code.. :roll:
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
Post Reply