Answer the question
In order to leave comments, you need to log in
Segmentation error?
Good day, I am writing a code generator, but I ran into a problem, the fact is that when executing the underlying code, a segmentation error occurs .
print1:
.string "%d\n"
.data
a:
.long 0
.text
.global main
main:
movl $-8, %ecx
movl $-7, %edx
cmp %ecx, %edx
setg %ah
push %ax
pushl a
pushl $print1
call printf
addl $8, %esp
jmp label_01
label_00:
label_01:
ret
Answer the question
In order to leave comments, you need to log in
The first point: The fact that a segmentation error occurs somewhere does not mean anything in itself. So the code is not analyzed (and even more so, generators are not written like that). It is necessary to consider this error under the debugger in detail: in what place, where the call came from, what is there with the stack, what is with the pointers. etc.
The second point: It is convenient to calculate the reverse Polish notation right on the top of the stack (but much faster still on registers, as long as there are enough registers). For everything else, local variables are allocated in the stack frame , for example (but still, registers should be used as much as possible here).
Third point: What is a coprocessor . Follow the links .
PS: Why not LLVM? Why another bike?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question