%macro scall 4
    mov rax,%1
    mov rdi,%2
    mov rsi,%3
    mov rdx,%4
    syscall
%endmacro
section .data
    protmsg: db "In Protected Mode"
    protmsg_len: equ $-protmsg
    realmsg: db "In Real Mode"
    realmsg_len: equ $-realmsg
    regmsg: db 0x0A,"Register Contents"
    regmsg_len: equ $-regmsg
    gmsg: db 0x0A,"Contents of GDTR:"
    gmsg_len: equ $-gmsg
    mmsg: db 0x0A,"Contents of MSW:"
    mmsg_len: equ $-mmsg
    imsg: db 0x0A,"Contents of IDTR:"
    imsg_len: equ $-imsg
    lmsg: db 0x0A,"Contents of LDTR:"
    lmsg_len: equ $-lmsg
    tmsg: db 0x0A,"Contents of TR:"
    tmsg_len: equ $-tmsg
    col db " : "
    col_len equ $-col
    cnt2: db 04H
    newline: db 0x0A 
section .bss
g:  resd 1
    resw 1
id: resd 1
    resw 1
ld: resd 1
tr: resd 1
msw: resd 1
value: resb 4

section .text
    global _start

_start:
    smsw [msw]
    mov eax,dword[msw]
    bt eax,0
    jc next
    scall 1,1,realmsg,realmsg_len
    jmp Exit
    next:
    scall 1,1,protmsg,protmsg_len
    scall 1,1,regmsg,regmsg_len
    scall 1,1,gmsg,gmsg_len
    SGDT [g]
    mov bx,word[g+4]
    call HtoA
    mov bx,word[g+2]
    call HtoA
    scall 1,1,col,col_len
    mov bx,word[g]
    call HtoA
    scall 1,1,newline,1
    sldt[ld]
    scall 1,1,lmsg,lmsg_len
    mov bx,word[ld]
    call HtoA
    scall 1,1,newline,1
    scall 1,1,imsg,imsg_len
    sidt[id]
    mov bx,word[id+4]
    call HtoA
    mov bx,word[id+2]
    call HtoA
    scall 1,1,col,col_len
    mov bx,word[id]
    call HtoA
    str[tr]
    scall 1,1,newline,1
    scall 1,1,tmsg,tmsg_len
    mov bx,word[tr]
    call HtoA
    scall 1,1,newline,1
    scall 1,1,mmsg,mmsg_len
    mov bx,word[msw+2]
    call HtoA
    mov bx,word[msw]
    call HtoA
    
Exit:
    mov rax, 60
    mov rdi, 0
    syscall
    
HtoA:
    mov rdi, value
    mov byte[cnt2],4H
aup:
    rol bx,04
    mov cl,bl
    and cl,0FH
    cmp cl,09H
    jbe anext
    add cl, 07H
anext:
    add cl,30H
    mov byte[rdi],cl
    inc rdi
    dec byte[cnt2]
    jnz aup
    scall 1,1,value,4
    ret

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: