at&t syntax: bootsector=> Textausgabe => 0xb800
-
Hallo. Ich versuche mich an einem simplen bootsector Programm.
(Ich hab so ein prog mal in NASM geschrieben. Da ging es. Jetzt in gas funkts net.).arch i386 .code16 .section .data msg: .asciz "Hallo Welt" .section .text .global _start _start: movw $0xb800 , %ax movw %ax , %es xorw %di , %di movw $0x7c00 , %ax movw %ax , %ds movw $msg , %si movb $0x1a , %ah #0x1a ist das Textattribut .l1: lodsb #ein byte von msg in %al lesen stosw #ein word bestehend aus attribut byte und text byte nach 0xb800 cmpb $0x00 , %al #msg zu ende? jne .l1 jmp . #is klar, endlosschleife .org 510 .short 0xaa55
as -o main.o main.s ld -o asm_bin.bin main.o --oformat binary -Ttext=0x7c00
Nunja. Eigentlich sollte mein code den Text "Hallo Welt" (msg) ausgeben Tut es aber nicht! (Es gib nur ein attributzeichen aus, und fertig) Ich vermute mal, es liegt am offset. aber wenn ich oeb im code ein
.org 0x7c00
einfüge, dann meckert der assembler.
as -o main.o main.s main.s: Assembler messages: main.s:34: Error: attempt to .org/.space backwards? (-31264) main.s:18: Error: relocation out of range main.s:36: Fatal error: cannot write to output file
Irgendwie stehe ich auf dem Schlauch!
-
.org 510
.short 0xaa55Laut meinem NASM geht das nicht.
Ich muss da wass mit "Times" zusammenstricken
-
gargyle schrieb:
.org 510
.short 0xaa55Laut meinem NASM geht das nicht.
Ich muss da wass mit "Times" zusammenstrickenNASM (Intelsyntax) != GAS (AT&T-Syntax)
Ich weiß, dass es in NASM nicht geht. Aber in GAS sollte es gehen.
(Zumindest hab ich mal im Netz einen AT&T syntax Quellcode gesehen, wo das so gemacht wurde.)
-
Hat sich erledigt.
-
schreibe auch unter anderem an einen bootloader, in meinen fall kommt
times 512-($-$$) db 0
zum einsatz.
-
auch_gaser schrieb:
schreibe auch unter anderem an einen bootloader, in meinen fall kommt
times 512-($-$$) db 0
zum einsatz.
Das ist aber NASM code. In GAS enzspricht '.' dem '$' in NASM. AUßerdem gibts es in GAS keine direktive times, sondern da muss man '.rept' und '.endr' verwenden.