Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
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.
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?
This comment is hidden because it contains spoiler information about the solution
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.
; <-- [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 RDIand 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 inrax
but if im justret
it im gettingTest 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 answerand 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.
You probably don't want brackets around rdi, so you save value in the register directly.
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 likemov [rdi], <some number>
.But if im moving any value to
[rdi]
im getting:Test Crashed Caught unexpected signal: <some number>
Thanks, worked
the input matrix should be
const
-qualified in C:the input is a matrix:
int **
, i.e. an array of 8-byte pointers to 4-byteint
.[rdi]
gives you the (address of the) first row of the matrix, not the first element of the first rowI 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.
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.Please use the
question
label to ask for help, anissue
is a provable bug within the kata. Your code has a bug, your secondwhile
statement keeps looping past the end of the string, which is undefined behavior.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)
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