//----------------------------------------------------------------- // showcr4.s // // This real-mode boot-time program will display the 32-bit // value in the x86 register known as Control Register CR4. // // to assemble: $ as showcr4.s -o showcr4.o // and to link: $ ld showcr4.o -T ldscript -o showcr4.b // and install: $ dd if=showcr4.b of=/dev/sda4 seek=1 // // NOTE: This code begins executing with CS:IP = 1000:0002. // // programmer: ALLAN CRUSE // written on: 18 DEC 2008 //----------------------------------------------------------------- .section .text #------------------------------------------------------------------ .word 0xABCD #------------------------------------------------------------------ main: .code16 mov %sp, %cs:ipltos+0 mov %ss, %cs:ipltos+2 # setup segment-registers to address our program-arena mov %cs, %ax mov %ax, %ds mov %ax, %es mov %ax, %ss lea tos, %sp # read the current value in register CR4 mov %cr4, %eax # format the register-value for display lea buf, %di call eax2hex # invoke ROM-BIOS services to display our message mov $0x0F, %ah int $0x10 mov $0x03, %ah int $0x10 lea msg, %bp mov len, %cx mov att, %bl mov $0x1301, %ax int $0x10 lss %cs:ipltos, %sp lret #------------------------------------------------------------------ ipltos: .word 0, 0 #------------------------------------------------------------------ #------------------------------------------------------------------ msg: .ascii "\r\n CR4=" buf: .ascii "xxxxxxxx \r\n\n" len: .short . - msg att: .byte 0x1F hex: .ascii "0123456789ABCDEF" #------------------------------------------------------------------ eax2hex: # converts value in EAX to a hexadecimal string at DS:DI pushal mov $8, %cx nxnyb: rol $4, %eax mov %al, %bl and $0x0F, %bx mov hex(%bx), %dl mov %dl, (%di) inc %di loop nxnyb popal ret #------------------------------------------------------------------ .align 16 .space 256 tos: #------------------------------------------------------------------ .end