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.
I think you are executing 16 bits code in a 32 bits code segment.
I tried to 'debug' your code, but because I didn't have time to setup a pm environment i did the following:
I created a bootsector starting your code. I compiled the code as 16 bits and everything went ok. Then, I compiled the code as 32 bits. I got the same kind of results you get when you are debugging in bochs. In your case however, you are executing in 16 bit code in 32 bit environment. The in al, 0x24 is actually a combination of the statements "in al, dx" and "and al, 0xc0".