PIC ICW3 explanation

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.
Post Reply
CeriseSky
Posts: 6
Joined: Sun Jun 15, 2025 10:54 am
Libera.chat IRC: Indigo

PIC ICW3 explanation

Post by CeriseSky »

I'm having trouble understanding this line on the wiki for the 8259 pic initialisation:
outb(PIC1_DATA, 4); // ICW3: tell Master PIC that there is a slave PIC at IRQ2 (0000 0100)
It say's that to tell the master pic that the slave is at irq2, you for some reason have to send 4 to it instead. The manual vaguely mentions a "PIC number" to send as icw3 which I assumed meant the irq number, i.e. 2 not 4. I've looked in the technical reference for the IBM AT and it doesn't mention anything that it's doing that could cause this and at this point I just have no idea what it could be
If I see one more magic number in wiki code then I'm going to lose it.
User avatar
JohnSwag
Posts: 1
Joined: Wed Apr 16, 2025 6:46 pm

Re: PIC ICW3 explanation

Post by JohnSwag »

8)
sandras
Member
Member
Posts: 155
Joined: Thu Nov 03, 2011 9:30 am

Re: PIC ICW3 explanation

Post by sandras »

I think each bit represents an IRQ line - 100b sets the second bit (counting from zero) to represent which IRQ line the PIC2 connects to.
CeriseSky
Posts: 6
Joined: Sun Jun 15, 2025 10:54 am
Libera.chat IRC: Indigo

Re: PIC ICW3 explanation

Post by CeriseSky »

sandras wrote: Wed Jul 09, 2025 3:22 pm I think each bit represents an IRQ line - 100b sets the second bit (counting from zero) to represent which IRQ line the PIC2 connects to.
Oh right that does make sense. Documentation was vague so I thought it meant the actual IRQ number
If I see one more magic number in wiki code then I'm going to lose it.
CeriseSky
Posts: 6
Joined: Sun Jun 15, 2025 10:54 am
Libera.chat IRC: Indigo

Re: PIC ICW3 explanation

Post by CeriseSky »

Given that I said that my struggle was with why the value was 4 and not 2 should tell you that I understand how to read binary numbers. I was looking for help about the information that the PIC was expecting due to finding the documentation difficult to read.
If I see one more magic number in wiki code then I'm going to lose it.
Post Reply