flat assembler
Message board for the users of flat assembler.

Index > DOS > A20 line controlling

Author
Thread Post new topic Reply to topic
avcaballero



Joined: 02 Feb 2004
Posts: 203
Location: Madrid - Spain
avcaballero 09 Jul 2006, 09:19
Hello, I've tried to modify and read A20 line status, but next code seems incapable to do it. I've changed this code using 92h port (A20 Fast Gate) and goes perfectly. Anyone has an idea for what it doesn't work?. I'm sorry for my spanish comments around the code, I can translate them if it can be useful. Thank you in advance.


; ----------------------------------------------------------------------------
; - TITULO : Activa la línea A20 vía controladora teclado COM-FASM -
; ----- -----
; - AUTOR : Alfonso Víctor Caballero Hurtado -
; ----- -----
; - VERSION : 1.0 -
; ----------------------------------------------------------------------------

COM8042 EQU 64h
DAT8042 EQU 60h
Accion EQU 0DFh ; 0DFh para activar linea A20
; 0DDh para desactivar línea A20
use16 ; usa codigo de 16 bits
ORG 100h ; ES tipo COM
CALL CambiA20
JC $_Fallo
CALL EstadoA20
JC $_Fallo
MOV DX, A20MSG1 ; Suponemos A20 activa
JNZ $_Fin ; si lo está, saltamos a imprimirlo
MOV DX, A20MSG2 ; Mensaje A20 no activa
JMP $_Fin
$_Fallo:
MOV DX, A20MSG3
$_Fin:
MOV AH, 9
INT 21h
MOV AX, 4C00h ; Servicio 4Ch, mensaje 0
INT 21h ; volvemos AL DOS

CambiA20:
; Propósito: Modifica el estado de la línea A20
; entrada : Ninguna
; salida : ZF = 1 activa, ZF = 0 no activa
; STC: hubo fallo, CLC: todo bien
; Destruye : AX
CLI ; Desactiva interrupciones
CALL Bufer8042 ; ¿Búfer entrada 8042 vacío?
JNZ $_FalloC ; salimos si no lo está
MOV AL, 0D1h ; orden de escritura al puerto
OUT COM8042, AL ; Enviar el comando al 8042
CALL Bufer8042 ; ¿Búfer entrada 8042 vacío?
JNZ $_FalloC ; salimos si no lo está
MOV AL, Accion ; Activamos/Desactivamos línea A20
OUT DAT8042, AL
CALL Bufer8042 ; ¿Búfer entrada 8042 vacío?
STI ; Restauramos interrupciones
CLC ; Todo bien
JMP $_FinC
$_FalloC:
STC
$_FinC:
RET

EstadoA20:
; Propósito: Lee el estado de la línea A20
; entrada : Ninguna
; salida : ZF = 1 activa, ZF = 0 no activa
; STC: hubo fallo, CLC: todo bien
; Destruye : AX
CLI ; Desactiva interrupciones
CALL Bufer8042 ; ¿Búfer entrada 8042 vacío?
JNZ $_FalloV ; salimos si no lo está
MOV AL, 0D0h ; si lo está, escribe puerto salida
OUT COM8042, AL ; Enviar el comando al 8042
CALL Bufer8042 ; ¿Búfer entrada 8042 vacío?
JNZ $_FalloV ; salimos si no lo está
IN AL, DAT8042
CALL Bufer8042 ; ¿Búfer entrada 8042 vacío?
STI ; Restauramos interrupciones
AND AL, 2
CLC ; Todo bien
JMP $_FinV
$_FalloV:
STC
$_FinV:
RET

Bufer8042:
; Propósito: Nos aseguramos de que el búfer de entrada del 8042 está vacío
; entrada : Ninguna
; salida : ZF = 1 si AL = 0, ZF = 0 si AL <> 0
; Destruye : AX, CX
PUSH AX
XOR CX, CX ; Esperamos 65536 ciclos
$_BuclEspera:
IN AL, COM8042 ; Lee el estado del 8042
AND AL, 02 ; Comprueba búfer entrada lleno
LOOPNZ $_BuclEspera ; Sale si CX = 0 ó AL = 0
POP AX
RET

A20MSG1 DB "Linea A20 activa$"
A20MSG2 DB "Linea A20 no activa$"
A20MSG3 DB "El buffer del teclado no esta vacio$"

; Salida por pantalla:
; C:\Trabajo\AOE\Codigos\Cap12>A20CF1
; Linea A20 no activa
Post 09 Jul 2006, 09:19
View user's profile Send private message Visit poster's website Reply with quote
zhak



Joined: 12 Apr 2005
Posts: 501
Location: Belarus
zhak 12 Jul 2006, 08:16
I took a glance at your code... it's too complicated, I think.
And numerous calls and jumps make it much sloooowly
I'm giving you my code. try to analize it and maybe you'll find your error.
(i tested it only on my system, yet. tell me about any problems)
Code:
enable_a20:
    mov si, 0500h
    in al, 92h
    or al, 2
    and al, 0FEh
    out 92h, al
    mov byte [si], 0
    push ds
    mov ax, 0FFFFh
    mov ds, ax
    mov [si+10], al
    pop ds
    cmp byte [si], al
    jnz .ret
  @@:
    in al, 64h
    test al, 2
    jnz @b
    mov al, 0D0h
    out 64h, al
  @@:
    in al, 64h
    test al, 1
    jnz @b
    in al, 60h
    mov dl, al
  @@:
    in al, 64h
    test al, 2
    jnz @b
    mov al, 0D1h
    out 64h, al
  @@:
    in al, 64h
    test al, 2
    jnz @b
    mov al, dl
    or al, 2
    out 60h, al
  @@:
    in al, 64h
    test al, 2
    jnz @b
    mov byte [si], 0
    push ds
    mov ax, 0FFFFh
    mov ds, ax
    mov [si+10], al
    pop ds
    cmp [si], al
  .ret:
    ret         ; ZF = 0 if successful    

it writes to memory to check if Gate A20 was enabled successfully.
Post 12 Jul 2006, 08:16
View user's profile Send private message Reply with quote
avcaballero



Joined: 02 Feb 2004
Posts: 203
Location: Madrid - Spain
avcaballero 13 Jul 2006, 19:34
Hello, zhak

Thank you for your response, I'm sorry not to answer earlier...

I took a glance at your code too and I believe that your code basically uses 92h port, I'm afraid that never uses 64h and 60h ports. As I've said, 92h port works fine, not as 64h and 60h.

Afterwards I'll read more carefully your code.

Cheers
Post 13 Jul 2006, 19:34
View user's profile Send private message Visit poster's website Reply with quote
avcaballero



Joined: 02 Feb 2004
Posts: 203
Location: Madrid - Spain
avcaballero 14 Jul 2006, 20:25
Hi again

I've debugged your code and, effectively jumps in first "jnz .ret". Anyway, why not use next code?
Code:
FastGate   EQU     92h
Accion     EQU     0DFh                   ; 0DFh to activate A20 line
                                          ; 0DDh to deactivate A20 line
use16                                     ; usa codigo de 16 bits
ORG       100h
; change A20 line status
CLI
MOV       AL, Accion
OUT       FastGate, AL
; verify A20 line status
IN        AL, FastGate
STI
AND       AL, 2
MOV       DX, A20MSG1                     ; Suppose A20 active
JNZ       $_Fin                           ;   if it is, jump to print it
MOV       DX, A20MSG2                     ;   if it isn't, print no active
$_Fin:
MOV       AH, 9
INT       21h
MOV       AX, 4C00h
INT       21h

A20MSG1   DB "A20 line active$"
A20MSG2   DB "A20 line no active$"

    
Post 14 Jul 2006, 20:25
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.