Name: Anonymous 2008-12-13 17:09
Hello, /prog/. I'm trying to decompress some rle data in this program using a nested inner loop. There's more than one way to do it, but I'm having trouble going in the right direction. Could anyone give me some help/advice as to what I should start with concerning the nested inner loop? Thanks.
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, over 9000, 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
mov ax, [bx]
; print it
call print_num
; print a space
mov si, offset space
call print_string
; 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
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, over 9000, 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
mov ax, [bx]
; print it
call print_num
; print a space
mov si, offset space
call print_string
; 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