I'm reverse-engineering some code I wrote in the middle-90s for which the source is long-lost and I'm a bit baffled by some VGA code I've encountered. I think it's probably from library or 3rd party code as I was just learning computers then and, while I did include some assembly to interact with VGA, it wasn't this informed.
If it's helpful, the app is a 16-bit DOS real-mode exe and the original source was compiled by the Turbo Pascal compiler (either version 6 or 7).
; function boilerplate push bp mov bp,sp call 0EE2:0530 ; stack bounds check function ; probe vga port 03CCh sub sp,0002 ; why? mov dx,03CC in al,dx and al,0C ; mask bits 3 & 2 cmp al,04 ; al == 00000100b mov al,00 ; pre return value jne jump_label ; return 0 inc ax ; return 1 jump_label: ; store return value in [bp-01] as well, for.. reasons. mov [bp-01],al mov al,[bp-01] ; function boilerplate mov sp,bp pop bp retf 0004 ; instance pointer?
So the question is, what is the intent here? Two parts are confusing to me:
First, bits 2 and 3 denote clock select according to the VGA docs I've read, but those docs are light on information about what that means when bit 3 is involved. For example, http://www.osdever.net/FreeVGA/vga/extreg.htm#3CCR3C2W declares the two values with the bit 3 set as undefined.
This function seems to return 0 when bit 3 is set and bit 2 isn't. But, why? What is it trying to determine about the hardware?
Second, and this is an aside, but what is the intent of
mov [bp-01],al followed by
mov al,[bp-01]? This seems redundant!