basic construct in c,.... languages
for (index =start_value; index< end_value; (pre/post) inc/dec(index))
like
for (i = 0; i< 10; i++) , ( i=10,i>0;i--) , (i=35; i> 25; --i) ,(i=35; i< 25; ++i)
the compiler takes this human readable code and converts it into assembly for the specific platform
for x86 this could look like
mov end_value to another register like mov edx,10
mov index to a register like mov,ecx,0
body {
do anything but preserve ecx,edx
}
inc/dec regsiter ecx
compare ecx with edx,
do an if < or > decision and either go back to doing the body or exit
a real world example
int main (void) {
register int a =4;
for (register int i =3; i<10; i++){
a = a + i*2;
}
return a;
}
compiled and disassembled using vs and windbg
:\>ls
loopy.cpp
:>cl /Zi /W4 /analyze:autolog- /Od /EHsc /nologo -GS loopy.cpp /link /release /subsystem:windows /entry:main /fixed
loopy.cpp
:>ls
loopy.cpp loopy.exe loopy.obj loopy.pdb vc140.pdb
disassembly of compiled code
:\>cdb -c "uf loopy!main;q" loopy.exe | awk "/Reading/,/quit/"
0:000> cdb: Reading initial command 'uf loopy!main;q'
loopy!main:
00000000`00401000 55 push rbp
00000000`00401001 8bec mov ebp,esp
00000000`00401003 83ec08 sub esp,8
=====================
memory location instead of register used
00000000`00401006 c745f804000000 mov dword ptr [rbp-8],4
00000000`0040100d c745fc03000000 mov dword ptr [rbp-4],3
=====================
00000000`00401014 eb09 jmp loopy!main+0x1f (00000000`0040101f)
loopy!main+0x16:
0000000000401016 8b45fc mov eax,dword ptr [rbp-4] increment ================== 00000000
00401019 83c001 add eax,1
00000000`0040101c 8945fc mov dword ptr [rbp-4],eax
loopy!main+0x1f:
============ comparison and decision
000000000040101f 837dfc0a cmp dword ptr [rbp-4],0Ah 00000000
00401023 7d0e jge loopy!main+0x33 (0000000000401033) ============== body loopy!main+0x25: 00000000
00401025 8b4dfc mov ecx,dword ptr [rbp-4]
0000000000401028 8b55f8 mov edx,dword ptr [rbp-8] 00000000
0040102b 8d044a lea eax,[rdx+rcx*2]
000000000040102e 8945f8 mov dword ptr [rbp-8],eax 00000000
00401031 ebe3 jmp loopy!main+0x16 (0000000000401016) =========== body end goes back to re doing again ================ exit loopy!main+0x33: 00000000
00401033 8b45f8 mov eax,dword ptr [rbp-8]
0000000000401036 8be5 mov esp,ebp 00000000
00401038 5d pop rbp
00000000`00401039 c3 ret
quit:
in laymans terms
this assembly is now further converted to binary (base 2 ,or 0,1) and fed into a network of logic gates which use and , or , not , nand ,xor, xnor circuitry to do the actual work
so simply a not gate might return false or true based on the input of index 0b101 versus 0b1000
if you need the basic electronics and logic gate circuitry you should look for electronics stack exchange
you can also check online logic simulators like this

for
andwhile
loops. I do not know how to do this. Given this is site is focused on reverse engineering, I assumed it would be appropriate to ask my question here. Do you have any suggestions on how I should edit my question? – Michael Sodeke Dec 02 '21 at 20:34for
andwhile
loops? If so, you'd have to give the language at least some reference to find a sample and an interpreter for said language. Are you asking conceptually how one would implement such a thing? In that case it's not reverse engineering at all. Please edit the details into your question and then vote to Reopen (link right under your question) – 0xC0000022L Dec 16 '21 at 09:38