flat assembler
Message board for the users of flat assembler.

Index > DOS > Simple question

Author
Thread Post new topic Reply to topic
slovach



Joined: 14 May 2007
Posts: 4
slovach
I'm pretty ASM retarded, but I've been goofing with it lately since I'm interested in ultimately getting a better understanding of things.

Code:
org $0100
use16

mov     ah, $02

print:
        mov     dl, [hello + bx]
        int     $21
        inc     bx
        cmp     bx, 5
        jne     print

int     $20

hello db 'hello', $24    


What's a smarter way of counting, so I don't have to do it myself? I'm used to sizeof() being available.

Feel free to tell me if I'm doing anything stupid / if anything can be bettered.
Post 30 Jul 2008, 05:01
View user's profile Send private message Reply with quote
Kenneth



Joined: 16 Nov 2005
Posts: 38
Location: United States of America
Kenneth
Code:
org $0100
use16

mov     ah, $02

print:
        mov     dl, [hello + bx]
        int     $21
        inc     bx
        cmp     bx, hello.size
        jne     print

int     $20

hello db 'hello', $24
hello.size = $ - hello  ;current offset - address of hello
    

Or you can just use this
Code:
struc db [bytes]
{
common
  . db bytes

.size = $ - .
}     
Post 30 Jul 2008, 05:25
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
DOS386



Joined: 08 Dec 2006
Posts: 1901
DOS386
slovach wrote:

Code:
hello db 'hello', $24    

What's a smarter way of counting


1. Why the $24 -> dollar "$" ? Do you want to see "hello$" ??? Confused

PS: prefixing hex numbers with dollar is good Smile

2.

Code:
txhello db 'hello', 0    


and compare against 0 before printing the char Idea
Post 23 Aug 2008, 07:33
View user's profile Send private message 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 YouTube, Twitter.

Website powered by rwasa.