Write an assembly procedure called increment that is callable from C. The procedure should take a pointer to 32-bit integer as a parameter, and should increment the integer to which the parameter points. The C prototype for the function is as follows:
void increment (int *p);
provide only the assembly code from the procedure label to the ret instruction.
So, the question has to be done in Assembly x86-64 (in this case, E registers since it's asking for 32-bit). It's generally a short segment of logical instructions of 3-12 lines of code in _start: that I have to code assuming everything else is already declared and defined. For example:
mov rax,[x]
mov rbx,[y]
cqo
idiv rbx
mov [q],rax
mov [r],rdx
My issue is it's asking for the procedure to take a pointer to a 32-bit integer as a parameter AND incrementing the integer to where the parameter is pointing.
I'm not sure how I would go about in translating this C code into NASM, or a callable function:
void increment (int *p) {
*p = *p + 1;
}