Testing the A20 in C

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
Someone256
Posts: 7
Joined: Sun Jul 14, 2013 8:58 pm

Testing the A20 in C

Post by Someone256 »

Hello, I was wondering if there is any way to test the A20 in C, not assembly like in the Wiki. Could tell me on how do detect whether or not the A20 line/gate has been enabled?

Thanks
Last edited by Someone256 on Sat Aug 24, 2013 3:10 am, edited 1 time in total.
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:

Re: Testing the A20 in C

Post by Combuster »

Yes, it's possible. No, we do not spoonfeed code - that's your exercise.
"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 ]
nbdd0121
Member
Member
Posts: 60
Joined: Thu Jul 25, 2013 8:10 am

Re: Testing the A20 in C

Post by nbdd0121 »

volatile int test=0, *ptr=(int*)((int)&test+0x100000);
return *ptr==0&&(test=1)&&*ptr==1;
Last edited by nbdd0121 on Sun Aug 25, 2013 5:15 am, edited 1 time in total.
User avatar
bluemoon
Member
Member
Posts: 1761
Joined: Wed Dec 01, 2010 3:41 am
Location: Hong Kong

Re: Testing the A20 in C

Post by bluemoon »

nbdd0121 wrote:int test=0, *ptr=(int*)((int)&test+0x100000);
return *ptr==0&&(test=1)&&*ptr==1;
This may get false alarm if the compiler decided that test is irreverent and remove it, or reorder to test ptr before setting test=0.

A better way is to scan the memory map for usable region, and write proper code to ensure compiler don't get confused.
nbdd0121
Member
Member
Posts: 60
Joined: Thu Jul 25, 2013 8:10 am

Re: Testing the A20 in C

Post by nbdd0121 »

bluemoon wrote: This may get false alarm if the compiler decided that test is irreverent and remove it, or reorder to test ptr before setting test=0.

A better way is to scan the memory map for usable region, and write proper code to ensure compiler don't get confused.
I just modifies 'test' to be volatile. I didn't test the code, but I am quite sure if you set -O0 it works.
Someone256
Posts: 7
Joined: Sun Jul 14, 2013 8:58 pm

Re: Testing the A20 in C

Post by Someone256 »

Thanks guys.
Post Reply