Menu

ELF 16 bit code and DOS .com file

2009-10-03
2013-04-20
  • Ito Toshimitsu

    Ito Toshimitsu - 2009-10-03

    Hello.<br>
    I compiled this code.<br>
    % jwasm200 -q -elf helloelf.asm<br>
    <br>
    ; helloelf.asm<br>
    .386<br>
    .model flat<br>

    _TEXT16 segment WORD use16 public 'CODE'<br>
    _start:<br>
                    mov dx, offset message<br>
                    mov     ah,09h<br>
                    int     21h<br>
                    mov     ax,4c00h<br>
                    int     21h<br>
    _TEXT16 ends

    _DATA16 segment WORD use16 public 'DATA'<br>
    message byte    'Hello, world !!', 0dh, 0ah, '$'<br>
    _DATA16 ends<br>
    end _start<br>
    <br>
    <br>
    and linked with object file. So, DOS .com file was made.<br>
    % ld -T com.lds helloelf.o -o helloelf.com<br>
    <br>
    /* com.lds (linker script) */<br>
    OUTPUT_FORMAT("binary");<br>
    COM_BASE = 0x0100;<br>

    SECTIONS {<br>
      . = COM_BASE;<br>
      .text   : { *(.text) }<br>
      .rodata : { *(.rodata) }<br>
      .rdata  : { *(.rdata) }<br>
      .data   : { *(.data) }<br>
      .bss    : { *(.bss) }<br>
      .stack  : { *(.stack) }<br>
    }<br>
    <br>
    <br>
    DOS> helloelf.com<br>
    Hello, world !!

    Thanks.

     
  • japheth

    japheth - 2009-10-04

        .386
        .model flat   
        _TEXT16 segment WORD use16 public 'CODE'
        _start:
        mov dx, offset message
        mov ah,09h
        int 21h
        mov ax,4c00h
        int 21h
        _TEXT16 ends

        _DATA16 segment WORD use16 public 'DATA'
        message byte 'Hello, world !!', 0dh, 0ah, '$'
        _DATA16 ends
       
        end _start

    jwasm200 -q -elf helloelf.asm

    ld -T com.lds helloelf.o -o helloelf.com

        OUTPUTFORMAT("binary");
        COM_BASE = 0x0100;
        SECTIONS {
        . = COM_BASE;
        .text : { *(.text) }
        .rodata : { *(.rodata) }
        .rdata : { *(.rdata) }
        .data : { *(.data) }
        .bss : { *(.bss) }
        .stack : { *(.stack) }
        }

     
  • japheth

    japheth - 2009-10-04

    I tried to make the itoto's post look nicer, but the new "formatting" feature apparently is too smart for me. I gave up.

     

Log in to post a comment.