NASM -> GNU ASM

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
yanix

NASM -> GNU ASM

Post 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:
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:NASM -> GNU ASM

Post by Candy »

Try googling for it -> first two hits...
yanix

Re:NASM -> GNU ASM

Post 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
Kemp

Re:NASM -> GNU ASM

Post 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.
AR

Re:NASM -> GNU ASM

Post 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
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re:NASM -> GNU ASM

Post by Solar »

yanix wrote: I need translate this code from nasm to gnu asm...
Meta-hint: assemble with NASM, disassemble with objdump.
Every good solution is obvious once you've found it.
Peradox

Re:NASM -> GNU ASM

Post by Peradox »

intel2gas has proven to be a useful tool. However hardcore nerders do it Solar's way ;)
yanix

Re:NASM -> GNU ASM

Post 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
NotTheCHEAT

Re:NASM -> GNU ASM

Post 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."
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:NASM -> GNU ASM

Post by Candy »

NotTheCHEAT wrote: !Off-topic: I wonder who invented the AT&T syntax?
AT&T of course.

at least, quite probable :)
yassine

Re:NASM -> GNU ASM

Post 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
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re:NASM -> GNU ASM

Post 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?
Every good solution is obvious once you've found it.
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:NASM -> GNU ASM

Post 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.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re:NASM -> GNU ASM

Post by Solar »

No I won't bite. ;)
Every good solution is obvious once you've found it.
Kemp

Re:NASM -> GNU ASM

Post 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
Post Reply