s2asm --- dos2out bug

s2asm --- dos2out bug

Post by Earl Ch » Fri, 02 Nov 1990 03:37:00



There is a minor problem with dos2out. Large .exe headers will confuse it.

Earl

-------------------------------------------------------------------------------
*** a:dos2out.c Mon May 08 23:23:42 1989
--- dos2out.c   Sat Nov 18 22:56:54 1989
***************
*** 96,103 ****
  #define A_BLR(cputype)        ((cputype&0x01)!=0)  /* TRUE if bytes left-to-right */
  #define A_WLR(cputype)        ((cputype&0x02)!=0)  /* TRUE if words left-to-right */

!
  #include <stdio.h>
  #include <fcntl.h>
  #include <io.h>
  #include <sys/stat.h>
--- 96,104 ----
  #define A_BLR(cputype)        ((cputype&0x01)!=0)  /* TRUE if bytes left-to-right */
  #define A_WLR(cputype)        ((cputype&0x02)!=0)  /* TRUE if words left-to-right */

! #include <stdlib.h>
  #include <stdio.h>
+ #include <string.h>
  #include <fcntl.h>
  #include <io.h>
  #include <sys/stat.h>
***************
*** 133,138 ****
--- 134,140 ----
    unsigned int
        sym,                    /* data-relocation symbol offset */
        sym_blk, sym_off;       /* load-module block & offset in blk */
+   long exehdr;                        /* length of exe header */
    long        d_size,                 /* size of data-segment */
        t_size,                 /* size of text-segment */
        load_size;              /* size of load-module in bytes */
***************
*** 221,226 ****
--- 223,231 ----

  /*========================= PROCESS FILE =============================*/

+     /* remember the length of the header */
+     exehdr = d_ptr->hdr_size * 16;
+
      /* get reloc symbol's position in load-module */
      sym  = (unsigned int) inbuf[d_ptr->reloc_table+3] << 12;
      sym += (unsigned int) inbuf[d_ptr->reloc_table+2] << 4;
***************
*** 238,252 ****
      /* get symbol and calculate sizes */
      sepid  = inbuf2[sym_off+1] | inbuf2[sym_off+0];
      t_size = (sym+2 + 0xf) & ~0xf;
!     load_size  = (long) (d_ptr->nr_of_pages - 1 - (d_ptr->last_page_size!=0))
!                       * PH_SECTSIZE + d_ptr->last_page_size;
      if ((d_size = load_size - t_size) < 0)
        d_size = 0;

!     /* reposition file */
!     close (inf);
!     inf=open(in_name,O_RDONLY);
!     in_cnt=read(inf,inbuf2,PH_SECTSIZE);

      /* make a.out header */
      a_ptr->a_magic[0] = MAGIC0;
--- 243,258 ----
      /* get symbol and calculate sizes */
      sepid  = inbuf2[sym_off+1] | inbuf2[sym_off+0];
      t_size = (sym+2 + 0xf) & ~0xf;
!     load_size  = (long) (d_ptr->nr_of_pages - (d_ptr->last_page_size!=0))
!                       * PH_SECTSIZE + d_ptr->last_page_size - exehdr;
      if ((d_size = load_size - t_size) < 0)
        d_size = 0;

!     /* reposition file at start of code */
!     if (lseek(inf, exehdr, SEEK_SET) == -1) {
!       fprintf(stderr, "Cannot seek to start of code\n");
!       exit(1);
!     }

      /* make a.out header */
      a_ptr->a_magic[0] = MAGIC0;
-------------------------------------------------------------------------------
--
Earl Chew, Dept of Computer Science, Monash University, Australia 3168

----------------------------------------------------------------------

 
 
 

1. Bug in mpx+s2asm+tasm

There is a nasty bug with mpx+s2asm+tasm.
Lines 461,462 of mpx88.x (in the save routine for interrupts):
        seg     cs
        jmp     (bx)
are converted by the posted s2asm to:
        jmp     cs:(bx)
which is the same as:
        jmp     cs:bx

Now tasm figures that since a segment override prefix is meaningless here,
what you really mean is:
        jmp     cs:[bx]
which is a completely different instruction. What's more, tasm does this
quietly, without warning you. Thus, when you try to boot minix the
machine jumps to some odd location when it tries to process an interrupt.

The fix is to delete the segment override prefix. Then tasm works OK.

2. How to move a Web Service to another server?

3. dos2out

4. Please help: Can't get <xsl:for-each...> working

5. looking for dos2out program

6. Why does this blank file force a save on close, please help.

7. I need s2asm.sed for mcc-2.1.4

8. Help! : TV on RGB computer monitor???

9. dos2out, crc - where do I find?

10. s2asm header files

11. Wanted s2asm program

12. s2asm --- .s to .asm conversion

13. Need help with 'dos2out'