flat assembler
Message board for the users of flat assembler.

Index > Main > problem with printing array data

Author
Thread Post new topic Reply to topic
majidkamali1370



Joined: 31 Oct 2010
Posts: 50
Location: Iran
majidkamali1370
Hi.
Here's my code:
Code:
org 100h
jmp start

include "0Header.inc"

arraydata db 5 dup ("Hello!")

start:
        mov si, 0
        forLoop:
                PrintChar [arraydata + si]
                inc si
                cmp si, 30  ; <-- commented line
                jb forLoop
int 20h
    


PrintChar is defined in 0Header.inc file like below:
Code:
macro PrintChar ch
{
        pusha
        mov dl, ch
        mov ah, 2h
        int 21h
        popa
}
    


when I add
Code:
size db $ - arraydata    
below arraydata definition and change commented line with this,
Code:
cmp si, size    
, it prints some bullshit after printing array data. I don't know where it comes from.

What's the problem?

Thanks and excuse Very Happy
Post 19 Nov 2011, 18:32
View user's profile Send private message Send e-mail Yahoo Messenger ICQ Number Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1288
Location: Paradise Falls
Picnic
majidkamali1370 wrote:

when I add
Code:
size db $ - arraydata    
below arraydata definition and change commented line with this,
Code:
cmp si, size    
, it prints some bullshit after printing array data. I don't know where it comes from.

What's the problem?


Hi,
You compare si value with size address.


Try this
Code:
   arraydata db 5 dup ("Hello!") 
   size = $ - arraydata
   ;
   ;
   ;
   cmp si, size 
    


or this

Code:
   arraydata db 5 dup ("Hello!") 
   size dw $ - arraydata
   ;
   ;
   ;
   cmp si, [size]
    


Last edited by Picnic on 19 Nov 2011, 19:50; edited 1 time in total
Post 19 Nov 2011, 19:29
View user's profile Send private message Reply with quote
majidkamali1370



Joined: 31 Oct 2010
Posts: 50
Location: Iran
majidkamali1370
Thanks
Post 19 Nov 2011, 19:47
View user's profile Send private message Send e-mail Yahoo Messenger ICQ Number Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.