0

I want to print sum of two numbers in assembly. When I run the code, compiler shows the message:

INT 21h, AH=020h - not supported yet. refer to the list of supported interrupts.

Why do my code produce this error? What Interrupt code should I use?

.MODEL SMALL .STACK 100H .DATA A DW 5H B DW 2H SUM DW ? .CODE MAIN PROC MOV AX,@DATA MOV AX,A ADD AX,B MOV SUM,AX INT 21H MAIN ENDP END MAIN 
3
  • 2
    There are many things EMU8086 doesn't do yet, maybe future releases. Commented Apr 27, 2016 at 21:32
  • 3
    Your problem is that your using INT 21h without loading the number of the MS-DOS service you want to use into the AH register. So instead of invoking the service you want to use, it invokes whatever service happens to correspond to the value that happens to be in AH. Commented Apr 27, 2016 at 21:50
  • 1
    This is because you are using an emulator that doesn't support the feature you are attempting to use. Commented Apr 27, 2016 at 21:53

1 Answer 1

4

You have to load AH with the MSDOS function code that you want to use before calling the MSDOS interrupt.

For example, to print an ASCII character,

; assuming AL already contains ASCII character to print MOV AH, 07H INT 21H 

You are not loading a valid function code into AH. Where your compiler got 20H is a puzzle, but since you are loading @DATA into AX without doing anything with it (such as setting DS), I wonder if you are not pointing to the correct data segment on startup.

Note also that MSDOS never provided a conversion from a numeric value to a string, so you will have to convert the value yourself if you want to display it. I believe the function code to print a string is AH=09H, with DS:SI pointing to a '$'-delimited string (not null-terminated!). I suggest verifying that first though.

If you just want to print it in base-16, you can convert each 4-bit section to the corresponding printable ascii character for that hex digit, and then use function 07H to print the character, but remember, you start at the most significant 4 bits, and you will have to reload the value from sum for each 4-bit part since you will trash the rest of the value when you set up for the interrupt call.

Sign up to request clarification or add additional context in comments.

1 Comment

Good guess on the segment thing. I missed that he never did a mov ds, ax. I was thinking he must have posted code that didn't match what generated the error message, since 5 + 2 would leave AH = 0.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.