CLEO Help HELP - reading a string

CLEO related
Status
Not open for further replies.

shanker

Well-known member
Joined
Sep 18, 2016
Messages
291
Reaction score
16
Location
Romania
@monday

let's think I have the following string:

alloc 0@ = 260
format 0@ = "me3r3 co0apt3"

i want to read char by char from it to output only letters
so the output should be: 3303

how can i do that?
 
Last edited:

Parazitas

God
Joined
Jan 2, 2017
Messages
3,112
Solutions
5
Reaction score
878
Location
Lithuania
Easy

PHP:
{$CLEO}

0000:

wait 8500

0AC8: 0@ = allocate_memory_size 260
0AD3: 0@ = format "me3r3 co0apt3"

0AC8: 1@ = allocate_memory_size 260
0AB1: call_scm_func @get_digits_to_print param_count 2 text 0@ memory_to_store_digits_as_text 1@
0AD1: "%s" 1337 1@
0A93: end_custom_thread

:get_digits_to_print
{
    0@ = text
    1@ = pointer to memory where digits will be stored as text
}
0C17: 31@ = strlen 0@
    for 30@ = 0 to 31@   
        0085: 29@ = 0@ // copy pointer
        005A: 29@ += 30@  // add offset (as the loop progresses it becomes pointers to first-last character)
        0A8D: 28@ = read_memory 29@ size 1 virtual_protect 1 // 28@ is the ascii number representing character
        if and
        28@ >= 0x30 // '0'
        28@ <= 0x39 // '9'
        then
        0A8C: write_memory 1@ size 1 value 28@ virtual_protect 1
        1@ += 1 // move to next address
        end
    end
0A8C: write_memory 1@ size 1 value 0 virtual_protect 1 // null-termination  
0AB2: ret 0
 
Status
Not open for further replies.
Top