section .data msg1 db 10,"LDTR: " msg1_len equ $-msg1 msg2 db 10,"IDTR: " msg2_len equ $-msg2 msg3 db 10,"GDTR: " msg3_len equ $-msg3 msg4 db 10,"MSW: " msg4_len equ $-msg4 msg5 db 10,"TR: " msg5_len equ $-msg5 pos db 10,"Protected mode on" pos_len equ $-pos pos2 db 10,"Protected mode off" pos2_len equ $-pos2 section .bss IDTR resw 3 GDTR resw 3 LDTR resw 1 MSW resw 1 TR resw 1 charans resb 16 %macro print 2 mov rax,1 mov rdi,1 mov rsi,%1 mov rdx,%2 syscall %endmacro %macro exit 0 mov rax,60 mov rdi,0 syscall %endmacro section .text global _start _start: SMSW [MSW] SIDT [IDTR] SLDT [LDTR] SGDT [GDTR] STR [TR] print msg3,msg3_len mov ax,[GDTR+4] call display mov ax,[GDTR+2] call display mov ax,[GDTR] call display print msg2,msg2_len mov ax,[IDTR+4] call display mov ax,[IDTR+2] call display mov ax,[IDTR] call display print msg1,msg1_len mov ax,[LDTR] call display print msg4,msg4_len mov ax,[MSW] call display print msg5,msg5_len mov ax,[TR] call display SMSW [MSW] mov ax, [MSW] shr ax,1 jc onMode onMode: print pos,pos_len jmp end print pos2,pos2_len end : exit display: mov rbx,16 mov rcx,16 mov rsi,charans+15 cnt: mov rdx,0 div rbx cmp dl,09h jbe add30 add dl,07h add30: add dl,30h mov [rsi],dl dec rsi dec rcx jnz cnt print charans,16 ret
To embed this project on your website, copy the following code and paste it into your website's HTML: