~ruther/verilog-riscv-semestral-project

bde9255cf35820314e882969060f77f5cbd6c460 — Rutherther 1 year, 5 months ago 37437a0
chore: load gcd parameters from memory
1 files changed, 21 insertions(+), 11 deletions(-)

M programs/gcd.c
M programs/gcd.c => programs/gcd.c +21 -11
@@ 2,7 2,12 @@
#include <stdio.h>
#endif

int int_remainder(int a, int b) {
int int_remainder(int a, int b)
{
    if (b == 0) {
        return 0;
    }

    while (a >= b) {
        a -= b;
    }


@@ 23,25 28,30 @@ int gcd(int a, int b)
    return previous_r;
}

#ifdef unix
void main()
{
    int a = 1071;
    int b = 462;

    #ifdef unix
    int a, b;
    printf("a: ");
    scanf("%d", &a);
    printf("b: ");
    scanf("%d", &b);
    #endif
    int res = gcd(a, b);
    printf("%d\n", res);
}
#else
void main()
{
    int* a_address = (int*)4;
    int* b_address = (int*)8;

    int a = *a_address;
    int b = *b_address;

    int res = gcd(a, b);

    #ifdef unix
    printf("%d\n", res);
    #else
    int* result_address = 0;
    *result_address = res;
    #endif

}
#endif


Do not follow this link