As part of my project which is an RPN calculator with unlimited precision, I'm trying to write a method to take in a buffer with size of at most 80bytes. Since I wanna support unlimited precision(or at least limited by only the heap size), I wanna take in that buffer and create a pointer that points to the head of a linked list that will represent the number, so for example if the input inside the buffer is : 0x7D12AF
Then the linked list generated by that input will look something like :
[AF, addr1] -addr1->[12, addr2] -addr2-> [7D, addr3] -addr3-> 0
where each link is 5 bytes, 4 for the pointer to the next link, and one byte for the data. Here's my shot at it, I'd take any suggestion since I'm really not sure about what I'm doing: (assume atoi takes in a hex digit and converts it to a numeric value)
`section .bss
        ptr: resb 5
 section .data
setcion .text
align 16
extern malloc
_buffersize
    push ebp
    mov ebp, esp
    mov ecx, [ebp+8]
_buffersize:
    push ebp
    mov ebp, esp
    push ecx
    mov ecx, [ebp+8]
    xor eax, eax
    .loop:
        cmp [ecx], 20h
        jle .done
        inc ecx
        inc eax
        jmp .loop
    .done:
        pop ecx
        mov esp, ebp
        pop ebp
        ret
_listify:
    push ebp
    mov ebp, esp
    mov edx, [ebp+8]                ; pointer to the first byte in the number_string
    pushad
    push edx                        ; push function argument
    call _buffersize                ; eax now holds the size of the buffer 
    add esp, 4                      ; clean up stack after call
    mov ecx, eax                    ; count for the loop
    .loop:
        pushad                      ; allocate 5 bytes for a node : 4 for a next ptr, 1 for data
        push 5
        call malloc                 ; eax now points to the 5 bytes allocated
        add esp, 4                  ; clean up stack after call to malloc
        mov [ptr], eax              ; now ptr points to the address in memory of the 5 allocated bytes 
        popad
        push [edx]                  ; push the first byte pointed to by edx as an argument for atoi (atoi converts a signle HEX digit to it's numeric value)
        call _atoi
        add esp, 4                  ; eax now holds the numeric value of that 1 byte character
        mov ebx, [ptr]              ; ebx points to the allocated memory
        mov [ebx], dword 0          ; the address of the next link is NULL as we're insterting at the head of the lsit
        mov [ebx], byte eax         ; hopefully, ebx should now points to 5 bytes in memory of the form [b4b3b2b1b0] where b4b3b2b1 is the address of the next link & b0 is a 0 <= number <16
        mov [ptr], ebx              ; now ptr points to the address of the newly updated linked list representing the number
        inc edx                     ; get ready to read next byte
       loop .loop  
    popad
    mov esp, ebp
    pop ebp
    ret
`
also another question I have is : is there a way to store number in its hex representation? I think it's kind of a stupid question because the representation is just how I look at it but the value is the same .. so converting a hex digit ASCII representation to an int is just the same, and to make hex I should just treat it that way when converting from char to int and vice versa.. please correct me if I'm wrong. Thanks!
 
    