0
#include <stdio.h>

#define abs(z) (z > 0 ? (z) : -(z))
#define minimumDistance 4
#define charOffset  60

int main()
{
    int radius = 15; 
    int size = 2 * radius + 1;
    
    for (int y=0; y<size; y++) {
        int deltaY = abs(y - radius);

        for (int x=0; x<size; x++) {
            int deltaX = abs(x - radius);

            int dist = deltaX + deltaY;
            if (dist > minimumDistance)
                putchar(dist + charOffset);
            else
                putchar(' ');
        }
        
        putchar(10);
    }

    return 0;
}

When ı tried to convert it ı got lots of error then I tried do it with chat it could not do it. Could you help me please ?

   main:
        push    rbp
        mov     rbp, rsp
        sub     rsp, 32
        mov     DWORD PTR [rbp-12], 15
        mov     eax, DWORD PTR [rbp-12]
        add     eax, eax
        add     eax, 1
        mov     DWORD PTR [rbp-16], eax
        mov     DWORD PTR [rbp-4], 0
        jmp     .L2
.L7:
        mov     eax, DWORD PTR [rbp-4]
        sub     eax, DWORD PTR [rbp-12]
        mov     edx, eax
        neg     edx
        cmovns  eax, edx
        mov     DWORD PTR [rbp-20], eax
        mov     DWORD PTR [rbp-8], 0
        jmp     .L3
.L6:
        mov     eax, DWORD PTR [rbp-8]
        sub     eax, DWORD PTR [rbp-12]
        mov     edx, eax
        neg     edx
        cmovns  eax, edx
        mov     DWORD PTR [rbp-24], eax
        mov     edx, DWORD PTR [rbp-24]
        mov     eax, DWORD PTR [rbp-20]
        add     eax, edx
        mov     DWORD PTR [rbp-28], eax
        cmp     DWORD PTR [rbp-28], 4
        jle     .L4
        mov     eax, DWORD PTR [rbp-28]
        add     eax, 60
        mov     edi, eax
        call    putchar
        jmp     .L5
.L4:
        mov     edi, 32
        call    putchar
.L5:
        add     DWORD PTR [rbp-8], 1
.L3:
        mov     eax, DWORD PTR [rbp-8]
        cmp     eax, DWORD PTR [rbp-16]
        jl      .L6
        mov     edi, 10
        call    putchar
        add     DWORD PTR [rbp-4], 1
.L2:
        mov     eax, DWORD PTR [rbp-4]
        cmp     eax, DWORD PTR [rbp-16]
        jl      .L7
        mov     eax, 0
        leave
        ret

I got this assembly output how can I make it executable.

mch
  • 9,424
  • 2
  • 28
  • 42
lalaland
  • 1
  • 1
  • 2
    You can use online compilers like [godbolt](https://godbolt.org/z/EYGnc9d5n). I guess most compilers should have some way to output to assembly too, instead of an executabel, just google it. – Joel Apr 25 '23 at 06:07
  • 1
    You compiled for Linux (note how it puts the arg for `putchar` into `EDI`, not `ECX`). If you want to use compilers on Godbolt other than MSVC, use `-mabi=ms` (instead of the default sysv). [Why does Windows64 use a different calling convention from all other OSes on x86-64?](https://stackoverflow.com/q/4429398) – Peter Cordes Apr 25 '23 at 06:36
  • ı tried them but ı do not get th true output – lalaland Apr 25 '23 at 06:50

0 Answers0