I have the following code (I'll print only the lines the program goes through before arriving at the segmentation fault)
push rbp
mov rbp, rsp
push rax
push rsi
push rdi
push rcx
push rdx
mov ecx, 0Ah
mov esi, 0h
for1:
cmp esi, DimMatrix * DimMatrix * 2
jge for1_end
mov edx, 011h
mov edi, 0h
for2:
cmp edi, DimMatrix
jge for2_end
mov ax, [m + esi + edi * 2]
movsx eax, ax
mov DWORD[number], eax
mov DWORD[rowScreen], ecx
mov DWORD[colScreen], edx
call showNumberP1
showNumberP1:
push rbp
mov rbp, rsp
push rax
push rbx
push rcx
push rdx
mov eax, [number]
mov cl, 0h
mov ebx, 0Ah
if1:
cmp eax, 000F423Fh
jle if1_end
mov eax, 000F423Fh
if1_end:
for:
cmp cl, 6h
jge for_end
mov BYTE[charac], 20h
if2:
cmp eax, 0h
jle if2_end
mov edx, 0h
div ebx
mov BYTE[charac], dl
add BYTE[charac], 30h
if2_end:
call gotoxyP1
gotoxyP1 is an nasm subroutine that calls on the correspoding C function which has one line:
printf("\x1B[%d;%dH",rowScreen,colScreen);
And that's where to program crashes with a segmentation fault.
number, rowScreen and colScreen are all int variables in the C program, and charac is a char variable. showNumberP1 works fine when tested on its own. Hoping somebody can find what's causing the segmentation fault, because I can't see it.