Ad
  • Custom User Avatar

    I wasn't familiar with brk. You should ask this question on CW Discord server, topics #asm channel. There's some clever people who should notice your question and answer.

  • Custom User Avatar

    The answer was not to use brk, in solutions there are only malloc and calloc implementations as well as in mine own. No one's solution uses bkr. And i dont know should it be issue or not?

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    Ah I forgot which kata this was. I haven't solved it in NASM, so I can't see your code, or what testing functions look like :/ When I tried NASM, I was too familiar with signal 6 and situations like yours :p

    You could try posting your code here for someone to analyze.

  • Custom User Avatar

    ; <-- [qword RAX] parts_sums([qword RDI] len, ro [qword RSI] ls, qword RDX n) --> No if im now trying to save pointer that came in the beginning from RDI
    and at the end of my code restore this pointer in rdi then it works and can see len in [rdi] but there is another problem now.
    For first case the answer is [ 20, 20, 19, 16, 10, 0 ] and i have exactly this array in rax but if im just ret it im getting
    Test Crashed Caught unexpected signal: 6 6 here is len or [rdi].
    And the MOST important is that if before ret
    if i do sub rax, 8 it doesnt error but returns [ 0, 20, 20, 19, 16, 10 ] that is definetly not the right answer
    and if im in opposite do add rax, 8 then it returns [ 20, 19, 16, 10, 0, 0 ] that is also dont error but not the right answer.
    I just CANT return the right answer because of the error. Also I have function to print nums from registers(does not affect them) and if i print [rax] it prints the right 20 and not anything else.

  • Custom User Avatar

    You probably don't want brackets around rdi, so you save value in the register directly.

  • Custom User Avatar

    How to sane len in NASM?
    Im having an error in NASM while saving len in [rdi].
    In C there is *len = <some number>; so in NASM its like mov [rdi], <some number>.
    But if im moving any value to [rdi] im getting:
    Test Crashed Caught unexpected signal: <some number>

  • Custom User Avatar

    Thanks, worked

  • Custom User Avatar

    the input matrix should be const-qualified in C:

    const int *const *matrix
    // or better yet, to emphasize that it is an array:
    const int *const matrix[];
    
  • Custom User Avatar

    the input is a matrix: int **, i.e. an array of 8-byte pointers to 4-byte int. [rdi] gives you the (address of the) first row of the matrix, not the first element of the first row

  • Custom User Avatar

    I dont get where array pointer in NASM.
    ; <-- RAX sumofmin(ro [qword [dword RDI]] nums, RSI rows, RDX cols) -->
    So [rdi] should be first item in array?
    I even did some function to print values in STDERR and everything worked fine but for [rdi].
    Code i did and even checked on my machine works and would here too i believe if i could get this array.

  • Custom User Avatar

    Yes ;-)

    The problem comes from your code. You ovewrite the previous best score in your hashMap as you iterate on the string. Try your code with e.g. "zzzaz": your code will return the score for "z", not "zzz".

    In the future, please use the question label to ask for help.

  • Custom User Avatar

    Please use the question label to ask for help, an issue is a provable bug within the kata. Your code has a bug, your second while statement keeps looping past the end of the string, which is undefined behavior.

  • Custom User Avatar

    in C all random tests passed yet all basic tests wrong. Why there is strange numbers when (int)(*str_in) instead of normal (on my PC the same code works)

  • Custom User Avatar

    expected [ [ [ 76, 97, -5, 29, -48, 31, 80, 57, +0 ], [ 76, 97, -5, 29, -48, 31, 80, 57 ] ], 317 ]
    to deeply equal [ [ [ 76, 97, -5, 29, -48, 31, 80, 57 ], [ 76, 97, -5, 29, -48, 31, 80, 57, +0 ] ], 317 ]

    genious