Page 2 of 3
Posted: Tue Mar 25, 2008 4:44 pm
by Pyrofan1
Okay, so i rewrote my entire Tasking code with the suggestions you made, but it just freezes.
i've attached my code
Posted: Tue Mar 25, 2008 5:20 pm
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)
Posted: Wed Mar 26, 2008 4:23 pm
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
But GAS chokes on it with Error: suffix or operands invalid for `out'
And unless i'm mistaken that is proper syntax.
Posted: Wed Mar 26, 2008 4:37 pm
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.
Posted: Wed Mar 26, 2008 4:43 pm
by Pyrofan1
Posted: Wed Mar 26, 2008 5:57 pm
by t0xic
try putting 0x20 into both al and dx. and doing 'out dx, al'
Posted: Wed Mar 26, 2008 6:06 pm
by Pyrofan1
that didn't work either
Posted: Wed Mar 26, 2008 6:40 pm
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.
Posted: Wed Mar 26, 2008 7:57 pm
by t0xic
or just link in nasm files
Posted: Thu Mar 27, 2008 7:31 am
by Brynet-Inc
Simple:
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:
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.
Posted: Thu Mar 27, 2008 9:13 am
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.
Posted: Thu Mar 27, 2008 9:26 am
by Brynet-Inc
Combuster wrote:You're starting a holy war here. Many people are more comfortable with dst = src over src = dst notation.
Alright alright.. apologies.
Posted: Thu Mar 27, 2008 2:04 pm
by bewing
Heh. I was just kidding.
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.
Posted: Thu Mar 27, 2008 3:17 pm
by Brynet-Inc
bewing wrote:Heh. I was just kidding.
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
Posted: Thu Mar 27, 2008 3:24 pm
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.
and
Are valid syntax, producing the same object code..