I keep getting a segmentation fault error when running my code. Everything has compiled well, but I can\'t seem to get it to do what I want. The program is to ask the user to e
It is not easy to pinpoint the problem without knowing the compiler you use.
Segmentation fault hapens in protected mode, when you try to access a segment you have no permissions to access.
You declare 3 diferent segments here. You have to make sure your ds
register is initialized to your .data
segment, before calling print_string
.
It also seems problematic that after read_int
you save the data to the input1
variable which seems to be in a different segment than that you used for printing the message, but you do not change ds
.
I'm not familiar how exactly your compiler handles these segments, so please give a link to its documentation.
div ebx
the problem seems to be here. You have to zero out edx since is is the high order word of the divisor, so probably you're getting something like a division overflow exception.
If this isn't the case probably the problem is in some of your I/O routines