While direct Language-Assembly compilers generate the code required to perform specific task for the given platform, how do interpreters do it?
The following pseudo-code...
...would compile to this assembly language code.
org 100h mov dx,msg mov ah,9 int 21h mov ah,4Ch int 21h msg db 'Hello, World!',0Dh,0Ah,'$'
I would like to take Python as an example. In CPython we have a
PRINT_ITEM VM instruction. Then we have a
print() function which (sic!) I believe calls directly or not the print statement, I may be wrong. But then does it mean that we cannot do something without implementing it before in the VM's source code? How does then Python/other interpreted languages implement more complex functions like writing data to file? Does it mean that really all of the standard library/basic functionality has to be implemented in the VM's code.
What is called when we want to write the data to the file? There is no direct VM instruction for that in CPython. Does it then call some method which is defined in the CPython's C code? Or maybe the C code exposes just some streams which enable that to the interpreted code?
I hope you can understand what I mean.