"Rod Pemberton" wrote:
> Frank Kotler wrote:
>
>> bilsch wrote:
>
>> > 1) NASM code: times 510-($-$$) db 0
>> > fills the space between the the last byte of the program and byte
>> > number 510 of the sector. Fills it with zeros.
>> >
>> > what is GAS equivalent of: times 510-($-$$) db 0
>>
>> .org 510
>>
>> on my system, actually .org 497 and a few odds and ends of variables
>> plus the boot sig.
>
> Didn't the OP ask for a fill too, or is it unnecessary here?
>
> .fill 0x1fe - (. - start) , 1, 0
> .org 510
In this case the ".org" directive is redundant since it does the
same thing as the ".fill"
> In the .fill command, the '0' is the value to fill. The '1' is
> the size of the fill value in bytes, i.e., one byte, not two, four,
> or eight.
The default in ".fill" is to fill the specified count with zero bytes,
so in this case the parameters are redundant. ".org" fills from the
current location counter to the specified offset in the same way
and also has a byte fill value parameter available.
> The '.' in the .fill command represents the current assembly
> location, like '$' in NASM.
Good news is that "as" also recognizes the "$" in the exact same way
as nasm/fasm.
Too bad for no "$$".
>> > 2) does GAS have equivalent assembler directive to: bits 16
>>
>> .code16
>
> He needs either a .text or .data segment with GAS too, yes?
>
> .code16
> .text
".text" is the default so it's not required in this case.
GAS ("as") outputs an object file and cannot directly output a
binary file (like nasm/fasm). The object file can be converted
to a binary with "objcopy" (but will require simple runtime linking
like masm) or it can be linked with "ld" which produces the same
binary as the nasm/fasm "org 0x7C00".
as yourfile.s -o yourfile.o
ld --oformat binary -Ttext 0x7C00 yourfile.o -o yourfile.bin
Using a capital "S" ("s" is the same as "asm" for nasm/fasm) allows
the file to be processed by "cpp" (the c preprocessor) by passing
it to gcc.
<code>
.intel_syntax noprefix # no yucky AT&T
.code16 # .text section by default
.global _start # so "ld" (the linker) doesn't issue a warning
# otherwise not needed
_start: # hash sign used for single line comments
/ but forward slash is also used for single line comments
/ BEWARE - because of this "as" and even "cpp" don't recognize it as
division
.fill 510-($-_start) / the "$" is also recognized by "as" - sames as
nasm/fasm
.word 0xAA55
</code>
Mike Gonta
look and see - many look but few see
http://mikegonta.com