-3

I have to write a program in assembly which would compare two numbers. I do not have any skills with this language, so help me please. You should enter two numbers and then the program must write: "X is bigger" or "Y is bigger". X and Y are inputs.

Seva Alekseyev
  • 59,826
  • 25
  • 160
  • 281
user2988928
  • 1
  • 1
  • 1
  • 1
  • Homework, I presume. Otherwise, why would you want to code in a notoriously hard language that you don't know. Anyway, what's the platform and CPU - DOS, Linux, Windows/Intel, ARM, MIPS? – Seva Alekseyev Nov 13 '13 at 18:07
  • 4
    As you `have to wirte a program in assembly which compare two numbers` but you `do not have any skills with this language` there's a rather serious problem that can only be solved by acquiring some skills in that language, which is I think the real goal of whoever gave you this task. – fvu Nov 13 '13 at 18:09

1 Answers1

0

Check this one:

.8086
.MODEL SMALL
.DATA
  CHAR DB " "
  MESSAGE1 DB 0AH,0DH,'****X IS GREATER THAN Y****','$'
  MESSAGE2 DB 0AH,0DH,'****Y IS GREATER THAN X****','$'
  MESSAGE3 DB 0AH,0DH,'****ALL ARE EQUAL****','$'

  INPUT_M DB 0AH,0DH,'ENTER CHARACTER',0DH,0AH,'$'
.CODE
  MAIN PROC
    MOV AX,@DATA
    MOV DS,AX

    MOV DX,OFFSET INPUT_M
    MOV AH,09
    INT 21H

    MOV AH,01
    INT 21H

    MOV CHAR,AL
    MOV DX,OFFSET INPUT_M

    MOV AH,09
    INT 21H

    MOV AH,01
    INT 21H

    CMP CHAR,AL
    JE  EQUAL
    JGE GREAT

    MOV DX,OFFSET MESSAGE2
    JMP PRINT
EQUAL:  MOV DX,OFFSET MESSAGE3
    JMP PRINT
    GREAT:  MOV DX,OFFSET MESSAGE1
PRINT:  MOV AH,09
        INT 21H
    MOV AH,4CH
    INT 21H
  MAIN ENDP
    END MAIN
Shreyos Adikari
  • 12,348
  • 19
  • 73
  • 82
  • 1
    Presumes DOS on x86. That's not a given. – Seva Alekseyev Nov 13 '13 at 18:17
  • 1
    Please read [this](http://meta.programmers.stackexchange.com/questions/6166/open-letter-to-students-with-homework-problems) and [this](http://meta.stackexchange.com/questions/10811/how-do-i-ask-and-answer-homework-questions/10812#10812) - providing readymade homework solutions does a disservice to the student in the long run. – fvu Nov 13 '13 at 18:19
  • Ok sorry then. Should I remove the answer? – Shreyos Adikari Nov 13 '13 at 18:20
  • That's up to you, maybe read the links I gave for some guidance for this and future "I'm too lazy to study the stuff I'm supposed to study" cases? Just think of it this way : soon these people may be your colleagues, are you going to do their work for them? – fvu Nov 13 '13 at 18:25
  • First thank you for your answer.I would be very happy if you give me any web source about assembly for begginers.I wish to know something for assebmly but i can not understand information in school. – user2988928 Nov 13 '13 at 18:29
  • @user2988928 Start here http://stackoverflow.com/questions/1932449/beginners-assembly-language for some mostly x86 related links. – fvu Nov 13 '13 at 18:37