[syslinux] Com32 error?

G. Murali Krishnan gmkrishn at cs.uchicago.edu
Mon Nov 18 11:55:24 PST 2002


Well I tried my first COM32 program, which is supposed to print
"Hello, World" and then ":ello, World" in the next line.
It prints the second line alright, but prints a "." instead of the
first line.

I am using INT 22h for the first print and INT 21h (as in the sample
code) for the second line. Here is the code itself. It is based on the
sample code. Any pointers on whats wrong? Is there any place, where one
can see more sample COM32 code?

#include <com32.h>

#define NULL ((void *)0)

#define SEGMENT(ptr) ((unsigned int)((long)(ptr) >> 16))
/* Get the high order 16 bits */
#define OFFSET(ptr)  ((unsigned int)((long)(ptr) & 0xFFFF))
/* get the low order 16 bits */

static inline void memset(void *buf, int ch, unsigned int len)
{
  asm volatile("cld; rep; stosb"
	       : "+D" (buf), "+c" (len) : "a" (ch) : "memory");
}

int _start(unsigned int nargs, char *cmdline,
	   void (*syscall)(unsigned char, com32sys_t *, com32sys_t *),
	   void *bounce_ptr, unsigned int bounce_len)
{
  char *msg = "Hello, World!\r\n";
  com32sys_t inreg, outreg;
  const char *p;

  memset(&inreg, 0, sizeof inreg); /* Initialize registers */
  inreg.eax.w[0]=0x02;
  inreg.es =SEGMENT(msg);
  inreg.ebx.w[0]= OFFSET(msg); /* Pointer to msg */
  syscall(0x22,&inreg,NULL); /* print to console */

  msg[0]=':';
  for ( p = msg ; *p ; p++ ) {
    inreg.edx.b[0] = *p;
    inreg.eax.b[1] = 0x02;	/* Write Character */
    syscall(0x21, &inreg, NULL);
  }

  return 0;
}

- Murali

################################################################
#  Ry 254, Ryerson Hall,   #    Ph : +1 773 702-1031 (Off)     #
#  1100 E 58th Street      #         +1 773 575-4836 (Cell)    #
#  Chicago, IL - 60637,    #   URL : http://www.g-murali.com   #
#  USA.                    #  email: gmkrishn at cs.uchicago.edu  #
################################################################





More information about the Syslinux mailing list