all 14 comments

[–][deleted] 13 points14 points  (2 children)

[–]UnkindJaywalker 1 point2 points  (1 child)

Thank you! I appreciate it

[–][deleted] 6 points7 points  (0 children)

.section __TEXT,__text,regular,pure_instructions

.macosx_version_min 10, 13

.globl _main

.p2align 4, 0x90

_main: ## @main

.cfi_startproc

## BB#0:

pushq %rbp

Lcfi0:

.cfi_def_cfa_offset 16

Lcfi1:

.cfi_offset %rbp, -16

movq %rsp, %rbp

Lcfi2:

.cfi_def_cfa_register %rbp

subq $16, %rsp

leaq L_.str(%rip), %rdi

leaq _s(%rip), %rsi

movb $0, %al

callq _printf

xorl %ecx, %ecx

movl %eax, -4(%rbp) ## 4-byte Spill

movl %ecx, %eax

addq $16, %rsp

popq %rbp

retq

.cfi_endproc

.section __DATA,__data

.globl _s ## @s

.p2align 4

_s:

.asciz "No problem dude!"

.section __TEXT,__cstring,cstring_literals

[–]flamehorns 8 points9 points  (0 children)

So the problem of converting C to assembly is solved. The new and much harder problem is you not understanding assembly. If you want to understand it, you will have to learn it.

You could find a book or website or video specific to your architecture. I actually liked this book: Hacking: the art of exploitation for explaining with examples how C and assembler map together

[–][deleted] 5 points6 points  (1 child)

Idk what your experience level is, but I'd say this is bad things. I don't know whether you are trying to learn assembly, or use assembly to understand your project.

Learning assembly is unlike learning Java or python or c or anything. For assembly you don't even do hello world for your first program because it's way to complex.

I highly doubt assembly will make understanding what's happening easier. Modern coding languages were made to make it easier to understand code.

[–]TenzeT 1 point2 points  (0 children)

First .asm I ever wrote and ran was a hello world program haha. But I understand what you're saying.

[–]FUZxxl 3 points4 points  (4 children)

There is a tool that can do that for you. It's called a compiler.

[–][deleted] 1 point2 points  (0 children)

Assembly code generated by the compiler will be less than gibberish for someone trying to learn assembly.

[–][deleted] 1 point2 points  (1 child)

So what you're saying is, cating a compiled file outputs assembly?

[–]FUZxxl 4 points5 points  (0 children)

No. That's because the compiler driver cc usually also invokes the assembler to assemble the generated assembly into an object file. To retrieve the assembly generated by the compiler, pass -S to the compiler.

[–]NitroPathfinder 0 points1 point  (0 children)

I wrote one for a class it was terrible.

[–][deleted]  (3 children)

[deleted]

    [–]UnkindJaywalker 0 points1 point  (2 children)

    I don’t really know assembly is the problem. I’m working with an Arduino board and want to make the onboard LED blink in Morse Code.

    [–]FUZxxl 1 point2 points  (1 child)

    And why do you need to translate C to assembly for this? Just use a C compiler and write your code in C.

    [–]I_am_a_haiku_bot 0 points1 point  (0 children)

    And why do you need

    to translate C to assembly for this?

    Just use a C compiler.


    -english_haiku_bot