The code that i am posting is Decompression data code and i was wonding if there was a way that i can change it into Compression data.
I have no clue where to start. Any ideas? Maybe an example? Anything would be greatly appreciated.
CODE
; rle_soln.asm
; sample program to demonstrate decompressing RLE
include 'emu8086.inc'
org 100h; set location counter to 100h
jmp CodeStart
DataStart:
; this is the run length encoded data
; notice that it is a list of words (bytes)
; with a zero on the end
rleData dw 1, 4, 3, 9, 5, 3, 2, 7, 0
space db ' ', 0
CodeStart:
; put the address of the first rle value in bx
mov bx, offset rleData
; start a loop that will visit each value in rle data
LoopStart:
; compare value in list with zer0
cmp [bx], 0
; if value was zero, must be end of list so quit
je EndLabel:
; move value in list to ax
;Moves bx into cx
mov cx, [bx]
;Adds 2 to bx
add bx, 2
;Moves bx into ax
mov ax, [bx]
;InnerLoop is used to jump if cx is greater than 0
InnerLoop:
; print it
call print_num
; print a space
mov si, offset space
call print_string
;Decrement cx by 1
sub cx, 1
;Compare cx to 0
cmp cx, 0
;Jumps to InnerLoop if cx is greater than 0
jg InnerLoop:
; add 2 bytes to the address in bx to move to the
; next value in the list
add bx, 2
; continue the loop until a zero is found
jmp LoopStart
EndLabel:
ret
DEFINE_PRINT_STRING
DEFINE_SCAN_NUM
DEFINE_PRINT_NUM
DEFINE_PRINT_NUM_UNS