;//--------------------------------------------------------------- ;// regdump.s ;// ;// This is a boot-sector program that displays the contents ;// of the 8086 processor's registers in hexadecimal format. ;// ;// assemble with: $ as86 regdump.s -b regdump.b ;// install using: $ dd if=regdump.b of=/dev/fd0 ;// ;// programmer: ALLAN CRUSE ;// written on: 01 FEB 2004 ;//--------------------------------------------------------------- .SECT .TEXT ;----------------------------------------------------------------- start: ; save the original values found in the 8086 registers, ; by copying them to an unused memory-area at 0000:7E00 CSEG mov [0x7E00], ax ; preserve register AX CSEG mov [0x7E02], bx ; preserve register BX CSEG mov [0x7E04], cx ; preserve register CX CSEG mov [0x7E06], dx ; preserve register DX CSEG mov [0x7E08], sp ; preserve register SP CSEG mov [0x7E0A], bp ; preserve register BP CSEG mov [0x7E0C], si ; preserve register SI CSEG mov [0x7E0E], di ; preserve register DI CSEG mov [0x7E10], cs ; preserve register CS CSEG mov [0x7E12], ds ; preserve register DS CSEG mov [0x7E14], es ; preserve register ES CSEG mov [0x7E16], ss ; preserve register SS pushf ; transfer FLAGS value pop dx ; to register DX call ahead1 ; transfer register IP ahead1: pop ax ; to register AX sub ax, #ahead1 ; compensate for fetch CSEG mov [0x7E18], ax ; preserve original IP CSEG mov [0x7E1A], dx ; preserve FLAGS value ; now setup new SS:SP and CS:IP cli ; enter critical-section mov ax, cs ; address segment zero mov ss, ax ; with SS register mov sp, #0x7C00 ; setup safe stack-top sti ; leave critical-section jmpf #ahead2, #0x07C0 ; renormalize CS and IP ahead2: ; setup registers DS and ES to address our data mov ax, cs ; address this segment mov ds, ax ; with DS register mov es, ax ; also ES register ; main loop to display the saved register-values xor si, si ; initial array-index mov cx, #14 ; number of registers nxreg: mov ax, names[si] ; get register-name mov report+1, ax ; set register-name SSEG mov ax, 0x7E00[si] ; get register-value lea di, report+4 ; point to value-field call ax2hex ; convert AX to string call showreg ; display the register add si, #2 ; advance array-index loop nxreg ; show other registers ; wait for keypress by user, then reboot xor ah, ah ; await keyboard input int 0x16 ; request BIOS service int 0x19 ; perform system reboot ;----------------------------------------------------------------- names: .ASCII "AXBXCXDXSPBPSIDICSDSESSSIPFL" ; array of names report: .ASCII " rr=xxxx " ; buffer for message info digits: .ASCII "0123456789ABCDEF" ; hexadecimal digit-array ;----------------------------------------------------------------- ;----------------------------------------------------------------- ax2hex: ; converts contents of AX to hexadecimal string at DS:DI push ax ; save working registers push bx push cx push dx push di mov dx, ax ; copy AX value into DX lea bx, digits ; pointer to xlat-table mov cx, #4 ; four nybbles-per-word nxnyb: rol dx, #4 ; next nybble into DL mov al, dl ; copy the byte to AL and al, #0x0F ; isolate lowest nybble xlat ; convert binary to hex mov [di], al ; put numeral in buffer inc di ; and advance the index loop nxnyb ; process other nybbles pop di ; restore saved registers pop dx pop cx pop bx pop ax ret ; back to calling routine ;----------------------------------------------------------------- showreg: ; writes 'report' to screen at current cursor-location push ax ; save working registers push bx push cx push dx push bp mov ah, #0x0F ; display-page into BH int 0x10 ; request BIOS service mov ah, #0x03 ; cursor-locn to DH,DL int 0x10 ; request BIOS service lea bp, report ; point ES:BP to string mov cx, #10 ; string's length in CX mov bl, #0x0E ; display-colors in BL mov ax, #0x1301 ; write_string function int 0x10 ; request BIOS service pop bp ; restore saved registers pop dx pop cx pop bx pop ax ret ; back to calling routine ;----------------------------------------------------------------- .ORG 510 ; boot-signature's offset .BYTE 0x55, 0xAA ; value of boot-signature ;----------------------------------------------------------------- END