과 관련하여 제가 질문을 통해 온 gas, 당신은 어떻게 알 수 있습니까 사용하여 간단한 부트 로더를 구축하기 위해 GNU의 바이너리 유틸리티를 사용하는 방법을 이해하는 링커는 .org를 사용하여 파일 크기를 512 바이트로 유지하면서 위치 카운터를 향상시키는 파일에 데이터를 저장할 위치를 지정합니다. 나는 이것을 할 길을 찾을 수없는 것 같습니다.: 내 노력에 LD
이 작업을 수행하려고 조립 프로그램입니다 :
# Author: Matthew Hoggan
# Date Created: Tuesday, Mar 6, 2012
.code16 # Tell assembler to work in 16 bit mode
.section .data
msg: # Message to be printed to the screen
.asciz "hello, world"
.section .text
.globl _start # Help linker find start of program
_start:
xor %ax, %ax # Zero out ax register (ah used to specify bios function to Video Services)
movw %ax, %ds # Since ax is 0x00 0x00 use it to set data segment to 0
mov $msg, %si # Use source index as pointer to string
loop:
movb %ds:(%si), %al # Pass data to BIOS function in low nibble of ax
inc %si # Advance the pointer
or %al, %al # If byte stored in al is equal to zero then...
jz _hang # Zero signifies end of string
call print_char # Print current char in al
jmp loop # Repeat
#
# Function that uses bios function calls
# to print char to screen
#
print_char:
movb $0x0e, %ah # Function to print a character to the screen
movb $0x07, %bl # color/style to use for the character
int $0x10 # Video Service Request to Bios
ret
#
# Function used as infinite loop
#
_hang:
jmp _hang
.org 510
.byte 0x55, 0xAA
.end
UPDATE 나는 다음과 같은 오류 얻을 다음 명령을 사용 : 이런 종류의 일을 위해
[email protected]:~/Code/svn_scripts/assembly/bootloader/gas$ ld --oformat binary -o string string.o
string.o: In function `_start':
(.text+0x5): relocation truncated to fit: R_X86_64_16 against `.data'
이 오류를 생성하는 간단한 예와 의미 : http://stackoverflow.com/a/32639540/895245 작업 섹터가있는 저장소 + BIOS 예제 : https://github.com/cirosantilli/x86-bare- metal-examples –