On Friday 01 June 2007 22:22, azeem ahmad wrote:
> i am about to make a bootable floppy for test
> but i am being unable to get it done
        Whoa bubba... I am surprised you can make lunch... but seriously, who 
taught 
you how to write assembler code?    Ok, here is a sample "hello, world!" 
program that includes a counted loop to the iolib wrapper routine 
( hello.asm ) and the io wrapper ( iolib.asm ) and a Makefile. All you will 
need to build this hello world demo in opensuse is yasm|nasm , binutils 
( ld ) and elf (standard).  Its a flat 32 bit sample, staticly linked, and 
does not call any of the c library.  Enjoy, but pay particular attention to 
the format, the style, the comments, and the Makefile.  note: do not include 
the /begin /end lines in the code files.

</begin hello.asm>
section .text
        global _start
        extern stdOut

_start:
        mov ecx,count           ;loop counter
        mov eax,hello           ;setup data hello
        mov edx,hellolen

wrtHello:
        call    stdOut          ;write data hello
        loop    wrtHello        ;loop back until counter is zero

        mov eax,1               ;sys_exit
        mov ebx,0               ;return code 0 (no error)
        int 80h                 ;call the kernel

section .data
        hello           db      'Hello, World!',10
        hellolen:       equ     $-hello
        count:          equ     07h
</end hello.asm>

</begin iolib.asm>
section .text
        global stdOut

stdOut:
        push    edx             ;save environment
        push    ecx             ;
        push    ebx             ;
        push    eax             ;
        mov ecx,eax             ;setup data register
        mov eax,4               ;sys_write
        mov ebx,1               ;standard out
        int 80h                 ;call kernell
        pop     eax             ;restore environment
        pop     ebx             ;
        pop     ecx             ;
        pop     edx             ;
        ret
</end iolib.asm>

</begin Makefile>
all: hello

AS = yasm
ASMOPTS = -f elf
LINKOPTS = -s -o hello

hello: hello.o iolib.o
        ld $(LINKOPTS) hello.o iolib.o

hello.o: hello.asm
        $(AS) $(ASMOPTS) hello.asm

iolib.o: iolib.asm
        $(AS) $(ASMOPTS) iolib.asm

clean:
        rm hello.o iolib.o hello

install:
        cp hello ~/bin/
</end Makefile>




-- 
Kind regards,

M Harris     <><
-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to