123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- #include <stdio.h>
- #include <inttypes.h>
- #include <assert.h>
- #include "prcalc.h"
- int main (int argc, char** argv) {
- prc_context ctx;
- uint64_t op1=0, op2=0;
- prc_init_context(&ctx);
-
- // This should have zero flags
- op1 = 10;
- op2 = 10;
- prc_push(&ctx, op1);
- prc_push(&ctx, op2);
- prc_add_stack(&ctx);
- assert(ctx.registers.FLAGS == 0);
- printf("ADD(%20." PRIi64 ", %20." PRIi64 ")\tuint64_t: %20." PRIu64 "\tint64_t: %20." PRIi64 "\tHex: %16.lx\tFlags: %d\n", op1, op2, ctx.registers.A, ctx.registers.A, ctx.registers.A, ctx.registers.FLAGS);
- // This should have zero flags
- op1 = -1;
- op2 = 10;
- prc_push(&ctx, op1);
- prc_push(&ctx, op2);
- prc_add_stack(&ctx);
- assert(ctx.registers.FLAGS == 0);
- printf("ADD(%20." PRIi64 ", %20." PRIi64 ")\tuint64_t: %20." PRIu64 "\tint64_t: %20." PRIi64 "\tHex: %16.lx\tFlags: %d\n", op1, op2, ctx.registers.A, ctx.registers.A, ctx.registers.A, ctx.registers.FLAGS);
- //This should have negative flag
- op1 = -1;
- op2 = -10;
- prc_push(&ctx, op1);
- prc_push(&ctx, op2);
- prc_add_stack(&ctx);
- assert(ctx.registers.FLAGS == 2);
- printf("ADD(%20." PRIi64 ", %20." PRIi64 ")\tuint64_t: %20." PRIu64 "\tint64_t: %20." PRIi64 "\tHex: %16.lx\tFlags: %d\n", op1, op2, ctx.registers.A, ctx.registers.A, ctx.registers.A, ctx.registers.FLAGS);
- // This should be negative flag and unsigned flag
- op1 = 0b0111111111111111111111111111111111111111111111111111111111111111;
- op2 = 1;
- prc_push(&ctx, op1);
- prc_push(&ctx, op2);
- prc_add_stack(&ctx);
- assert(ctx.registers.FLAGS == 10);
- printf("ADD(%20." PRIi64 ", %20." PRIi64 ")\tuint64_t: %20." PRIu64 "\tint64_t: %20." PRIi64 "\tHex: %16.lx\tFlags: %d\n", op1, op2, ctx.registers.A, ctx.registers.A, ctx.registers.A, ctx.registers.FLAGS);
- // This should be a overflow flag and negative
- op1 = 1;
- op2 = 0b1111111111111111111111111111111111111111111111111111111111111111;
- prc_push(&ctx, op1);
- prc_push(&ctx, op2);
- prc_add_stack(&ctx);
- assert(ctx.registers.FLAGS == 6);
- printf("ADD(%20." PRIu64 ", %20." PRIu64 ")\tuint64_t: %20." PRIu64 "\tint64_t: %20." PRIi64 "\tHex: %16.lx\tFlags: %d\n", op1, op2, ctx.registers.A, ctx.registers.A, ctx.registers.A, ctx.registers.FLAGS);
- // This should have zero flags
- op1 = 4;
- op2 = 25;
- prc_push(&ctx, op1);
- prc_push(&ctx, op2);
- prc_mul_stack(&ctx);
- assert(ctx.registers.FLAGS == 0);
- printf("ADD(%20." PRIi64 ", %20." PRIi64 ")\tuint64_t: %20." PRIu64 "\tint64_t: %20." PRIi64 "\tHex: %16.lx\tFlags: %d\n", op1, op2, ctx.registers.A, ctx.registers.A, ctx.registers.A, ctx.registers.FLAGS);
-
-
- //prc_mul_stack(&ctx);
- //printf("RESULT: %ld \nFLAGS: %d\n", ctx.registers.A, ctx.registers.FLAGS);
-
-
-
- }
|