NASM - Selecting multiple values to output different string lengths

32 views Asked by At

I'm trying to use run length encoding to output multiple, different length, strings. I can output one string, but as soon as I try to modify the code so that multiple strings are output I only get errors. This code below works as expected and allows me to change the values in rle or movement successfully to control the start point and lenght of the string. What I want to do is to be able to read multiple values from rle and then use these to output strings of different lengths. However if I add more than one value to rle (such as rle, dw 2,7,0) I get no output. Likewise if I dont have the zero (such as rle dw 2) I get no output. This code is part of a larger bit of code, all of which works, and this is just the essential part where my issue exists.

section .text

global _start

_start:

    mov     ecx, stars          ; load the output data string into ecx
    mov     edx, dword[rle]     ; define string output length (initially 2)
    mov     eax, 0x4            ; set output type as sys_write
    inc     ecx                 ; move along one position (so go from B not A)
    inc     ecx                 ; move along one position (so go from C not B)
    mov     ebx, dword[movement] ; get the value from movement (1 the first time)
    add     edx, ebx            ; add 1 (ebx via movement) to 2 (edx from rle) >> 3
    mov     ebx, 1               ; now set ebx for printing
    int     80h
    
section .data

    stars db "ABCDE",0
    rle dw 2,0;
    movement dw 1,0,-1,0;
   
segment .bss

I've tried all types of different rle data. Only where I have the initial length (2) followed by a zero terminator does it work successfully (outputs CDE in this example).

What I was expecting was that if I added more comma seperated values into rle, I would be able to point at them and then use those values to control my output length.

0

There are 0 answers