Monday, January 9, 2012

I think port to ARM.

I'm thinking my own OS to port x86 to ARM.
I have to control ARM chip.
I will try to design and make program on ARM.
Install gcc for ARM.
$ sudo apt-get install gcc-arm-linux-gnueabi
Install ARM qemu.
$ sudo apt-get install qemu qemu-kvm qemu-kvm-extras
Write program by ARM assemble(hello world) and check ARM registers.
.text
    .align 2
    .global _start

# write system call
sys_write = 0x900004
# exit system call
sys_exit = 0x900001

# Program entry
_start:
    ldr r1, msg
    mov r0, #1
    ldr r2, msg_sz
    swi #sys_write

    mov r0, #0
    swi #sys_exit

msg:    .long msg_str
msg_sz: .long msg_sz0

    .data
    .align 2

msg_str: .asciz "Hello, world\n"

    .align 2
    msg_sz0 = . - msg_str

    .bss
    .align 2
data: .long 0
Compile and link program.
$ arm-linux-gnueabi-as -o hello.o hello.s                 
$ arm-linux-gnueabi-ld hello hello.o
Run software on ARM qemu.
$ qemu-arm ./hello

Hello, world
$
Thanks.

No comments:

Post a Comment