[syslinux] Gcc 3.4.0 and syslinux-2.09 menu

H. Peter Anvin hpa at zytor.com
Tue Apr 27 10:47:41 PDT 2004

Murali Krishnan Ganapathy wrote:
> TenThumbs wrote:
>> I also noticed that getnumrows returns the contents of 0x484 which is
>> the number of rows minus one but menu.c has this
>>    ms->numcols = getnumcols();
>>    ms->numrows = getnumrows();
>>    ms->maxcol = ms->numcols - 1;
>>    ms->maxrow = ms->numrows - 1;
>> which makes maxrow = rows - 2. Is this intentional?
> According to the info I read
> "40:84    byte    Rows on the screen (less 1, EGA+)"
> I interpreted it as meaning, that on EGA+ it is one less than the number 
> of rows and otherwise it is equal to the number of rows.

No, that's wrong; it means that for EGA or better (i.e. not MDA, 
Hercules or CGA) it is rows on screen - 1; for MDA, Hercules and CGA 
this field is undefined.

> I did not want to write code to figure out if I am working with an EGA+ 
> or otherwise (which might complicate matters further if there is going 
> to be serial console support). So I took the conservative approach.
> If somebody knows for sure that this number is always one less than the 
> number of rows then a change to biosio.c is in order.

See above.  The *correct* thing to do is to detect EGA presence (which 
includes VGA), if so use this value, otherwise use the hard-coded value 
24.  In practice I think this is safe to skip these days, it's a matter 
how anal-retentive you want to be (I always advocate anal-retentive 

There is another valuable aspect to this: if you detect EGA or better, 
it is safe to write directly to video RAM.  This can be a significant 
speedup, but I don't think it matters for the menu system.

Here is a getnumrows() which detects the proper number of rows (as 
opposed to rows-1):

	pushl	%ebp
	pushl	%ebx
	pushl	%esi
	pushl	%edi

	# First, detect if we have EGA or better
	movl	$0x12,%ah		# Video Subsystem Configuration			movb	$0x10,%bl		# 
Return EGA info
	int	$0x10
	movl	$25,%eax		# If no EGA, 25 lines
	cmpb	$0x10,%bl		# No EGA BIOS?
	je	1f

	# Get width from BIOS location 0x484
	xorw	%ax,%ax
	movw	%ax,%es
	movzbl	%es:0x484,%eax
	inc	%ax
	popl	%edi
	popl	%esi
	popl	%ebx
	popl	%ebp

More information about the Syslinux mailing list