Page 1 of 1
Testing the A20 in C
Posted: Sat Aug 24, 2013 2:15 am
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
Re: Testing the A20 in C
Posted: Sat Aug 24, 2013 3:04 am
by Combuster
Yes, it's possible. No, we do not spoonfeed code - that's your exercise.
Re: Testing the A20 in C
Posted: Sun Aug 25, 2013 2:53 am
by nbdd0121
volatile int test=0, *ptr=(int*)((int)&test+0x100000);
return *ptr==0&&(test=1)&&*ptr==1;
Re: Testing the A20 in C
Posted: Sun Aug 25, 2013 4:13 am
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.
Re: Testing the A20 in C
Posted: Sun Aug 25, 2013 5:15 am
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.
Re: Testing the A20 in C
Posted: Sun Aug 25, 2013 5:27 am
by Someone256
Thanks guys.