0

I have a very easy program in assembly 8086 for university purpose. The main components are working, but when I want to display 2 or more strings I have some special character, impossible to understand output. These are my first tries in assembly so lots of errors are possible, but I cannot figure this out.

The program would be very simple: first display the message "Welcome to my triangle area calculator!" then display "Do you want another try? y-yes n-no" and depending on the key pressed you can retry it or finish the program. Here is my code:

DATA SEGMENT PARA PUBLIC 'DATA'

WELCOME DB "Welcome to my triangle area calculator!$";welcome message

CONTINUE DB "Do you want another try? y-yes n-no$";other message

DATA ENDS


CODE SEGMENT PARA PUBLIC 'CODE'

ASSUME CS:CODE, DS:DATA

MAIN PROC FAR

MOV DX,OFFSET WELCOME;load the address of the welcome message in dx

MOV AH,09H; instruction for display

INT 21H; interrupt for display

XOR DX,DX; putting dx back to 0

XOR AX,AX; the same for ax

START:;loop label

MOV DX,OFFSET CONTINUE;loads the address of the other message into dx

MOV AH,09H; display intruction

INT 21H; interrupt for display

MOV AH,01H; character input instruction

INT 21H; interrupt for input

CMP AL,79H; comparison if the inputted character is y

JZ START; jump zero if it is

CMP AL,6EH; comparison if the inputted character is n

JZ FINISHPROGRAM; jump zero to finish the program

FINISHPROGRAM:

MOV AH,4CH; dos program ending

INT 21H

RET

MAIN ENDP

CODE ENDS

END MAIN
6
  • Maybe you should describe what the error is??
    – Hot Licks
    Dec 30, 2013 at 18:29
  • And you'd help yourself and us if you added comments stating what each of the system calls is -- it's been decades since many of us have looked a this sort of thing.
    – Hot Licks
    Dec 30, 2013 at 18:30
  • No compilation error, nothing and when the program runs displays me a bunch of special characters, then the welcome message and in place of the other message displays the welcome message once again. Dec 30, 2013 at 18:34
  • Done with editing, now there are comments. Dec 30, 2013 at 18:39
  • 1
    You say assume ds:data but you don't make it so. Dec 30, 2013 at 18:54

1 Answer 1

0

try this......

.model small
.data

welcome db 10,13,"Welcome to my triangle area calculator!$"
continue db 10,13,"Do you want another try? y-yes n-no$"

.code
       mov dx,@data
       mov ds,dx

start: lea dx,welcome
       mov ah,09h
       int 21h

       lea dx,continue
       mov ah,09h
       int 21h

       mov ah,01h
       int 21h

       cmp al,'y'
       je start
       mov ah,4ch
       int 21h
end

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.