Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple Assembly Programs gone astray -- Please help

Status
Not open for further replies.

codeWarrior456

Technical User
Oct 27, 2002
27
US
I have to write two assembly programs for a class and I am stuck on them. The first program that I have to write has to take in a number 1-4 and then another number 1-4. Then it needs to add the two numbers together and print out the sum.

The second program has to prompt for a name. Then it needs to print out a greeting followed by the name entered.

The following is what I have so far. I would appreciate it if anyone could offer advice as to what I may be doing wrong. Thanks.

Part 1
C:\WINDOWS\Desktop>debug
-e 200 "Please enter a number (1-4): $"
-a
MOV AH,06 ;clear screen
MOV AL,00
MOV CH,00
MOV CL,00
MOV DH,18
MOV DL,4F
MOV BH,07
INT 10
MOV AH,09 ;prompt for input
MOV DX,200
INT 21
MOV AH,01 ;get input
MOV [0220],AX
INT 21
MOV AH,02
MOV DL,0A
INT 21
MOV DL,0D
INT 21
MOV AH,09 ;prompt for second number
MOV DX,200
INT 21
MOV AH,01 ;get second input
MOV [0221],AX
INT 21
ADD AX,221
MOV AX,222
MOV AH,02
MOV DL,0A
INT 21
MOV DL,0D
INT 21
MOV DL,[222]
ADD DL,30 ;allows numbers to be correctly added
INT 21
INT 20

Part 2

C:\WINDOWS\Desktop>debug
-e 300 "Please enter your first name: $"
-e 400 "Welcome, "
-e 500 0A 0D 24
-a
MOV AH,06 ;clear screen
MOV AL,00
MOV CH,00
MOV CL,00
MOV DH,18
MOV DL,4F
MOV BH,07
INT 10
MOV AH,09 ;print prompt
MOV DX,300
INT 21
MOV AH,0A ;get buffered input
MOV DX,0200 ;memory location buffered input is being stored at
INT 21
MOV CX,[0201]
MOV CH,00
MOV AH,02 ;print a blank line
MOV DL,0A
INT 21
MOV DL,0D
INT 21 ;end of print blank line instructions
MOV SI,0202
MOV DL,[SI]
INT 21
INC SI
LOOP 0131
INT 20
 
You didn't say what kind of error you got, but one visible error from the code above will be from the Print String Function 09H

You entered your string between double quote and this is Assembly language Unforgivable crime.

Use single quote with the function 09H Walid Magd
Engwam@Hotmail.com
 
Actually... You can use a double quote when entering data into memory. I was able to figure out the problems. In case anyone is interested, this is how the two programs are done:

1691:0100 B406 MOV AH,06
1691:0102 B000 MOV AL,00
1691:0104 B500 MOV CH,00
1691:0106 B100 MOV CL,00
1691:0108 B618 MOV DH,18
1691:010A B24F MOV DL,4F
1691:010C B707 MOV BH,07
1691:010E CD10 INT 10
1691:0110 B409 MOV AH,09
1691:0112 BA0002 MOV DX,0200
1691:0115 CD21 INT 21
1691:0117 B401 MOV AH,01
1691:0119 CD21 INT 21
1691:011B A20003 MOV [0300],AL
1691:011E B402 MOV AH,02
1691:0120 B20A MOV DL,0A
1691:0122 CD21 INT 21
1691:0124 B20D MOV DL,0D
1691:0126 CD21 INT 21
1691:0128 B409 MOV AH,09
1691:012A BA0002 MOV DX,0200
1691:012D CD21 INT 21
1691:012F B401 MOV AH,01
1691:0131 CD21 INT 21
1691:0133 A20004 MOV [0400],AL
1691:0136 B402 MOV AH,02
1691:0138 B20A MOV DL,0A
1691:013A CD21 INT 21
1691:013C B20D MOV DL,0D
1691:013E CD21 INT 21
1691:0140 B402 MOV AH,02
1691:0142 8A160003 MOV DL,[0300]
1691:0146 02160004 ADD DL,[0400]
1691:014A 80EA30 SUB DL,30
1691:014D CD21 INT 21
1691:014F CD20 INT 20

Part 2
1691:0100 B406 MOV AH,06
1691:0102 B000 MOV AL,00
1691:0104 B500 MOV CH,00
1691:0106 B100 MOV CL,00
1691:0108 B618 MOV DH,18
1691:010A B24F MOV DL,4F
1691:010C B707 MOV BH,07
1691:010E CD10 INT 10
1691:0110 B409 MOV AH,09
1691:0112 BA0002 MOV DX,0200
1691:0115 CD21 INT 21
1691:0117 B40A MOV AH,0A
1691:0119 B1FF MOV CL,FF
1691:011B 880E0004 MOV [0400],CL
1691:011F BA0004 MOV DX,0400
1691:0122 CD21 INT 21
1691:0124 B402 MOV AH,02
1691:0126 B20A MOV DL,0A
1691:0128 CD21 INT 21
1691:012A B20D MOV DL,0D
1691:012C CD21 INT 21
1691:012E B409 MOV AH,09
1691:0130 BA0003 MOV DX,0300
1691:0133 CD21 INT 21
1691:0135 BE0104 MOV SI,0401
1691:0138 46 INC SI
1691:0139 8A14 MOV DL,[SI]
1691:013B 80FA0D CMP DL,0D
1691:013E 75F8 JNZ 0138
1691:0140 B124 MOV CL,24
1691:0142 880C MOV [SI],CL
1691:0144 B409 MOV AH,09
1691:0146 BA0204 MOV DX,0402
1691:0149 CD21 INT 21
1691:014B CD20 INT 20
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top