ALP to Check whether system is in Real or Protected mode (BY USING MACRO)


section .data
    msg1 db 10,'Processor is in Real Mode'
    len1 equ $-msg1

    msg2 db 10,'Processor is in Protected Mode'
    len2 equ $-msg2

%macro disp 2
    mov eax,04
    mov ebx,01
    mov ecx,%1
    mov edx,%2
    int 80h
%endmacro

section .text
    global _start
_start:   
    smsw eax    ;Reading CR0
    rcr eax,01
    ;bt eax,0    ;Checking PE bit(LSB), if 1=Protected Mode, else Real Mode
    jc x1
    disp msg1,len1
    jmp exit
x1:    disp msg2,len2

exit:    mov eax,01
    mov ebx,00
    int 80h
SHARE
    Blogger Comment
    Facebook Comment