0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

#概要

grubが入ったフロッピーイメージでkernelの様なものを起動する。
コンパイルに、paizaを使って見た。

#閃きのイメージ

開発環境を準備するのは、大変。
web上で、解決できないか。
paizaが64bitだけど、使えそう。
バイナリーは、base64で、良いでしょう。

#サンプルコード

import subprocess
import os

def gcc():
    p_file = 'test5.S'
    test_p = """
.text
.globl _start
.globl multiboot_header
.code32

_start:
    movl    $0xb8000, %ebx
    movl    $12, %ecx
    movl    $msg, %esi
loop:
    movb    (%esi), %al
    movb    $2, %ah
    movw    %ax, (%ebx)
    addl    $2, %ebx
    addl    $1, %esi
    subl    $1, %ecx
    jne     loop
    jmp     .

.data
multiboot_header:
    .align 4
    .long   0x1badb002
    .long   0x0 
    .long   -0x1badb002-0x0
msg:
    .ascii "Hello world!"
"""
    with open(p_file, 'w') as f:
        f.write(test_p)
    os.system("gcc -c -m32 -nostdlib %s" % p_file)
    os.system("ld -melf_i386 -e_start -Ttext=0x100000 -otest5.elf test5.o")
    os.system("file test5.elf")
    os.system("cat test5.elf|base64")

if __name__ == '__main__':
  gcc()
  

#成果物

以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?