; bootreg.asm stand alone program for floppy boot sector ; prints registers and writes to printer ; Compiled using nasm -f bin -o bootreg.bin bootreg.asm ; Written to floppy with dd if=bootreg.bin of=/dev/fd0 org 7C00h ; Boot record is loaded at 0000:7C00 lea sp,[stack] ; my local stack lea si,[head] ; string to display call prints ; display a zero terminated string ; print register values lea di,[spout+4] ; destination bytes (in ram) mov dx,sp ; register to dump into dx call printr ; convert register value to hex lea si,[spout] call prints lea di,[bpout+4] ; bp base pointer mov dx,bp call printr lea si,[bpout] call prints lea di,[csout+4] ; cs code segment mov dx,cs call printr lea si,[csout] call prints lea di,[dsout+4] ; ds data segment mov dx,ds call printr lea si,[dsout] call prints lea di,[ssout+4] ; ss mov dx,ss call printr lea si,[ssout] call prints ; write to printer (added FF, form feed, to 'head') lea si,[head] ; print to printer (should be call) prwait: mov ax,0 mov ah,2 ; read printer status mov dx,0 ; lpt 0 int 17h ; ask for printer status, in 'ah' and ah,0F0h cmp ah,090h ; test printer on line and ready jne prwait mov ax,0 ; zero ah for int 17h mov al,[si] ; get next character cmp al,0 je prfin ; zero byte ends inc si mov dx,0 ; lpt 0 (hopefully) int 17h ; print a character jmp prwait ; loop prfin: done: lea si,[reboot] call prints ; wait for 'any key': mov ah,0 int 16h ; waits for key press ; AL is ASCII code or zero ; AH is keyboard code ; store magic value at 0040h:0072h to reboot: ; 0000h - cold boot. ; 1234h - warm boot. mov ax,0040h mov ds,ax mov word[0072h],0000h ; cold boot. jmp 0FFFFh:0000h ; reboot! prints: ; 'si' comes in with string address mov bx,0 ; write to display mov ah,0Eh ; screen function prs: mov al,[si] ; get next character cmp al,0 ; look for terminator je finpr ; zero byte at end of string int 10h ; write character to screen. inc si ; move to next character jmp prs ; loop finpr: ret ; finished this line printr: ; 'dx' has register ; 'di' has destination mov cx,4 ; print 4 hex characters sp4: mov ax,0 ; zero ax shld ax,dx,4 ; get next 4 bits into ax shl dx,4 ; have to move dx also add al,48 ; change 4 bits to hex character cmp al,57 jle spok add al,7 ; make A to F spok: mov byte [di],al ; save for printing inc di loop sp4 ; printed 4 hex bytes ret head: db "boot.asm hex dump of disk sectors",13,10 db "ADDR 0 1 2 3 4 5 6 7 8 9 A B C D E F " db "ascii",13,10,12,0 reboot: db "press any key to reboot",13,10,0 spout: db "sp= hhhh",13,10,0 bpout: db "bp= hhhh",13,10,0 csout: db "cs= hhhh",13,10,0 dsout: db "ds= hhhh",13,10,0 ssout: db "ss= hhhh",13,10,0 dd 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ; backwards part of stack stack: dd 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ; end boot