The boot loader that I'm designing is just simply going to setup (A) Stack, (B) Segment registers (C) Load remainder of track for specified device. Conventionally, this could have been up to 4 floppy and/or fixed disk devices, but now, it may be an FDC, but most likely USB or fixed disk. As my boot sector does have an 85 byte BPB, that leaves me with 422 bytes to work with. This code is fairly weighty (105 bytes), but in return of its 8160 possibilities, it can display all the detail I need.
INT 0x13 can return a possible 16 errors, so I came up with this color/character scheme that will provide me with all the details and not comprise to much space in boot sector. As an example, we want an error code to look like this.
Error codes are passed in EAX as a combination of two characters with attributes
mov eax, 0x07ce41cd call Err jz GoBackTo
The high order word is the center character and low order the outside two. Therefore 07 = Grey on Black, 0xCE is double line cross, 0x41 = Blue on Red and 0xCD = Double horizontal bars.
Prompting string can be constructed in any fashion required, but the only thing that must be is 0xFF where the error code will be inserted.
Prompt: db ' Error [' db -1 ; Position of error indicator db '] (A)bort (R)etry (I)gnore' db 0
; ENTER: EAX = Two combinations of attribute & character. ; LEAVE: AL = 'N' or 'R' ; EBX, ECX, EDX modified ; FLAGS: ZF = Retry otherwise NZ to Ignore.
Err: push ds push di push si push es push cs pop ds ; DS might be right push eax mov si, Prompt ; DS:SI now points to prompt mov ax, 0xb800 mov es, ax ; Point to base of page 0 ; Calcuate offset in page 0 where error prompting should begin. xor bh, bh ; BH = Page mov ah, GetCurPos int VIDEO xor ax, ax mov cx, ax mov cl, 160 ; Chars & Attribue / line mov al, dh and dx, 255 shl dx, 1 mov di, dx xor dl, dl ; DX needs to be null for IMUL to work imul cx ; Calculate offset add di, ax ; DI = offset in page 0 ; Initial prompting including closing bracket will be in this attribute. mov ah, 14 ; BIOS color for bright yellow mov si, Prompt ; Write everything up and including opening bracket lodsb or al, al js $ + 5 stosw jmp $ - 6 ; Write 3 character error indicate mov cx, ax ; Preserve attribute pop eax stosd stosw ; Write closing bracket now mov ax, cx ; Retrieve previous attribute lodsb stosw ; Change attribute to bright white and display remainder of string ; terminated by NULL. mov ah, 15 ; Attribute .L0: lodsb ; Read next character test al, 255 jz .Done stosw ; Write char & attr to video memory. jmp .L0 ; Wait for response from operator and convert to uppercase .Done: xor ax, ax int KEYBOARD and al, 0x5f ; Converts to uppercase. cmp al, 'A' jnz $ + 4 int ReBoot cmp al, 'R' jz .Exit ; Return with ZF set cmp al, 'I' jnz .Done inc al ; Clears ZF .Exit: pop es pop si pop di pop ds ret
I haven't completely formulated how I want codes to look for disk errors, but essentially center character will reflect colors corresponding to code and outside will be blue for removable devices and bright blue for fixed assuming DL was either 00 or 0x80.
NOTE I do code a lot of hard conditionals and branches
jmp $+?? to avoid a lot of unnecessary symbols in object files. Would be nice if NASM had something similar to MASM & FASM like