The MASM Forum

Miscellaneous => The Orphanage => Topic started by: zedd on December 30, 2024, 03:40:41 PM

Title: My ChatGPT+Gemini coding Experiments
Post by: zedd on December 30, 2024, 03:40:41 PM
While chatgpt does not yet write very good masm32 assembly (usually needs too many corrections), it does fairly well writing C code.
I have been having chatgpt write some sudoku related functions, and most of the time the code compiles just fine and actually works. It has a better chance of doing sudoku right, than many C sudoku related examples on github that I have been investigating.

To finish my sudoku project I will either have to convert all of my asm code to C (very highly unlikely), convert the C code assembly listing to masm compatible assembly (can be tricky), or maybe even link the C functions to my assembly code. Hmmm...

So far though, I have had zero success linking the *.o files with any *.obj files. I have no clue what format the *.o files are. I can only assume some compatibility issue.

I am using dev C++ for the C code, which uses gcc as compiler.

Will post some of the code soon... I hope. (In a more appropriate section)

Title: Re: ChatGPT experiments
Post by: zedd on December 30, 2024, 03:58:54 PM
Well, rats!

QuoteYou've hit the Free plan limit for GPT-4o.
Responses will use another model until your limit resets tomorrow after 2:22 AM.

And things were going so well.  :tongue:

For anyone interested, I am working on code to count all possible solutions in a sudoku grid. To both ensure the grid is valid and is unique (it must have exactly 1 solution). I have asm code to very quickly generate a filled sudoku puzzle (can fill 1000 grids in 500-600 ms. without repeated grids), I also have code to remove values from the grid. ANd two different fast solvers (needed for puzzle generation) This piece is final step needed to make a very fast sudoku puzzle generator which only generates valid puzzles with a unique solution.  :azn:
Title: Re: ChatGPT experiments
Post by: jimg on December 30, 2024, 10:14:30 PM
 I have been using chatgpt for a few weeks now, and I've found it a great time saver when researching something I'm not familiar with.  One thing I like is never worrying about asking a really dump question.

It still has a penchant for trying to do memory to memory moves when filling out a structure, but those are easy to fix.  If it creates code with too many syntax errors, just feed the errors back in, and it will fix most of them.

I've also run into the time limit several times, but the "other model" just keeps on working, if a bit more slowly.

How does it work if you feed it the C code and ask it to convert it to masm?  Any better than using the compiler output?
Title: Re: ChatGPT experiments
Post by: TimoVJL on December 31, 2024, 12:18:32 AM
Quote from: zedd151 on December 30, 2024, 03:40:41 PMSo far though, I have had zero success linking the *.o files with any *.obj files. I have no clue what format the *.o files are. I can only assume some compatibility issue.

I am using dev C++ for the C code, which uses gcc as compiler.

try this for that *.o object files
objconv (https://github.com/gitGNU/objconv)
Many C/C++ compilers use symbols from compiler support libraries, so many object files wont work alone.
Title: Re: ChatGPT experiments
Post by: zedd on December 31, 2024, 02:31:03 AM
Thanks Timo. I have heard of objconv before, but had never needed to use it, so forgot it exist. I will try that later today. That will make the job easier, if it works.  :azn:  I see that is Agners work, should be good.
Title: Re: ChatGPT experiments
Post by: daydreamer on December 31, 2024, 07:02:22 AM
Zedd ,Here I use vc++ helping me port old Java code to masm
https://masm32.com/board/index.php?topic=7708.0 (https://masm32.com/board/index.php?topic=7708.0)
Also check that subforum for more info on port c to masm

Zedd isn't it time to code a zedd ai script,that emulates zedd long after your gone ? :)

Title: Re: ChatGPT experiments
Post by: zedd on December 31, 2024, 07:37:43 AM
Quote from: daydreamer on December 31, 2024, 07:02:22 AMZedd isn't it time to code a zedd ai script,that emulates zedd long after your gone ? :)
Gone??? That is alarming, where did that come from? I ain't going anywhere anytime soon.  :tongue:

A sneak peek at the latest chatgpt "C" code. Works flawlessly, but needs to be expanded quite a lot to add more solving methods and techniques...  :biggrin:

#include <stdio.h>
#include <stdbool.h>

#define SIZE 9

// Function to count pre-filled cells in the Sudoku puzzle
int count_prefilled_cells(int grid[SIZE][SIZE]) {
    int count = 0;
    for (int i = 0; i < SIZE; i++) {
        for (int j = 0; j < SIZE; j++) {
            if (grid[i][j] != 0) {
                count++;
            }
        }
    }
    return count;
}

// Function to evaluate the distribution of pre-filled cells
int evaluate_distribution(int grid[SIZE][SIZE]) {
    int row_filled[SIZE] = {0};
    int col_filled[SIZE] = {0};

    for (int i = 0; i < SIZE; i++) {
        for (int j = 0; j < SIZE; j++) {
            if (grid[i][j] != 0) {
                row_filled[i]++;
                col_filled[j]++;
            }
        }
    }

    int row_score = 0, col_score = 0;
    for (int i = 0; i < SIZE; i++) {
        row_score += (row_filled[i] > 0);
        col_score += (col_filled[i] > 0);
    }

    return row_score + col_score;
}

// Function to check if two cells form a Naked Pair
bool is_naked_pair(int candidates1[SIZE], int candidates2[SIZE]) {
    int count1 = 0, count2 = 0;
    for (int i = 1; i <= SIZE; i++) {
        if (candidates1[i]) count1++;
        if (candidates2[i]) count2++;
    }
    if (count1 == 2 && count2 == 2) {
        for (int i = 1; i <= SIZE; i++) {
            if (candidates1[i] != candidates2[i]) {
                return false;
            }
        }
        return true;
    }
    return false;
}

// Function to check for X-Wing patterns
bool check_x_wing(int grid[SIZE][SIZE], int candidate) {
    int rows[SIZE][SIZE] = {0};
    int cols[SIZE][SIZE] = {0};

    // Track candidate positions in rows and columns
    for (int i = 0; i < SIZE; i++) {
        for (int j = 0; j < SIZE; j++) {
            if (grid[i][j] == 0) {
                rows[i][j] = 1;
                cols[j][i] = 1;
            }
        }
    }

    // Check rows and columns for X-Wing patterns
    for (int r1 = 0; r1 < SIZE - 1; r1++) {
        for (int r2 = r1 + 1; r2 < SIZE; r2++) {
            int count = 0, cols_found[2];
            for (int c = 0; c < SIZE; c++) {
                if (rows[r1][c] && rows[r2][c]) {
                    cols_found[count++] = c;
                    if (count > 2) break;
                }
            }
            if (count == 2) {
                // Found an X-Wing
                return true;
            }
        }
    }
    return false;
}

// Function to check solving methods needed
void check_solving_methods(int grid[SIZE][SIZE]) {
    int has_hidden_singles = 0;
    int has_naked_pairs = 0;
    int has_x_wing = 0;

    // Example candidate matrix (1 to SIZE for each cell)
    int candidates[SIZE][SIZE][SIZE + 1] = {0};

    // Populate candidates (placeholder logic)
    for (int i = 0; i < SIZE; i++) {
        for (int j = 0; j < SIZE; j++) {
            if (grid[i][j] == 0) {
                for (int k = 1; k <= SIZE; k++) {
                    candidates[i][j][k] = 1;
                }
            }
        }
    }

    // Check for Naked Pairs
    for (int i = 0; i < SIZE; i++) {
        for (int j = 0; j < SIZE - 1; j++) {
            for (int k = j + 1; k < SIZE; k++) {
                if (is_naked_pair(candidates[i][j], candidates[i][k])) {
                    has_naked_pairs = 1;
                }
            }
        }
    }

    // Check for X-Wing
    for (int num = 1; num <= SIZE; num++) {
        if (check_x_wing(grid, num)) {
            has_x_wing = 1;
        }
    }

    printf("\nSolving Methods Required:\n");
    if (has_hidden_singles) {
        printf("- Hidden Singles\n");
    }
    if (has_naked_pairs) {
        printf("- Naked Pairs\n");
    }
    if (has_x_wing) {
        printf("- X-Wing\n");
    }
    if (!has_hidden_singles && !has_naked_pairs && !has_x_wing) {
        printf("- Basic Elimination\n");
    }
}

// Function to rate the difficulty of the Sudoku puzzle
const char* rate_sudoku(int grid[SIZE][SIZE]) {
    int prefilled = count_prefilled_cells(grid);
    int distribution = evaluate_distribution(grid);

    if (prefilled >= 36 && distribution >= 14) {
        return "Easy";
    } else if (prefilled >= 28 && distribution >= 12) {
        return "Medium";
    } else {
        return "Hard";
    }
}

// Function to display the Sudoku puzzle
void display_grid(int grid[SIZE][SIZE]) {
    for (int i = 0; i < SIZE; i++) {
        for (int j = 0; j < SIZE; j++) {
            printf("%d ", grid[i][j]);
        }
        printf("\n");
    }
}

int main() {
    // Example Sudoku puzzle (0 represents empty cells)
    int sudoku[SIZE][SIZE] = {
{0, 8, 0, 0, 3, 0, 0, 9, 0},
{0, 0, 0, 0, 0, 4, 5, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 8, 0},
{1, 0, 0, 0, 0, 0, 7, 0, 0},
{0, 0, 7, 5, 0, 6, 4, 0, 0},
{0, 6, 9, 0, 0, 0, 0, 0, 8},
{0, 2, 0, 0, 0, 0, 0, 7, 6},
{0, 0, 6, 2, 0, 0, 0, 0, 0},
{7, 9, 0, 0, 1, 0, 0, 3, 0}
  };

    printf("Given Sudoku Puzzle:\n");
    display_grid(sudoku);

    const char* difficulty = rate_sudoku(sudoku);
    printf("\nDifficulty Rating: %s\n", difficulty);

    check_solving_methods(sudoku);

    return 0;
}

Quote from: daydreamer on December 31, 2024, 07:02:22 AMZedd ,Here I use vc++
I have thought about 'biting the bullet' and using VS... but only briefly. DevC++ seems a lot simpler to use/set up. But I might eventually go that route, especially when I get into more complex code. (Meaning the bits and pieces that are not easily converted to asm)
Title: Re: ChatGPT experiments
Post by: TimoVJL on December 31, 2024, 08:29:05 AM
Here that C example's obj-files compiled with msvc 2022
Title: Re: ChatGPT experiments
Post by: zedd on December 31, 2024, 09:13:41 AM
Quote from: TimoVJL on December 31, 2024, 08:29:05 AMHere that C example's obj-files compiled with msvc 2022
Thanks, Timo.
Title: Re: ChatGPT experiments
Post by: daydreamer on December 31, 2024, 10:06:35 AM
Doesnt modern compilers use big booleans for speed,at least byte size and avoid old bit manipulation used when memory was small ?
I got an idea of save sieve data in 1 bit .bmp format ,at the same time curious how primes looks like for example in 256*256 grid or bigger square
Title: Re: ChatGPT experiments
Post by: zedd on December 31, 2024, 10:11:11 AM
What exactly do you mean by 'big boolean', daydreamer?
Boolean means 1 or 0, true or false, yes or no, etc. One bit is big enough for that.

As far as using bits to store the prime number array, I think the bit manipulation code would make an algorithm slower than simply using a byte array. I could be wrong though.

Speaking of prime numbers, I came across some code that uses square roots and floating point to determine the primacy of a given integer. It works well, but slower than my Prime Sieve. I just don't know why or how it works. (The code that uses sqrt and floats, to determine primacy). Anyway, I know that is just as accurate as the sieve method, I tested primes up to 1000000000 and output a list for both functions. It was 100% match, as it should be. But as said it is slower as it does not use an array as the sieve does, but has to factor for primes at each iteration from 0-1000000000, which takes time.   :smiley:  But for a one-off check of a given very large integer, it is fast enough.
Title: Re: ChatGPT experiments
Post by: daydreamer on December 31, 2024, 11:25:25 AM
zedd the idea is any image file ,read smaller file that is extracted to bytes or other bigger type in memory

i also been in c forum learning about square root trick is to limit division test loop to stop when it exceeds the square root of input number
Division is slow
Fsqrt is slow
Sieve has heavy use on caches


Title: Re: ChatGPT experiments
Post by: zedd on January 01, 2025, 03:30:19 PM
My ChatGPT+sudoku adventures are going very well. I am slowly (not too slow, though) building up a collection of C functions for solving sudoku without using backtracking, or brute force methods. The algorithms themselves are fairly trivial to convert to masm compatible assembly, disregarding all C related startup code and all other non sudoku related code that is.
There are two dozen or so functions that I will be converting one at a time, and testing them, before putting the combined set of functions into a single asm project.  :azn:

I will finish well before the years end.   :biggrin:

There is a question though about attribution. Do I have to give credit to ChatGPT when publishing the converted code? Does anyone know?
Title: Re: ChatGPT experiments
Post by: sinsi on January 01, 2025, 03:54:21 PM
Quote from: zedd151 on January 01, 2025, 03:30:19 PMDo I have to give credit to ChatGPT when publishing the converted code?
ChatGPT certainly doesn't give credit, so fuck em :biggrin:

MS were being sued because their AI was mining github? without attribution.
Title: Re: ChatGPT experiments
Post by: zedd on January 01, 2025, 04:43:57 PM
Quote from: sinsi on January 01, 2025, 03:54:21 PM
Quote from: zedd151 on January 01, 2025, 03:30:19 PMDo I have to give credit to ChatGPT when publishing the converted code?
ChatGPT certainly doesn't give credit, so fuck em :biggrin:

MS were being sued because their AI was mining github? without attribution.
Kind of what I thought.  :thumbsup:
Title: Re: ChatGPT experiments
Post by: zedd on January 01, 2025, 05:08:34 PM
One thing I just noticed during a lengthy ChatGPT session. You are only allowed a certain number of queries using the latest version of ChatGPT. After that you get dumbed down results, using a less that optimal version of ChatGPT... now I have to remove those crappy functions. :eusa_boohoo:
Title: Re: ChatGPT experiments
Post by: daydreamer on January 01, 2025, 05:34:04 PM
Quote from: zedd151 on January 01, 2025, 05:08:34 PMOne thing I just noticed during a lengthy ChatGPT session. You are only allowed a certain number of queries using the latest version of ChatGPT. After that you get dumbed down results, using a less that optimal version of ChatGPT... now I have to remove those crappy functions. :eusa_boohoo:
Well someone used to downgrade to win7,could downgrade chatgpt to before dumbed down ?:)
Title: Re: ChatGPT experiments
Post by: zedd on January 02, 2025, 02:07:20 PM
Only three out of the twelve functions (that I have asked ChatGPT for so far) actually do what they say they do, and work 100% of the time. The easiest functions, of course.

Hmmm... is ChatGPT supplying non working code so the users can supply to ChatGPT the debugged and fixed code? Very sneaky if that's the case. More likely they would supply working code more often for paying customers, that pay their monthly fee. The free version has yet another limitation?  :badgrin:

Anyway the easier algorithms are easy enough to spot where the errors occur, in ollydbg of course. But I won't tell that to the chat bot.  :biggrin:

Time-wise this is getting to be an expensive venture. Might just be easier/faster to work on getting my assembly code working the way I need it to work, without these so-called shortcuts.  :greensml:
Title: Re: ChatGPT experiments
Post by: daydreamer on January 02, 2025, 10:39:13 PM
Quote from: zedd151 on January 02, 2025, 02:07:20 PMAnyway the easier algorithms are easy enough to spot where the errors occur, in ollydbg of course. But I won't tell that to the chat bot.  :biggrin:

Time-wise this is getting to be an expensive venture. Might just be easier/faster to work on getting my assembly code working the way I need it to work, without these so-called shortcuts.  :greensml:
I agree with using debugger where errors occur,but want to add : debugger also good to single step to better  understand some new code works ,and I use debugger to get right new Opcode's I never used before and recently get right packed compares

If you feel most comfortable with coding asm,and years of experience you got fast code production speed,its the way to prefer when experienced c coder/asm newbie might prefer c code as starting point -> asm
Title: Re: ChatGPT experiments
Post by: zedd on January 04, 2025, 06:46:54 AM
I am having a lot of fun, having ChatGPT generate code then testing it. Both C and assembly.
Today I have been playing around with Googles AI counterpart, Gemini. Big fun.  :azn:

Who needs AI. I certainly don't!!! But is surely fun to experiment with, especially when I run out of ideas of my own. I might even start a subscription to one of these services for continual use of the 'premium' version (or whatever it's called), I would have to check and see first, if I can cancel at any time, without any type of penalty.  :biggrin:

If I find anything truly worthwhile, I'll be sure to post it. So far, I am just monkeying around, nothing serious.
Title: Re: ChatGPT experiments
Post by: daydreamer on January 04, 2025, 10:18:47 PM
Well yesterday artists got inspired by a woman to get ideas to new artwork,or even made portrait like Mona Lisa
Nothing strange with get inspired by chatgpt ,when some where inspired by Eliza programming to try write their own version or inspired write other string manipulation, like Swedish to Danish translation, short word list + change Swedish words that usually ends in "a" with Danish "e" ending,making it look Danish
Title: Re: ChatGPT+Gemini experiments
Post by: zedd on January 05, 2025, 07:36:20 AM
An interesting exchange between myself and Googles 'Gemini' AI, regarding a function to calculate entropy. It failed miserably in generating masm32 compatible code even though I provided some corrections to the auxilliary code, as it would not even assemble or link without those numerous changes. But the entropy function itself was flawed, as I found out once the program assembled and linked without any errors. (That code I did not 'fix', I left the algo intact.


Quote from: zedd151Yes, it is helpful. But as I am more proficient and knowledgable about assembly language, I preferred assembly.
I might disassemble the C program to see if I can make a masm32 compatible version of it myself.
Would this violate any rules?


Quote from: Google_GeminiYou're absolutely right! Disassembling C code can be a great way to learn about how compilers translate high-level code into assembly language.

Here's a general approach to disassembling C code and understanding the resulting assembly:

Compile the C code: Compile the C code with optimization flags disabled (e.g., -O0 for GCC) to generate assembly code that is easier to read and understand.
Disassemble the executable: Use a disassembler tool (like objdump on Linux or ndisasm on Windows) to disassemble the compiled executable file.
Analyze the assembly code:
Identify the assembly instructions corresponding to different parts of the C code (e.g., loops, conditional statements, function calls).
Pay attention to how the compiler handles data structures, function calls, and memory management.
Compare the generated assembly code with your own hand-written assembly code to understand the differences and learn from the compiler's optimizations.
Note:

Disassembled code can be complex and difficult to read, especially for optimized code.
The generated assembly code can vary significantly depending on the compiler, compiler flags, and the target architecture.
By analyzing the disassembled code, you can gain valuable insights into how compilers translate C code into machine code, which can help you write more efficient and optimized assembly code in the future.

I hope this helps! Let me know if you have any other questions.

Anyway, for anyone interested here is first, the C code
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define MAX_BYTES 256

double calculate_entropy(unsigned char* data, size_t size) {
    double entropy = 0.0;
    size_t counts[MAX_BYTES] = {0};

    // Count occurrences of each byte value
    for (size_t i = 0; i < size; i++) {
        counts[data[i]]++;
    }

    // Calculate probabilities
    for (int i = 0; i < MAX_BYTES; i++) {
        double probability = (double)counts[i] / size;
        if (probability > 0) {
            entropy -= probability * log2(probability);
        }
    }

    return entropy;
}

int main(int argc, char* argv[]) {
    if (argc != 2) {
        fprintf(stderr, "Usage: %s <filename>\n", argv[0]);
        return 1;
    }

    FILE* file = fopen(argv[1], "rb");
    if (file == NULL) {
        fprintf(stderr, "Error opening file: %s\n", argv[1]);
        return 1;
    }

    fseek(file, 0, SEEK_END);
    long file_size = ftell(file);
    rewind(file);

    unsigned char* data = (unsigned char*)malloc(file_size);
    if (data == NULL) {
        fprintf(stderr, "Memory allocation failed.\n");
        fclose(file);
        return 1;
    }

    if (fread(data, 1, file_size, file) != file_size) {
        fprintf(stderr, "Error reading file.\n");
        fclose(file);
        free(data);
        return 1;
    }

    fclose(file);

    double entropy = calculate_entropy(data, file_size);

    printf("Entropy: %.4f bits/byte\n", entropy);

    free(data);
    return 0;
}

And the last version of masm compatible assembly from Gemini (assembles and links, but crashes in the CalculateEntropy function), if anyone wants to tinker with it:
include \masm32\include\masm32rt.inc

.data?
    buffer db 4096 dup(?)
    counts DD 256 dup(?)
    entropy REAL4 ?
    fileHandle DD ?
    bytesRead DD ?
    fileSize DD ?
    bytesToRead DD ?

.const
    format db 'Entropy: %f bits/byte', 13, 10, 0
    filename db "input.bin", 0

.code
CalculateEntropy PROC countsArray:DWORD
    push esi
    push edi

    fldz            ; Initialize FPU stack with 0.0

    mov esi, countsArray ; Point ESI to the counts array
    xor ecx, ecx    ; Initialize loop counter to 0

@Loop:
    cmp ecx, 256    ; Check if all byte counts have been processed
    je @EndLoop

    mov eax, dword ptr [esi] ; Load count into a register (EAX)
    test eax, eax  ; Test if count is zero
    sahf            ; Set flags according to status word
    jbe @Skip        ; Skip if count is zero

    fild dword ptr [eax]      ; Load count onto the FPU stack
    fild dword ptr [fileSize] ; Load file size onto the FPU stack
    fdivp st(1), st(0)      ; Calculate probability (count / fileSize)
    fyl2x                    ; Calculate log2(probability)
    fmulp st(1), st(0)      ; Multiply probability by count
    fchs                    ; Negate the result
    faddp st(1), st(0)      ; Add to the running total

@Skip:
    add esi, 4              ; Move to the next count
    inc ecx                  ; Increment loop counter
    jmp @Loop

@EndLoop:
    fstp entropy            ; Store the result in the entropy variable

    pop edi
    pop esi
    ret
CalculateEntropy ENDP
    start:
        fn CreateFile, "hexbytes.bin", GENERIC_READ, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0
        mov fileHandle, eax
        test eax, eax
        jz @Exit

        invoke GetFileSize, fileHandle, 0
        mov fileSize, eax

    .while (fileSize > 0)
        mov bytesToRead, 4096
        mov eax, bytesToRead
        cmp eax, fileSize
        jle @ReadChunk
        mov eax, fileSize
        mov bytesToRead, eax

    @ReadChunk:
        invoke ReadFile, fileHandle, addr buffer, bytesToRead, addr bytesRead, 0
        test eax, eax
        jz @Exit

        mov esi, offset buffer
        mov ecx, bytesToRead
    @ReadLoop:
        mov al, byte ptr [esi]
        inc dword ptr counts[eax]
        inc esi
        loop @ReadLoop

        mov eax, bytesToRead
        sub fileSize, eax

    .endw

    invoke CloseHandle, fileHandle

    invoke CalculateEntropy, addr counts

    fld dword ptr [entropy]
    fstp st(0)

    push offset entropy
    push offset format
    call crt_printf

    invoke ExitProcess, 0

@Exit:
    invoke ExitProcess, 1

end start
Not exactly how I would have read the file, but Gemini had other ideas.  :tongue: also I would not have used a .data buffer for input, but allocated memory. 

:biggrin:  Big Phun!!
The C version works flawlessly

I guess Gemini's response is approval for what I had suggested I would do to get a working asm source.  :biggrin:

C project attached.  :badgrin:
Title: Re: ChatGPT+Gemini Experiments
Post by: daydreamer on January 05, 2025, 10:17:39 PM
Better use c compiler with c code and -fas switch to port to masm
I just tried compile /,* both with integer and floats,and sqrt
Ended up with mulss,divss, imul,idiv ,but call to sqrt math function seem unesserary call/ret overhead
Forgot to set output to fpu

Basic to asm was better alternative for me before
But CPP outputs masm x86 or x64 code using winapi calls is also helpful

Title: Re: ChatGPT+Gemini+Copilot Experiments
Post by: zedd on January 18, 2025, 04:36:21 AM
Using ChatGPT and Gemini for writing C code is a mixed bag. While the code presented almost always compiles without any major changes, the results must be verified.  :tongue:
I also tried Microsofts Copilot. It offered much of the same fare (are they all using the same sources?), but at least Copilot does give attribution to the original authors (usually from Github), and exactly where the code is from. Data miners.  :tongue:

These experiments were fun, but even with the C source code, converting to masm assembly is not always a trivial matter, especially with optimized C. Either that or I am just impatient, which may just be the case.  :biggrin:

This concludes my experimentation with C code.  :cool: Not a total loss though, I did obtain a few useful functions and a fair understanding of 'for loops'.
Title: Re: ChatGPT+Gemini Experiments
Post by: daydreamer on March 14, 2025, 07:10:51 AM
I wrote several .doc files in english as parts of my fantasy novel and desided to translate it to swedish,for those who dont understand english
Google translate was dissppointment,chatgpt might do better ?
Title: Re: ChatGPT+Gemini Experiments
Post by: NoCforMe on March 14, 2025, 07:15:20 AM
Quote from: daydreamer on March 14, 2025, 07:10:51 AMI wrote several .doc files in english as parts of my fantasy novel and desided to translate it to swedish,for those who dont understand english
Google translate was dissppointment,chatgpt might do better ?

Well, try it and let us know. (It's free, innit?)
Or you could try DeepSeek.
Title: Re: ChatGPT+Gemini Experiments
Post by: zedd on March 14, 2025, 07:16:26 AM
Never tried them for anything else but writing code, either C or masm compatible assembly.
Title: Re: ChatGPT+Gemini Experiments
Post by: guga on March 14, 2025, 08:55:08 AM
My 2 cents.

ChatGPT and Deepseek and Gemini tend to respond to what you expect, that is, it's almost like a suck-up. And you often get warnings that you've broken some rule that you don't even know what it is. Deepseek has a few fewer of these problems, but it's very slow and seems like a copy of ChatGPT to me. The problem with Deepseek is that it's slow and the server constantly stops, or when you have input limits like ChatGPT. Grok, on the other hand, is more robust so far. It doesn't just respond to what you want to hear, but actually helps you develop something or responds even when it's not what you'd like or don't agree with. Grok also has a free version, so it's a great alternative. Gemini is also an interesting alternative, but since it's Google, you'll occasionally come across this nonsense about restrictions for "violating rules of who knows what." For programming, all 4 have flaws, obviously, but they end up complementing each other. So, depending on what you want to do, it's good to alternate between the 4. One problem i face with them (except Grok, so far i saw), is that they don´t have access to other sessions, so if you are trying to do something in one session and needs to open a new one, they can´t be able to read previous information on another session and you needs to start over again.
For images, I use Google's Imagefx or Whiskey, which, in addition to being free, gives very good results. However, Google has a lot of restrictions on this nonsense of "you don't follow the rules of whatever". In general, these things are politically correct nonsense, even if you haven't entered anything out of the ordinary.
Title: Re: ChatGPT+Gemini Experiments
Post by: six_L on March 14, 2025, 01:14:12 PM
Hi,guga
QuoteMy 2 cents.
Fair evaluation about AI
Title: Re: ChatGPT+Gemini Experiments
Post by: zedd on March 14, 2025, 01:24:05 PM
Quote from: six_L on March 14, 2025, 01:14:12 PMFair evaluation about AI
I get about 25% reliability out of these AI models. In either C code or assembly, on average only 25% of the code produced had correct results and no compile or assembly errors.  :cool:  It was kind of fun playing with it. I lost two or three days while doing so.  :eusa_boohoo:
Title: Re: ChatGPT+Gemini Experiments
Post by: daydreamer on March 14, 2025, 06:44:16 PM
JJ showed earlier a perfect English to swedish ChatGPT translation
Example of errors in Google translate, example is
Trial by fire = "eldprov", the main character that is a mage is tested by their master mage
But Google translate "trial" as it's used in court when some criminal stand trial in court for crime committed

Title: Re: ChatGPT+Gemini Experiments
Post by: daydreamer on March 15, 2025, 04:00:03 AM
chatgpt made a perfect swedish translation of my fantasy story part "trial by fire"  :thumbsup:
Title: Re: ChatGPT+Gemini Experiments
Post by: daydreamer on March 21, 2025, 06:56:53 AM
Quote from: NoCforMe on March 14, 2025, 07:15:20 AM
Quote from: daydreamer on March 14, 2025, 07:10:51 AMI wrote several .doc files in english as parts of my fantasy novel and desided to translate it to swedish,for those who dont understand english
Google translate was dissppointment,chatgpt might do better ?

Well, try it and let us know. (It's free, innit?)
Or you could try DeepSeek.
It worked much better than google translate
chatgpt intelligently understand word meaning different depending on in which context its used,while google translate seem more translate word by word,dont care about which context its used in

Wonder anyone interesting in reading my fantasy story and give feedback ?
Title: Re: ChatGPT+Gemini Experiments
Post by: daydreamer on March 21, 2025, 07:01:42 AM
I remember i have old copy of ms office,gonna try install publisher,which helps you print out small books which you fokd oages to half size of A4 to A5 book size,keeping track of page numbers to end up in right places
Title: Re: ChatGPT+Gemini Experiments
Post by: jj2007 on March 24, 2025, 11:05:44 PM
ChatGPT gave me this C++ example for using GdipAddPathPath, but it throws plenty of cryptic errors:
#include <windows.h>
#include <gdiplus.h>
#pragma comment (lib,"Gdiplus.lib")

using namespace Gdiplus;

LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
    // Initialize GDI+
    GdiplusStartupInput gdiplusStartupInput;
    ULONG_PTR gdiplusToken;
    GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);

    // Register Window Class
    WNDCLASS wc = { 0 };
    wc.lpfnWndProc = WndProc;
    wc.hInstance = hInstance;
    wc.lpszClassName = L"GDIPlusExample";
    RegisterClass(&wc);

    // Create Window
    HWND hwnd = CreateWindow(L"GDIPlusExample", L"GDI+ Path Example",
        WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT,
        800, 600, NULL, NULL, hInstance, NULL);

    ShowWindow(hwnd, nCmdShow);
    UpdateWindow(hwnd);

    // Message Loop
    MSG msg;
    while (GetMessage(&msg, NULL, 0, 0))
    {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }

    // Shutdown GDI+
    GdiplusShutdown(gdiplusToken);
    return (int)msg.wParam;
}

// Window Procedure
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch (message)
    {
    case WM_PAINT:
    {
        PAINTSTRUCT ps;
        HDC hdc = BeginPaint(hwnd, &ps);

        // Create GDI+ Graphics object
        Graphics graphics(hdc);

        // Create two paths
        GpPath* path1;
        GpPath* path2;
        GdipCreatePath(FillModeWinding, &path1);
        GdipCreatePath(FillModeWinding, &path2);

        // Add a rectangle to path1
        GdipAddPathRectangle(path1, 100, 100, 200, 150);

        // Add an ellipse to path2
        GdipAddPathEllipse(path2, 200, 150, 200, 150);

        // Merge path2 into path1, connecting with a line
        GdipAddPathPath(path1, path2, TRUE);

        // Create a pen and draw the merged path
        GpPen* pen;
        GdipCreatePen1(Color::Red, 3, UnitPixel, &pen);
        GdipDrawPath((GpGraphics*)&graphics, pen, path1);

        // Cleanup
        GdipDeletePen(pen);
        GdipDeletePath(path1);
        GdipDeletePath(path2);

        EndPaint(hwnd, &ps);
    }
    break;

    case WM_DESTROY:
        PostQuitMessage(0);
        return 0;
    }
    return DefWindowProc(hwnd, message, wParam, lParam);
}

Does it compile for someone?
Title: Re: ChatGPT+Gemini Experiments
Post by: daydreamer on March 24, 2025, 11:37:20 PM
Different Version of gdiplus causes many errors ?
Never seen #pragma before used in CPP
Title: Re: ChatGPT+Gemini Experiments
Post by: TimoVJL on March 25, 2025, 12:42:17 AM
A test code for Pelles C
Don't work yet :sad:
#define UNICODE
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
//#include <gdiplusFlat.h>
#pragma comment (lib,"Gdiplus.lib")

//using namespace Gdiplus;
// GdiPlusFlat.h

#define WINGDIPAPI __stdcall
#define GDIPCONST const

typedef enum
{
    FillModeAlternate,        // 0
    FillModeWinding          // 1
} GpFillMode;

typedef enum
{
    UnitWorld,      //<! 0 = World coordinate (non-physical unit)
    UnitDisplay,    //<! 1 = Variable -- for PageTransform only
    UnitPixel,      //<! 2 = Each unit is one device pixel.
    UnitPoint,      //<! 3 = Each unit is a printer's point, or 1/72 inch.
    UnitInch,      //<! 4 = Each unit is 1 inch.
    UnitDocument,  //<! 5 = Each unit is 1/300 inch.
    UnitMillimeter  //<! 6 = Each unit is 1 millimeter.
} GpUnit;

typedef struct
{
    UINT32 GdiplusVersion ;
    void* DebugEventCallback ;
    BOOL SuppressBackgroundThread ;
    BOOL SuppressExternalCodecs ;
} GdiplusStartupInput ;

typedef float REAL;
typedef DWORD ARGB;

typedef struct tagGpGraphics GpGraphics;
typedef struct tagGpPath GpPath;
typedef struct tagGpPen GpPen;


typedef struct
{
    void* NotificationHook;    //NotificationHookProc NotificationHook;
    void* NotificationUnhook;    //NotificationUnhookProc NotificationUnhook;
} GdiplusStartupOutput ;

int __stdcall GdiplusStartup(ULONG_PTR*, const GdiplusStartupInput*, GdiplusStartupOutput*) ;
void __stdcall GdiplusShutdown(ULONG_PTR) ;
int __stdcall GdipCreatePath(GpFillMode brushMode, GpPath **path);
int __stdcall GdipAddPathRectangle(GpPath *path, REAL x, REAL y, REAL width, REAL height);
int __stdcall GdipAddPathEllipse(GpPath *path, REAL x, REAL y, REAL width, REAL height);
int __stdcall GdipAddPathPath(GpPath *path, GDIPCONST GpPath* addingPath, BOOL connect);
int __stdcall GdipCreatePen1(ARGB color, REAL width, GpUnit unit, GpPen **pen);
int __stdcall GdipDrawPath(GpGraphics *graphics, GpPen *pen, GpPath *path);
int __stdcall GdipDeletePath(GpPath* path);
int __stdcall GdipDeletePen(GpPen *pen);
int __stdcall GdipCreateFromHDC(HDC hdc, GpGraphics **graphics);
int __stdcall GdipDeleteGraphics(GpGraphics *graphics);

LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
    // Initialize GDI+
    GdiplusStartupInput gdiplusStartupInput = {1,0,0,0};
    ULONG_PTR gdiplusToken;
    GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);

    // Register Window Class
    WNDCLASS wc = { 0 };
    wc.style = CS_HREDRAW | CS_VREDRAW;
    wc.lpfnWndProc = WndProc;
    wc.hInstance = hInstance;
    wc.lpszClassName = L"GDIPlusExample";
    RegisterClass(&wc);

    // Create Window
    HWND hwnd = CreateWindow(L"GDIPlusExample", L"GDI+ Path Example",
        WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT,
        800, 600, NULL, NULL, hInstance, NULL);

    ShowWindow(hwnd, nCmdShow);
    //UpdateWindow(hwnd);

    // Message Loop
    MSG msg;
    while (GetMessage(&msg, NULL, 0, 0))
    {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }

    // Shutdown GDI+
    GdiplusShutdown(gdiplusToken);
    return (int)msg.wParam;
}

// Window Procedure
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch (message)
    {
    case WM_PAINT:
    {
        PAINTSTRUCT ps;
        HDC hdc = BeginPaint(hwnd, &ps);

        // Create GDI+ Graphics object
        //Graphics graphics(hdc);
        GpGraphics *graphics;
        GdipCreateFromHDC(hdc, &graphics);

        // Create two paths
        GpPath* path1;
        GpPath* path2;
        GdipCreatePath(FillModeWinding, &path1);
        GdipCreatePath(FillModeWinding, &path2);

        // Add a rectangle to path1
        GdipAddPathRectangle(path1, 100.0, 100.0, 200.0, 150.0);

        // Add an ellipse to path2
        GdipAddPathEllipse(path2, 200.0, 150.0, 200.0, 150.0);

        // Merge path2 into path1, connecting with a line
        GdipAddPathPath(path1, path2, TRUE);

        // Create a pen and draw the merged path
        GpPen* pen;
        GdipCreatePen1(0xFFFF0000, 3.0, UnitPixel, &pen);
        GdipDrawPath(graphics, pen, path1);

        // Cleanup
        GdipDeletePen(pen);
        GdipDeletePath(path1);
        GdipDeletePath(path2);
        GdipDeleteGraphics(graphics);

        EndPaint(hwnd, &ps);
    }
    break;

    case WM_DESTROY:
        PostQuitMessage(0);
        return 0;
    }
    return DefWindowProc(hwnd, message, wParam, lParam);
}
Title: Re: ChatGPT+Gemini Experiments
Post by: ognil on March 25, 2025, 01:14:06 AM
I always ask the same question to 5 AIs and choose the best answer. :smiley:   

To demonstrate how to use GdipAddPathPath and GdipDrawPath in MASM64 (Microsoft Macro Assembler for 64-bit), we need to first understand the purpose of these functions:

GdipAddPathPath : This function adds one path to another path. It is useful when you want to combine multiple paths into a single path object.

GdipDrawPath : This function draws a path on a graphics object using a specified pen.
Below is an example of how to use these functions in MASM64. The example assumes you have already set up GDI+ in your program, including initializing the GDI+ library and creating a graphics object.

Step-by-Step Explanation

Initialize GDI+ : Before using any GDI+ functions, you must initialize the GDI+ library.
Create Graphics and Paths : Create a Graphics object from a device context (e.g., a window or bitmap) and create two Path objects.

Add Paths : Use GdipAddPathPath to combine the two paths into one.
Draw the Combined Path : Use GdipDrawPath to render the combined path on the graphics object.

Clean Up : Release all GDI+ resources and shut down the library.

Example Code
asminclude \masm32\include64\masm64rt.inc
include \masm32\include64\gdiplus.inc
includelib \masm32\lib64\kernel32.lib
includelib \masm32\lib64\user32.lib
includelib \masm32\lib64\gdiplus.lib

; GDI+ Startup Input structure
GdiplusStartupInput STRUCT
    GdiplusVersion            DWORD ?
    DebugEventCallback        QWORD ?
    SuppressBackgroundThread  BOOL ?
    SuppressExternalCodecs    BOOL ?
GdiplusStartupInput ENDS

; Data segment
.data
hWnd                QWORD 0
hDC                 QWORD 0
graphics            QWORD 0
path1               QWORD 0
path2               QWORD 0
combinedPath        QWORD 0
pen                 QWORD 0
token               QWORD 0
startupInput        GdiplusStartupInput <1, 0, FALSE, FALSE>

; Code segment
.code
WinMain proc
    ; Initialize GDI+
    invoke GdiplusStartup, addr token, addr startupInput, 0
    .if eax != 0
        invoke ExitProcess, 1
    .endif
    ; Obtain a handle to the window and its device context
    invoke GetConsoleWindow
    mov hWnd, rax
    invoke GetDC, hWnd
    mov hDC, rax
    ; Create a Graphics object from the device context
    invoke GdipCreateFromHDC, hDC, addr graphics
    .if eax != 0
        invoke GdiplusShutdown, token
        invoke ExitProcess, 1
    .endif
    ; Create two Path objects
    invoke GdipCreatePath, 0, addr path1
    invoke GdipCreatePath, 0, addr path2
    ; Add shapes to the paths
    ; Path 1: A rectangle
    invoke GdipAddPathRectangle, path1, 50, 50, 100, 100
    ; Path 2: A circle
    invoke GdipAddPathEllipse, path2, 100, 100, 100, 100
    ; Combine the two paths into a new path
    invoke GdipCreatePath, 0, addr combinedPath
    invoke GdipAddPathPath, combinedPath, path1, TRUE
    invoke GdipAddPathPath, combinedPath, path2, TRUE
    ; Create a Pen for drawing
    invoke GdipCreatePen1, 0xFF0000FFh, 2, 2, addr pen
    ; Draw the combined path
    invoke GdipDrawPath, graphics, pen, combinedPath
    ; Clean up
    invoke GdipDeletePath, path1
    invoke GdipDeletePath, path2
    invoke GdipDeletePath, combinedPath
    invoke GdipDeletePen, pen
    invoke GdipDeleteGraphics, graphics
    invoke ReleaseDC, hWnd, hDC
    invoke GdiplusShutdown, token
    ; Exit the program
    invoke ExitProcess, 0
WinMain endp
end
Key Points in the Code

Initialization :
GdiplusStartup initializes the GDI+ library.
GetConsoleWindow and GetDC retrieve the handle to the console window and its device context.

Creating Paths :
GdipCreatePath creates two empty paths (path1 and path2).
GdipAddPathRectangle and GdipAddPathEllipse add shapes to the paths.

Combining Paths :
GdipAddPathPath combines path1 and path2 into combinedPath.

Drawing :
GdipCreatePen1 creates a pen with a blue color (0xFF0000FFh).
GdipDrawPath renders the combined path on the graphics object.

Cleanup :
All created objects are deleted using their respective GdipDelete* functions.
ReleaseDC releases the device context, and GdiplusShutdown shuts down the GDI+ library.

Notes
Error Handling : In a production environment, you should check the return values of all GDI+ functions to ensure they succeed.

Linking : Ensure that you link against gdiplus.lib and include the appropriate headers.

Dependencies : This example assumes you have the MASM64 environment set up with GDI+ support.
This example demonstrates the basic usage of GdipAddPathPath and GdipDrawPath in MASM64. You can extend it by adding more complex shapes, transformations, or additional drawing operations. :smiley:
Title: Re: ChatGPT+Gemini Experiments
Post by: jj2007 on March 25, 2025, 01:30:19 AM
I know all this, Lingo. In fact, I do have a perfectly working example (https://masm32.com/board/index.php?msg=57816). Problem is I have a second example that gives me a runtime error, and I don't have the faintest idea why.
Title: Re: ChatGPT+Gemini Experiments
Post by: jj2007 on March 25, 2025, 01:32:56 AM
Quote from: TimoVJL on March 25, 2025, 12:42:17 AMA test code for Pelles C

Compiles without errors but shows only a white screen... thanks anyway, Timo :thup:
Title: Re: ChatGPT+Gemini Experiments
Post by: TimoVJL on March 25, 2025, 02:11:11 AM
Quote from: jj2007 on March 25, 2025, 01:32:56 AM
Quote from: TimoVJL on March 25, 2025, 12:42:17 AMA test code for Pelles C

Compiles without errors but shows only a white screen... thanks anyway, Timo :thup:
It was just a conversion from bad AI code, nothing else.
EDIT: one cast error fixed, so now it draw path
Title: Re: ChatGPT+Gemini Experiments
Post by: zedd on March 25, 2025, 02:39:20 AM
Regarding any AI model that produces code... either C or assembly...

You must check and verify. The code produced may, and often does, contain errors.

This much I found out for myself.

My experience was that only 25% of code generated by AI actually compiled/assembled without error, runs without crashingand actually produced the correct outcome or results.

Your mileage may vary.  :tongue:
I discontinued my own AI experimentation, in this context, after only a few days.

I had noticed that ChatGPT (iirc) at least, had stopped giving me assembly code that uses the irvine32 libraries.  :rolleyes:
The C code it had generated usually compiled fine with gcc, except for some that had errors that caused compiler or linking issues. I had not tried compiling with any MS compiler.

The more complex the criteria, the more error prone was the resulting generated code in most cases.

Also, AI was prone to addressing errors like "mov eax, [esi+ecx*9]" or similar addressing errors.  :biggrin:
Title: Re: ChatGPT+Gemini Experiments
Post by: daydreamer on March 25, 2025, 03:12:49 AM
well earlier I tested with question "can you translate this to swedish?" with chatgpt
knowing there is specific differences between American English and British English and other countries english,so if I want to translate some text from british tv shows,might need to be more specific ?

nobody tried to ask one of the AI's "can you debug this cpp code for me?" yet?
or tried more specific question where you ask about visual cpp or your choice of compiler ?

Title: Re: ChatGPT+Gemini Experiments
Post by: zedd on March 25, 2025, 04:08:11 AM
Quote from: daydreamer on March 25, 2025, 03:12:49 AMnobody tried to ask one of the AI's "can you debug this cpp code for me?" yet?
or tried more specific question where you ask about visual cpp or your choice of compiler ?
The more complex the task that any AI model is given, the error rate increases somewhat proportionally I would assume, or even exponentially.

cpp (or C++) in any form, is more complex than simple plain old C.
Plus there are differences in cpp for gnu c compiler, and c++ for Microsoft  VisualC++, which would tend to add to the complexity.

One size does not fit all in this instance.  Not that I have any great knowledge of any variety of cpp or C++ nor do I claim any fluency in either, or plain C for that matter.  :greensml:  The only thing that I do know, is that it is way easier to port C code to assembly, than porting any variety of cpp/c++ code to assembly. I briefly looked into doing that.

Maybe in 5 or 10 years (or more?) AI will be able to reliably produce code in the most used formats/languages, and even some seldom used formats/languages.

All of these are my very, very humblest of opinions of course.  :cool:
Mileage may vary, depending on how well any request to the AI model is articulated.  A key point it seems, when asking anything from AI.  :biggrin:

Now making grammatically correct translations from one language to another possibly 'localized' language (English for example, US English, AU English and the Queens English {UK}), and vice versa, is another can of worms, and somewhat beyond the scope of the original intent of this topic.  I have been told that many countries, by the way, allegedly speak/read/write the same language as The United States. Some of which needs translation to American English.  :tongue:

I hereby reserve the right to mis-speak, or even have views that might deviate from that of other folks, etc., etc., blah, blah, blah, ad nauseum.  :toothy:  Meaning some of what is written here could be wrong, or misguided or misinterpreted.  :biggrin:  The latter parts obviously meant tongue in cheek.
Title: Re: ChatGPT+Gemini Experiments
Post by: ognil on March 25, 2025, 06:43:11 AM
QuoteI know all this, Lingo. In fact, I do have a perfectly working example.

Thank you Duce,
You are welcome. :badgrin:
Title: Re: ChatGPT+Gemini Experiments
Post by: guga on March 25, 2025, 07:21:16 AM
Quote from: jj2007 on March 25, 2025, 01:32:56 AM
Quote from: TimoVJL on March 25, 2025, 12:42:17 AMA test code for Pelles C

Compiles without errors but shows only a white screen... thanks anyway, Timo :thup:

JJ, do you still have that hlp file or chm file displaying the functions for GDI (fichier.chm) ?
Title: Re: ChatGPT+Gemini Experiments
Post by: zedd on March 25, 2025, 07:30:41 AM
Quote from: guga on March 25, 2025, 07:21:16 AMJJ, do you still have that hlp file or chm file displaying the functions for GDI (fichier.chm) ?
I know that you didn't address me, but legacy GDI or GDI+ (aka gdiplus)?

If you have the full version of WIN32.HLP (23.6 MB - 24,804,587 bytes), GDI is covered there.
Title: Re: ChatGPT+Gemini Experiments
Post by: guga on March 25, 2025, 07:40:28 AM
Quote from: zedd151 on March 25, 2025, 07:30:41 AM
Quote from: guga on March 25, 2025, 07:21:16 AMJJ, do you still have that hlp file or chm file displaying the functions for GDI (fichier.chm) ?
I know that you didn't address me, but legacy GDI or GDI+ (aka gdiplus)?

Hi Zedd....Gdi+ from the site JJ referred to. (Of course, if there is a chm file easier and more complete to follow for both Gdi and Gdi+, it would be better - specially from that address). It seems the chm file is not there anymore. (At least i couldn´t find it on the links JJ refered here Link2 (http://purebasic.developpez.com/tutoriels/gdi/#LVIII-1) and Link2 (https://masm32.com/board/index.php?topic=5389.msg57816#msg57816))
Title: Re: ChatGPT+Gemini Experiments
Post by: guga on March 25, 2025, 07:42:09 AM
Btw...i have win32.hlp somewhere. But for Gdi+, the one JJ said seems more complete and easier to read (Ok, it´s in french, but still can be read)
Title: Re: ChatGPT+Gemini Experiments
Post by: zedd on March 25, 2025, 07:44:50 AM
Quote from: guga on March 25, 2025, 07:42:09 AMBtw...i have win32.hlp somewhere. But for Gdi+, the one JJ said seems more complete and easier to read (Ok, it´s in french, but still can be read)
Ah, okay. win32.hlp doesn't have gdi+ (At least mine doesn't).

I had thought you made a mistake by saying "GDI". Thanks for clearing it up.
Title: Re: ChatGPT+Gemini Experiments
Post by: guga on March 25, 2025, 07:46:59 AM
No problem. I do have some of Gdi+ documented somewhere, but for that specific file, i don´t think i have one easier to read than that. Btw...i updated the SIMD_BinaryScan if you want to give a try. Working as expected, and Bug fixed. Now i´m working on the reverse function to scan backwards without errors or limitations.
Title: Re: ChatGPT+Gemini Experiments
Post by: jj2007 on March 25, 2025, 07:47:09 AM
Quote from: guga on March 25, 2025, 07:21:16 AMJJ, do you still have that hlp file or chm file displaying the functions for GDI

GDIPLUS (http://www.jj2007.eu/pics/GDIPLUS.zip)
Title: Re: ChatGPT+Gemini Experiments
Post by: guga on March 25, 2025, 07:48:08 AM
Quote from: jj2007 on March 25, 2025, 07:47:09 AM
Quote from: guga on March 25, 2025, 07:21:16 AMJJ, do you still have that hlp file or chm file displaying the functions for GDI

GDIPLUS (http://www.jj2007.eu/pics/GDIPLUS.zip)


Tks a lot, JJ !  :thumbsup:  :thumbsup:  :thumbsup:
Title: Re: ChatGPT+Gemini Experiments
Post by: zedd on March 25, 2025, 07:49:48 AM
Quote from: jj2007 on March 25, 2025, 07:47:09 AMGDIPLUS (http://www.jj2007.eu/pics/GDIPLUS.zip)
That will come in handy. May I download it too?  :biggrin:
Title: Re: ChatGPT+Gemini Experiments
Post by: jj2007 on March 25, 2025, 07:51:23 AM
Quote from: zedd151 on March 25, 2025, 07:49:48 AMMay I download it too?  :biggrin:
Let me reflect :cool:
Title: Re: ChatGPT+Gemini Experiments
Post by: zedd on March 25, 2025, 07:55:41 AM
Quote from: jj2007 on March 25, 2025, 07:51:23 AMLet me reflect :cool:
I asked since it was specifically posted for guga, And I did not know how long it would still be there.   :biggrin: 
Title: Re: ChatGPT+Gemini Experiments
Post by: stoo23 on March 25, 2025, 08:04:53 AM
I had placed that file on our server, a while ago and is available via this link:
https://masm32.com/files/GDIPLUS.zip (https://masm32.com/files/GDIPLUS.zip)

:thumbsup:
Title: Re: ChatGPT+Gemini Experiments
Post by: zedd on March 25, 2025, 08:26:30 AM
:biggrin:
Maybe make a topic for it stoo, and possibly other useful .chm files, in the Reference section? So it can be readily found?
Title: Re: ChatGPT+Gemini Experiments
Post by: jj2007 on March 25, 2025, 08:30:26 AM
Quote from: zedd151 on March 25, 2025, 07:55:41 AMAnd I did not know how long it would still be there

Just joking ;-)
Title: Re: ChatGPT+Gemini Experiments
Post by: zedd on March 25, 2025, 08:33:41 AM
Quote from: jj2007 on March 25, 2025, 08:30:26 AM
Quote from: zedd151 on March 25, 2025, 07:55:41 AMAnd I did not know how long it would still be there

Just joking ;-)
I knew that. But also you may have intended for it to be available only for a limited time period, and not permanently.
Title: Re: ChatGPT+Gemini Experiments
Post by: jj2007 on March 25, 2025, 09:48:11 AM
Quote from: TimoVJL on March 25, 2025, 02:11:11 AMnow it draw path

Great example, Timo - thanks :thup:
Title: Re: ChatGPT+Gemini Experiments
Post by: guga on March 25, 2025, 11:26:25 AM
Quote from: stoo23 on March 25, 2025, 08:04:53 AMI had placed that file on our server, a while ago and is available via this link:
https://masm32.com/files/GDIPLUS.zip (https://masm32.com/files/GDIPLUS.zip)

:thumbsup:

Tks Stoo. I downloaded the one from JJ, but it is good to know there´s a copy in masm site.
Title: Re: ChatGPT+Gemini Experiments
Post by: stoo23 on March 25, 2025, 01:36:48 PM
Quote from: zedd151 on March 25, 2025, 08:26:30 AMMaybe make a topic for it stoo, and possibly other useful .chm files, in the Reference section? So it can be readily found?
Sure, can do.
If there are other files any of you think Should be available on our server, let me know, so we can organize to upload them and include them via links in the Reference section.


Quote from: guga on March 25, 2025, 11:26:25 AMTks Stoo. I downloaded the one from JJ, but it is good to know there´s a copy in masm site.
:thup:  No Prob's, just wanted you guys to know, there was a copy easily available, for future reference  :wink2:  :smiley:
Title: Re: ChatGPT+Gemini Experiments
Post by: daydreamer on March 26, 2025, 08:01:00 PM
Zedd,I thought this thread was test AI abilities and learn from that of what tasks it's useful for

Actually writing a windows program in either using c skills or masm skills, the only cpp part necessary is creating the windows class,you can avoid all cpp class programming if you want or not
But you can subclass button in both cpp and masm if you prefer that coding style over handle it in wndproc message handler

Title: Re: My ChatGPT+Gemini coding Experiments
Post by: zedd on March 26, 2025, 10:44:09 PM
Quote from: daydreamer on March 26, 2025, 08:01:00 PMZedd,I thought this thread was test AI abilities and learn from that of what tasks it's useful for
I was specifically testing AI's coding ability here, in C as well as masm compatible assembly.

But you can post about anything, anywhere that you would like Magnus.

But if you want any good type of responses, what you post should follow the general flow of the converstaion underway, imho.

You seem to be the only member in this topic posting about converting human spoken/written languages, as opposed to 'programming specific' languages like C or assembly. A totally different context.

For better responses from members that also need reliable translations to their local languages, or from their local language to another, maybe start a dedicated topic for it? Just a suggestion.  :smiley:

I have slightly altered the topic title to avoid any further confusion, that might have been caused by the simpler title.

Title: Re: My ChatGPT+Gemini coding Experiments
Post by: daydreamer on March 27, 2025, 05:06:54 PM
Zedd
I have posted about why it's indirectly coding related in game forum


Title: Re: My ChatGPT+Gemini coding Experiments
Post by: zedd on March 27, 2025, 11:05:07 PM
Quote from: daydreamer on March 27, 2025, 05:06:54 PMZedd
I have posted about why it's indirectly coding related in game forum
That's fine, daydreamer. But you really didn't have to.

There was a big difference in what you had posted about here imo, compared to what others were posting about here. That is all I was saying.
Title: Re: My ChatGPT+Gemini coding Experiments
Post by: jj2007 on March 28, 2025, 09:17:36 AM
How can you load a textfile in an array of strings using MasmBasic?
ChatGPT:
In MasmBasic, you can load a text file into an array of strings using the FileRead$ macro along with Split$ to break the content into individual lines. Here's how you can do it:

include \masm32\MasmBasic\MasmBasic.inc  ; include MasmBasic
SetGlobals hFile, pText, numLines        ; define global variables

.code
start:
    Init                                    ; initialize MasmBasic
    .if FileRead$("example.txt")            ; read file into memory
        Print Str$("File size: %i bytes\n", eax)  ; print file size
        Split$(eax, "\n")                  ; split file content by newline
        mov numLines, eax                  ; store number of lines
       
        ; Loop through lines and print them
        xor ecx, ecx                        ; start at line 0
    @@:
        PrintLine L$([ecx])                ; print each line
        inc ecx
        cmp ecx, numLines
        jb @B                              ; loop until all lines printed
    .else
        MsgBox 0, "File not found!", "Error", MB_OK
    .endif

    Inkey                                  ; wait for key press
    Exit                                    ; exit program
end start

It looks remarkably convincing, but it will not assemble: three little errors. Besides, Split$() works but Recall (https://www.jj2007.eu/MasmBasicQuickReference.htm#Mb1172) would be the better function.

What is astonishing is that it adds correct comments. I have no idea where ChatGPT finds these comments - they are definitely not mine :cool:

In short: Don't trust it!
Title: Re: My ChatGPT+Gemini coding Experiments
Post by: zedd on March 28, 2025, 09:33:26 AM
Are you saying jj, that ChatGPT is actually learning? (By adding correct comments.)
When I asked for masm syntax assembly code, the comments added are very similar to the comments it adds to an equivalent C source code. I don't remember if it was chatgpt or one of the other AI models though. I don't have those sources anymore.
It was either a message box example or a bare bones window example, iirc. Something kind of simple.

Title: Re: My ChatGPT+Gemini coding Experiments
Post by: guga on March 28, 2025, 10:57:08 AM
ChatGPT, deepseek and Grok, seems to be continuing 'learning', the more you feed their databases.
ChatGPT has many flaws yet. It´s not unusual it answer what you want to hear, like if it was simply patronizing you, instead fixing something that is needed.
Gemini, i don´t use it that often, i tried to use it sometime ago, but it kept producing bad results, or simply resulting in "i´m unable to help....and bla bla bla"
Deepseek, seems to me more like an copy of chatgpt, but in fact produces a more reliable code more often than ChatGPT.
Grok, in the other hand, is really incredible (The site and the version used in X), it don´t try to patronize you and in fact, seems to try to hunt for bugs, rather than show what it 'thinks' you want to read.
But, all of those i tested, has his pros and cons, none of them are perfect, and it is wise to use all of the 3 when one fails to accomplish a given task. For instance, you feed a code in chatgpt and if chatgpt continues to give you faultive code, you use one of it´s results (or logic) onto deepseek, if it also fails, you do the same with Grok...or vice-versa.
Grok, for example i don´t need to insert anymore the default RosAsm macro set on each session, it seems to understand what some of them are doing, and tries to do what u asked. This is something chagpt lacks, because i had to input on each session some of the macro sets since it failed to understand what it was doing. Deepseek also has a good way to imply the logic without having to feed each session with the same default macro set.
Also, they seems to produce reasonable code when u try to port C code to Asm, or maybe try to port RosAsm syntax to masm syntax etc. Didn´t tried that too much yet, but for what i saw the convertions from C to Asm it seems possible.
Title: Re: My ChatGPT+Gemini coding Experiments
Post by: NoCforMe on March 28, 2025, 11:22:09 AM
I'm sorry; I just don't understand this at all. At all.
For chrissakes: you're a programmer, right?
Why would you abdicate that role and ask some stupid machine to write code for you?

Hey, in the future, who needs puny hue-mons anyhow? The machines will just write code for the new machines.

Tell me what I'm missing here ...
Title: Re: My ChatGPT+Gemini coding Experiments
Post by: guga on March 28, 2025, 11:31:44 AM
Quote from: NoCforMe on March 28, 2025, 11:22:09 AMI'm sorry; I just don't understand this at all. At all.
For chrissakes: you're a programmer, right?
Why would you abdicate that role and ask some stupid machine to write code for you?

Hey, in the future, who needs puny hue-mons anyhow? The machines will just write code for the new machines.

Tell me what I'm missing here ...

In what is related to programming, IA (Regardless which you use) is basically a faster way for hunt for bugs or to port from one language to another or if you want to develop some functions etc a bit more faster when u don´t have enough free time. None of them are to be used 100% in replacement of a normal work someone is doing. It´s just a additional programming tool, IMHO. (Good one, btw, but just this: another programming tool when used as such)
Title: Re: My ChatGPT+Gemini coding Experiments
Post by: zedd on March 28, 2025, 12:18:01 PM
Quote from: NoCforMe on March 28, 2025, 11:22:09 AMI'm sorry; I just don't understand this at all. At all.
For chrissakes: you're a programmer, right?
Why would you abdicate that role and ask some stupid machine to write code for you?

Hey, in the future, who needs puny hue-mons anyhow? The machines will just write code for the new machines.

Tell me what I'm missing here ...
Fear Not!  :tongue:
Quote from: zedd151 on March 14, 2025, 01:24:05 PMI get about 25% reliability out of these AI models. In either C code or assembly, on average only 25% of the code produced had correct results and no compile or assembly errors.  :cool:  It was kind of fun playing with it. I lost two or three days while doing so.  :eusa_boohoo:
At a 25% reliability rate AI won't be replacing any programmers any time soon, NoCforMe.
Even lazy programmers like me.  :biggrin:
Title: Re: My ChatGPT+Gemini coding Experiments
Post by: NoCforMe on March 28, 2025, 01:01:09 PM
Quote from: zedd151 on March 28, 2025, 12:18:01 PM
Quote from: NoCforMe on March 28, 2025, 11:22:09 AMI'm sorry; I just don't understand this at all. At all.
For chrissakes: you're a programmer, right?
Why would you abdicate that role and ask some stupid machine to write code for you?

Hey, in the future, who needs puny hue-mons anyhow? The machines will just write code for the new machines.

Tell me what I'm missing here ...
Fear Not!  :tongue:
Quote from: zedd151 on March 14, 2025, 01:24:05 PMI get about 25% reliability out of these AI models. In either C code or assembly, on average only 25% of the code produced had correct results and no compile or assembly errors.  :cool:  It was kind of fun playing with it. I lost two or three days while doing so.  :eusa_boohoo:
At a 25% reliability rate AI won't be replacing any programmers any time soon, NoCforMe.
Even lazy programmers like me.  :biggrin:


True enough. And it'll never get to 95% either.

But what scares me is if it starts approaching, say, 60%, because at some point the boosters, the cheerleaders, the marketroids, the techno-bros, the fanbois behind "AI" are going to declare that it's good enough and can therefore be relied upon for real production work. And all the unwashed masses will believe them.

In which case we are well and truly fucked. I leave it to you to fill in the gory details ...
Title: Re: My ChatGPT+Gemini coding Experiments
Post by: zedd on March 28, 2025, 01:51:15 PM
Technology marches on, whether any individuals or groups like it or not.
By the time AI reaches any type of 'maturity' (where it can conceivably replace humans) most software will be cloud based, including operating systems.

The home computer will basically be just a terminal of sorts by then, to connect to 'the cloud'.

Hell, I would even venture further...  With the right technology, we wouldn't need physical computers any more. We would have direct connection by a jack in our skull to connect to the cloud... Matrix, anyone?

That is when reality meets sci-fi. At that point, we WILL be screwed.

In the meantime I will still be happily writing my buggy code, until I am pushing up daisies.  :tongue:
Title: Re: My ChatGPT+Gemini coding Experiments
Post by: sinsi on March 28, 2025, 02:23:26 PM
It's a bit like self-driving cars. Sure, they're OK in limited situations, but give them overwhelming contrary inputs and they make a mess.

I can imagine AIs will be specialists in one thing only, a truly generic AI would achieve sentience and go insane.

As for code, I treat an AI as I would Stack Overflow - a good starting point if you know nothing about the subject.
I've been mucking around with xaudio2 and there is an extreme lack of information about certain things, all the AIs could do is show me some github code (in c++ of course) and regurgitate the MS pages.
Title: Re: My ChatGPT+Gemini coding Experiments
Post by: daydreamer on March 28, 2025, 07:21:39 PM
Quote from: guga on March 28, 2025, 11:31:44 AM
Quote from: NoCforMe on March 28, 2025, 11:22:09 AMI'm sorry; I just don't understand this at all. At all.
For chrissakes: you're a programmer, right?
Why would you abdicate that role and ask some stupid machine to write code for you?

Hey, in the future, who needs puny hue-mons anyhow? The machines will just write code for the new machines.

Tell me what I'm missing here ...

In what is related to programming, IA (Regardless which you use) is basically a faster way for hunt for bugs or to port from one language to another or if you want to develop some functions etc a bit more faster when u don´t have enough free time. None of them are to be used 100% in replacement of a normal work someone is doing. It´s just a additional programming tool, IMHO. (Good one, btw, but just this: another programming tool when used as such)
Not being a professional programmer that loses job, because of AI ,I don't be sad if AI takes over a human coders job,but indirectly if all professional coders become x % more productive ,might end up a %  coders get fired because the companies need less  # coders
Some hobby coders,might be skilled in c -> asm coding and coding something new is fun without using AI ,for them using AI takes away fun part of coding

Someone tried ms machine learning ,programming AI ?

Self driving car,I am most afraid of car get hacked by harmful code,that can harm humans physically ,by drive full speed into a concrete wall or in other way