Sign in to follow this  
pmcastillo

My dollar sign problem and meaning of DB

Recommended Posts

MY DOLLAR SIGN PROBLEM AND MEANING OF DB I don't know what's wrong with my code here:
.MODEL TINY
.CODE
        ORG 0100H

MAIN:
        JMP START

        STRING1 DB "Enter Your Name: $"
        STRING2 DB "HELLO$"
        STRING3 DB 30, ?, 29 DUP (?)

START:
        ; =========== SHOW "ENTER YOUR NAME"
        MOV AH, 09H
        MOV DX, OFFSET STRING1
        INT 21H

        ; =========== ASK THE NAME
        MOV AH, 0AH
        MOV DX, OFFSET STRING3
        INT 21H

        ; =========== SHOW "HELLO"
        MOV AH, 09H
        MOV DX, OFFSET STRING2
        INT 21H

        ; =========== THIS IS WHERE THE PROBLEM STARTS
        MOV AH, 09H
        MOV DX, OFFSET STRING3
        INT 21H

        ;=========== TERMINATE THE PROGRAM
        INT 20H
        END MAIN
MAIN
The output sound be:
Enter Your Name: Paul Mark
HELLO Paul Mark
But it prints out gibberish things (much like "memory things"). But if put a dollar sign at the end "Paul Mark$", it will not show that gibberish things but the HELLO would overwrite the "Enter Your Name: " PLUS adding two symbols and then the name. 1.) Is there any way so that I don't need anymore to put a Dollar Sign at the end when inputting? 2.) What is that two symbols after the HELLO message? 3.) Is there any good Debugger that is compatible with Windows XP? Coz I tried to use Turbo Debugger 5.0, but it gave me Windows errors. MEANING OF DB And this:
        STRING3 DB 30, ?, 29 DUP (?)
Then followed a code like this:
        MOV AH, 09H
        MOV DX, OFFSET STRING3
        INT 21H
But I don't what's the whole "STRING3 DB 30, ?, 29 DUP (?)" means. All I know is that when I increase 30 & 29, my variable size increases. 4.) Why DB? They said it means Define Byte, but I'm inputting more than one byte. 5.) Why it needs three things? 30, ?, 29 6.) What is the meaning of "?"? 7.) What DUP do? DUP, they said it means DUPLICATE, but what things do I need to duplicate? I need also a thorough explanation about DB... [Edited by - Fruny on October 21, 2005 9:38:33 PM]

Share this post


Link to post
Share on other sites
Where are you getting this assembly from? It should explain what everything means. It's been a while since I did anything with MASM/TASM, but I believe that STRING3 DB 30, ?, 29 DUP (?) means you're declaring some bytes. You will have 30 bytes, the first one is unspecified, followed by 29 "duplications" of of the unspecified byte. At least that's what I recall '?' meaning. And '$' might mean the end of a string buffer to the interrupt. Look up the semantics of these interrupts online, and maybe that will clue you in on what might be wrong. I have a big purple assembly book at home that basically walks you through writing a hex editor in assembly, but I'm unfortunatley not at home.

Share this post


Link to post
Share on other sites
Wgen you use function 09h of int 21h, your string must be $ terminated. the gibberish that gets printed is only because the function print caracters until it get a $ and it never get one.

IIRC Zipster is right about the STRING3 DB 30, ?, 29 DUP (?) line.
I can't test it, but you could try this line instead and see if it works:
STRING3 DB 30 DUP ($)
I don't remember enough of my assembly class to teel you it'll work, but it's worth trying it.

good luck !

matchu

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this