Hello currently im trying to make a gaussian function in NASM, but when I try to compile it so I can use this function in C, I get an error..
The error I get:
ISO C does not support the 'I64' ms_printf length modifier [-Wformat=]
My NASM code:
global gauss
section .text
gauss:
mov rax, rdi
imul rax, rax
add rax, rdi
mov dl, 2
div dl
ret
My gauss.c file:
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <inttypes.h>
#define RED "\033[31m"
#define DEFAULT "\033[39m"
#define BOLD "\033[1m"
#define RESET "\033[0m"
extern uint64_t gauss(uint64_t n);
int main(int argc, char* argv[]) {
if(argc < 2) {
fputs(BOLD RED "Not enough arguments!\n" RESET, stderr);
return EXIT_FAILURE;
}
char* test = NULL;
uint64_t val = strtoull(argv[1], &test, 10);
if(*test) {
fprintf(stderr, BOLD RED "Invalid Argument: %s\n" RESET, argv[1]);
return EXIT_FAILURE;
}
uint64_t res = gauss(val);
printf("gauss(%"PRIu64") = %"PRIu64"\n", val, res);
return EXIT_SUCCESS;
}
The commands I typed in:
> nasm -f elf64 gauss.asm
> gcc -std=c11 -Wall -Wextra -pedantic -O2 -o prog gauss.c
gauss.o