Writing a for loop in assembly from scratch

By : Paul
Source: Stackoverflow.com
Question!

Hello I am currently trying to learn assembly in c++ on my own. I have assembly code in my project that is currently in a high level c++ for loop, I need help converting this to be entirly assembly if possible, here is the code how I have it at the moment:

char temp_char;
for (int i = 0; i < length; i++){
    temp_char = characters [i];
    __asm {                         
        push eax    
        push ecx
        movsx ecx,temp_char
        movsx eax,key   
        push ecx    
        push eax
        call test
        add esp, 8
        mov temp_char,al
        pop ecx 
        pop eax
    }
}
By : Paul


Answers

Your for line has three parts to it. When thinking at the assembly level, it helps to break these apart. An easy way to do this is to re-write the for as a while:

char temp_char;

int i = 0;
while (i 
By : bta


This video can help you solving your question :)
By: admin