-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.

2
  • 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? Nov 13, 2013 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, 2013 at 18:09

1 Answer 1

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
6
  • 1
    Presumes DOS on x86. That's not a given. Nov 13, 2013 at 18:17
  • 1
    Please read this and this - providing readymade homework solutions does a disservice to the student in the long run.
    – fvu
    Nov 13, 2013 at 18:19
  • Ok sorry then. Should I remove the answer? Nov 13, 2013 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, 2013 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. Nov 13, 2013 at 18:29

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.