Page 1 of 2

NASM -> GNU ASM

Posted: Sun Nov 20, 2005 12:04 pm
by yanix
I need translate this code from nasm to gnu asm :
_isr0:
cli
push byte 0
push byte 0
jmp isr_common_stub

SECTION .bss
resb 8192 ; This reserves 8KBytes of memory here
_sys_stack:

Re:NASM -> GNU ASM

Posted: Sun Nov 20, 2005 1:14 pm
by Candy
Try googling for it -> first two hits...

Re:NASM -> GNU ASM

Posted: Sun Nov 20, 2005 1:51 pm
by yanix
OK , I trying...
HERE is a NASM source .
This is Bran's Kernel Development -BKERNDEV- tutorial on writing kernels .
HERE is my GNU ASM version of this source .
What is wrong ?

Thank you

Re:NASM -> GNU ASM

Posted: Sun Nov 20, 2005 3:28 pm
by Kemp
Lesson number 1:
Posted reams of code and saying "What's wrong?" with no description of why you think it's wrong will get no help.

Re:NASM -> GNU ASM

Posted: Sun Nov 20, 2005 9:01 pm
by AR
yanix wrote: I need translate this code from nasm to gnu asm :
_isr0:
cli
push byte 0
push byte 0
jmp isr_common_stub

SECTION .bss
resb 8192 ; This reserves 8KBytes of memory here
_sys_stack:
For this particular piece of code:

Code: Select all

.global _isr0
_isr0:
   cli
   push $0
   push $0
   jmp isr_common_stub

.lcomm Stack, 8192
You will need to change the code that loads the stack though:

Code: Select all

mov $(Stack + 8192), %esp

Re:NASM -> GNU ASM

Posted: Mon Nov 21, 2005 12:32 am
by Solar
yanix wrote: I need translate this code from nasm to gnu asm...
Meta-hint: assemble with NASM, disassemble with objdump.

Re:NASM -> GNU ASM

Posted: Mon Nov 21, 2005 1:11 am
by Peradox
intel2gas has proven to be a useful tool. However hardcore nerders do it Solar's way ;)

Re:NASM -> GNU ASM

Posted: Mon Nov 21, 2005 11:36 am
by yanix
>> Meta-hint: assemble with NASM, disassemble with objdump.
It is a real Meta-hint

>> intel2gas has proven to be a useful tool.
Yes , of course . But you must correct generated code .

I compiled bkerndev project under Fedora 3 (gcc 3.4.2 + gnu asm 2.15 + nasm 0.98)

This is NASM zip-version bkerndev source project
This is GNU ASM zip-version bkerndev source project

Both kernels works under GRUB

Re:NASM -> GNU ASM

Posted: Tue Nov 22, 2005 11:26 pm
by NotTheCHEAT
GNU AS uses the AT&T syntax, which is very different from the Intel syntax. However, converting is pretty simple.

!Off-topic: I wonder who invented the AT&T syntax? Although I much prefer Intel syntax since that's the one I learned originally, I think if I had started with AT&T syntax I probably would have learned a lot more easier. To me,

Code: Select all

MOV FROM, TO
makes more sense than

Code: Select all

MOV TO, FROM
as it is closer to the English syntax, like "Move FROM to TO."

Re:NASM -> GNU ASM

Posted: Wed Nov 23, 2005 2:37 am
by Candy
NotTheCHEAT wrote: !Off-topic: I wonder who invented the AT&T syntax?
AT&T of course.

at least, quite probable :)

Re:NASM -> GNU ASM

Posted: Wed Nov 23, 2005 2:59 am
by yassine
Hi,

you can use intel synatx in Gnu assembler by using this directive

.intel_syntax

this switch to intel mode, while

.att_syntax
switches back to the AT&T

Re:NASM -> GNU ASM

Posted: Wed Nov 23, 2005 3:05 am
by Solar
AT&T is "native", or "near-native" syntax for many CPU families, including the 680x0 which was the CPU in many SUN Unix workstations. Quite naturally, that is how AT&T wrote its Unix - the Intel CPUs didn't play big in the Unix sector for a long time.

Since the GCC toolchain comes from the Unix world, it's quite natural they stuck to one general syntax to keep interfacing of GCC and GAS simple.

The question is, who the f*** came up with that brain-dead Intel syntax, and what have they been smoking?

Re:NASM -> GNU ASM

Posted: Wed Nov 23, 2005 3:23 am
by Candy
Solar wrote: The question is, who the f*** came up with that brain-dead Intel syntax, and what have they been smoking?
As far as I'm concerned, they've just been breathing fresh, pure, 21% oxygen 79% nitrogen air. What those guys at AT&T have been breathing is my question.

Re:NASM -> GNU ASM

Posted: Wed Nov 23, 2005 3:59 am
by Solar
No I won't bite. ;)

Re:NASM -> GNU ASM

Posted: Wed Nov 23, 2005 6:38 am
by Kemp
Just in case anyone takes you seriously, I'll adjust your quote slightly ;)


Intel is "native", or "near-native" syntax for many Intel CPU families, including the x86 which was the CPU family in many home PCs