Nasm working with glaciers



  • There's a c++ function.

    extern int** GetSubOrders(int* order);
    

    We need to put a body in a nasm assem module under ubuntu. The question is: how to work with the indexes in this case? i.e., get a order, get the meaning out of it, push the submassiums and return the index to the number of indexes? Interesting asm code, thank you.

    It's obvious that order is an address to the first element of the mass, but it's hard to get its meaning from the steak and so to make the whole body. Go back int** also through the glass, but there's only an address on the addresses that were in turn located somewhere in the variable, or do all the sub-mass addresses?



  • First need to be determined with https://ru.wikipedia.org/wiki/%D0%A1%D0%BE%D0%B3%D0%BB%D0%B0%D1%88%D0%B5%D0%BD%D0%B8%D0%B5_%D0%BE_%D0%B2%D1%8B%D0%B7%D0%BE%D0%B2%D0%B5 Like, take it. __fastcallthen, if int You have four bikes, then ecx = order♪ Then [ecx] - it's a zero element. You can start a cycle with some help. edie.g. by design [ecx + 4*edi] list all the elements of the mass. If you have a regime x64Not x86there are other agreements on challenges and the principle is somewhat different. If I remember correctly. https://msdn.microsoft.com/ru-ru/library/ms235286.aspx the first parameter is transmitted through rcxThen go rdxr8 and r9♪ It's the same way through. [rcx + 4*rdi]when rdi = 0, 1, 2 ...

    Trouble is the name of the function, you don't know it. It's possible to get a job done by making a mistake. When you start lining, there's a mistake that a function is something called какое-то-название defined but not implemented. (For example, in one of my projects, the name is so scary: ?add@AddAsm@@YIIPAIPBIII@Z, although the reference function was described AddAsm::add) That's the name and it's gonna have to be in the assembler code. Below the pseudocod (almost nasm) is similar to what you need (no more specific, because I don't give the level of specificity more than the specificity of the question). Speaking of which, extern No need.

    [BITS 32]
    

    global какое-то-название-функции ; Тут декларируется функция

    section .code

    какое-то-название-функции: ; Тут точка входа в функцию.
    push edi ; __fastcall обязан заботится о сохранении edi, esi и ebx

    xor edi, edi

    .loop:
    mov edx, [ecx + edi*4]
    ... Что-то делаем с edx ...
    lea edi, [edi + 1] ; ++ edi
    cmp edi, некое-число ; Сколько итераций нужно
    jne .loop

    pop edi

    mov eax, Бла-бла ; Это результат работы функции, передаётся через eax.

    ret 0 ; Выход без корректировки стека

    From this point of view, try to solve your task yourself.




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2