I am very new into assembly and this is a basic question.
I have just heard about the concept of using zero bytes of RAM.
I have compiled a C++ code via
g++ -O3 main.cpp -S -o main3.s
main.cpp (source)
#include <iostream>
using namespace std;
int main()
{
    int low=10, high=100, i, flag;
    cout << "Prime numbers between " << low << " and " << high << " are: ";
    while (low < high)
    {
        flag = 0;
        for(i = 2; i <= low/2; ++i)
        {
            if(low % i == 0)
            {
                flag = 1;
                break;
            }
        }
        if (flag == 0)
            cout << low << " ";
        ++low;
    }
    return 0;
}
And here is the result:
main3.s
    .file   "main.cpp"
    .section    .rodata.str1.1,"aMS",@progbits,1
.LC0:
    .string "Prime numbers between "
.LC1:
    .string " and "
.LC2:
    .string " are: "
.LC3:
    .string " "
    .section    .text.startup,"ax",@progbits
    .p2align 4,,15
    .globl  main
    .type   main, @function
main:
.LFB1561:
    .cfi_startproc
    pushq   %rbx
    .cfi_def_cfa_offset 16
    .cfi_offset 3, -16
    movl    $22, %edx
    movl    $.LC0, %esi
    movl    $_ZSt4cout, %edi
    call    _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
    movl    $10, %esi
    movl    $_ZSt4cout, %edi
    call    _ZNSolsEi
    movl    $5, %edx
    movq    %rax, %rbx
    movl    $.LC1, %esi
    movq    %rax, %rdi
    call    _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
    movq    %rbx, %rdi
    movl    $100, %esi
    movl    $10, %ebx
    call    _ZNSolsEi
    movl    $.LC2, %esi
    movq    %rax, %rdi
    call    _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
    .p2align 4,,10
    .p2align 3
.L6:
    movl    %ebx, %esi
    sarl    %esi
    testb   $1, %bl
    je  .L2
    movl    $2, %ecx
    jmp .L3
    .p2align 4,,10
    .p2align 3
.L14:
    movl    %ebx, %eax
    cltd
    idivl   %ecx
    testl   %edx, %edx
    je  .L2
.L3:
    addl    $1, %ecx
    cmpl    %esi, %ecx
    jle .L14
    movl    %ebx, %esi
    movl    $_ZSt4cout, %edi
    call    _ZNSolsEi
    movl    $1, %edx
    movl    $.LC3, %esi
    movq    %rax, %rdi
    call    _ZSt16__ostream_insertIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_PKS3_l
.L2:
    addl    $1, %ebx
    cmpl    $100, %ebx
    jne .L6
    xorl    %eax, %eax
    popq    %rbx
    .cfi_def_cfa_offset 8
    ret
    .cfi_endproc
.LFE1561:
    .size   main, .-main
    .p2align 4,,15
    .type   _GLOBAL__sub_I_main, @function
_GLOBAL__sub_I_main:
.LFB2045:
    .cfi_startproc
    subq    $8, %rsp
    .cfi_def_cfa_offset 16
    movl    $_ZStL8__ioinit, %edi
    call    _ZNSt8ios_base4InitC1Ev
    movl    $__dso_handle, %edx
    movl    $_ZStL8__ioinit, %esi
    movl    $_ZNSt8ios_base4InitD1Ev, %edi
    addq    $8, %rsp
    .cfi_def_cfa_offset 8
    jmp __cxa_atexit
    .cfi_endproc
.LFE2045:
    .size   _GLOBAL__sub_I_main, .-_GLOBAL__sub_I_main
    .section    .init_array,"aw"
    .align 8
    .quad   _GLOBAL__sub_I_main
    .local  _ZStL8__ioinit
    .comm   _ZStL8__ioinit,1,1
    .hidden __dso_handle
    .ident  "GCC: (Ubuntu 7.2.0-1ubuntu1~16.04) 7.2.0"
    .section    .note.GNU-stack,"",@progbits
This is a basic program which can store all variables into CPU registers. Therefore, I guess it does not use RAM. I would like to know what is the criteria to check if an assembly code is using RAM?
 
     
    