In C here, _AX is a pseudo register. And when you do AX=1000
, this value 1000
is taken from the Accumulator
But it may not work as expected in GCC compiler
Compile and Run the following program in Turbo C, you will get 35 as output. It may not work in other compilers.
#include<stdio.h>
int main()
{
int a = 0;
a = 35;
printf("%d");
return 0;
}
Assume the address of a = 1200.
Assume the address of video memory = 5500;
MOV AH, 35
MOV [1200], AH
MOV [5500], AH // prints on the screen.
This is the way of execution takes place. After copying the value 35 to location 1200, AH retains the value 35.
Then printf("%d")
tries to get the value from AH and sends to video memory to display it on screen.
If we use printf("%d %d", age, salary)
, the value of age transfered to AH before using that value to send to video memory. Then the value of salary is moved to AH then send to video memory.
Assume,
Address of age = 1200;
Address of salary= 1202;
Address of video memory = XXXX; (It will changed according to no. of chars printed on the screen, dont think much about this address value)
MOV AH, [1200]
MOV [XXXX], AH
MOV AH, [1202]
MOV [XXXX], AH
I hope this will help to understand the solution for the given program.