codeWarrior456
Technical User
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
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