assembly - How to read text from a file in NASM and get each line comma seperated? -
assembly - How to read text from a file in NASM and get each line comma seperated? -
okay i'm working on project based on mikeos , i'm attempting comma separated list text file. illustration if text file had "hello" on line 1 "world" on line 2 , "!" on line 3, want homecoming of "hello,world,!" possible, , if how can it. im relatively new nasm have basic understanding of it. help appreciated :d
pop si force si mov bx, si mov ax, si phone call os_string_length mov si, bx add together si, ax dec si dec si dec si mov di, txt_ext mov cx, 3 rep cmpsb jne bad extension pop si mov ax, si mov cx, 32768 phone call os_load_file phone call os_clear_screen
(at point in code text file loaded ram, want retrieve comma separated list mentioned utilize in list box)
given comments assume have basic knowledge of assembly in general, let's start c code. have loaded file somewhere ram, have create comma-separated list replacing newlines commas; in code:
void to_list(char *text) { while(*text != '\0') { if(*text == '\n') *text = ',' text += 1; } }
now, long time has passed since have lastly programmed in x86 assembly, line-to-line translation along lines of:
to_list: ; text passed in si register pusha mov bl, 2ch ; ascii code ',' to_list_loop: mov al, [si] ; load character cmp al, 0 ; end of string? je to_list_ret cmp al, 0dh ; newline? jne to_list_inc mov [si], bl ; if yes, replace comma to_list_inc: inc si ; , go next character jmp to_list_loop to_list_ret: popa ret
assembly text-files nasm
Comments
Post a Comment