;//--------------------------------------------------------------- ;// bootmsw.s ;// ;// This is a very simple floppy diskette boot-sector program ;// which uses the unprivileged 'smsw' instruction, available ;// on 80286 (or higher) Intel processors, to verify that the ;// boot-loader is NOT being executed in 'Protected Mode' (it ;// shows current bit-settings from the 16-bit MSW register). ;// ;// assemble with: $ as86 bootmsw.s -b bootmsw.b ;// install using: $ dd if=bootmsw.b of=/dev/fd0 ;// ;// programmer: ALLAN CRUSE ;// written on: 20 JAN 2004 ;// revised on: 27 JAN 2004 -- to include the boot-signature ;//--------------------------------------------------------------- .SECT .TEXT ;----------------------------------------------------------------- start: jmpf #main, #0x07C0 ; renormalize CS and IP ;----------------------------------------------------------------- msg: .ASCII "\r\n MSW=" ; our messaage's legend buf: .ASCII "xxxxxxxxxxxxxxxx \r\n" ; our message's content len: .WORD * - msg ; length of our message ;----------------------------------------------------------------- main: ; setup segment-registers to address this segment's data mov ax, cs ; address this segment mov ds, ax ; with DS register mov es, ax ; also ES register ; format our message-string mov di, #buf ; point DS:DI to buffer smsw ax ; current MSW into AX mov cx, #16 ; count of register bits nxbit: mov dl, #0x30 ; numeral '0' into DL shl ax, #1 ; next bit to carry-flag adc dl, #0 ; adjust numeral in DL mov [di], dl ; write numeral to buffer inc di ; advance buffer index loop nxbit ; process remaining bits ; display our message-string mov ah, #0x0F ; get curent video-page int 0x10 ; request BIOS service mov ah, #0x03 ; get cursor's location int 0x10 ; request BIOS service lea bp, msg ; point ES:BP to string mov cx, len ; message-length in CX mov bl, #0x0A ; bright green on black mov ax, #0x1301 ; write_string to screen int 0x10 ; request BIOS service freeze: jmp freeze ; loop here until reset ;----------------------------------------------------------------- .ORG 510 ; boot-signature offset .BYTE 0x55, 0xAA ; and signature's value ;----------------------------------------------------------------- END