flat assembler
Message board for the users of flat assembler.

flat assembler > OS Construction > A20 enabling issues

Author
Thread Post new topic Reply to topic
neonz



Joined: 02 Aug 2003
Posts: 62
Location: Latvia
DOS version of FASM uses following code to test is A20 line enabled:

Code:
test_a20:
        mov     al, [0]                 ; get byte from 0:0
        mov     ah, al                  ; preserve old byte
        not     al                      ; modify byte
        xchg    al, [100000h]           ; put modified byte to 0FFFFh:10h
        cmp     ah, [0]                 ; set zero if byte at 0:0 not modified
        mov     [100000h], al           ; restore byte at 0FFFFh:10h
        ret                             ; return, zero if A20 enabled
    


Unfortunatelly, it seems that this code is hanging under Bochs (at least 1.2.pre1).

Is there other ways to check that A20 line is enabled without using BIOS (Int15h/AX=2402h), which is not possible on all machines?

I'm currently using following code to enable A20, but I would feel safer if I could check that A20 is really on:

Code:
; Enable A20 gate
    mov     ax, 2402h               ; Int15/2402h: query A20 status
 int     15h
 jc      .manualEnableA20
    or      al, al
      jnz     .A20On
      mov     ax, 2401h               ; Int15h/2401h: enable A20 gate
 int     15h
 mov     ax, 2402h               ; Int15h/2402h: query A20 status
        int     15h
 or      al, al
      jnz     .A20On

.manualEnableA20:
 call    empty_8042              ; Classic PC/AT A20 enable
  mov     al, 0D1h
    out     64h, al
     call    empty_8042
  mov     al, 0DFh
    out     64h, al
     call    empty_8042
  
    in      al, 92h                 ; Fast A20 enable
   test    al, 02h                 
    jnz     .A20On
      or      al, 02h
     out     92h, al
     
.A20On:

...


empty_8042:
        xor     cx, cx
.loop:
        in      al, 64h                 ; read 8042 status
        test    al, 2                   ; buffer full?
        loopnz  .loop                   ; if yes, loop
        ret

    
Post 17 Apr 2004, 10:18
View user's profile Send private message Visit poster's website Reply with quote
asmdemon



Joined: 18 Jan 2004
Posts: 97
Location: Virginia Beach, VA
look at the menuetos source code, it enables a20 using only in/out to ports
Post 17 Apr 2004, 16:54
View user's profile Send private message Visit poster's website Reply with quote
Gomer73



Joined: 29 Nov 2003
Posts: 151
The fasm code already assumes you are in flat real mode which is what probably messes up bochs.

What you could do is change the code so that whereever it access the 10000h you would access it as [es:10h] where the value of es is 0xffff
Post 18 Apr 2004, 19:39
View user's profile Send private message Reply with quote
neonz



Joined: 02 Aug 2003
Posts: 62
Location: Latvia
Gomer73 wrote:
The fasm code already assumes you are in flat real mode which is what probably messes up bochs.

What you could do is change the code so that whereever it access the 10000h you would access it as [es:10h] where the value of es is 0xffff


thanks, it helped.
Post 24 Apr 2004, 16:24
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2019, Tomasz Grysztar.

Powered by rwasa.