in reply to Re^2: Assembly language
in thread Assembly language
The interesting thing about this particular asm code is that it will only run on 64-bit Intel and AMD microprocessors. It will not run on a 32-bit CPU. And it will not run on ARM, SPARC, or old iMac processors!
On the other hand, the print "Hello World"; perl equivalent of this program is not bound to one particular architecture or one particular OS. It would run on any CPU and any OS.
To further prove my point, if you would run an assembler to convert this asm text code to an obj file and then link the obj into exe file, it would result in a Windows executable. If you tried to run it in Linux, it wouldn't run (without wine). If you tried to execute it on an Apple MacBook Pro, it wouldn't run. It wouldn't run even if you included it in your perl script inline. This code is not only machine specific, but it is OS specific. That's what I meant. It's a fact. Try it if you don't believe me.
A simple print "Hello World" perl script will run on any computer, but once you insert asm code into your perl script as inline assembly, chances are you have limited your perl script to one particular processor and one particular OS! Now, your perl script is no longer compatible with 90% of other computers out there. But if you omit the inline assembly code, then it will run on other computers.
section .data Message db "Hello World", 0Dh, 0Ah MessageLength EQU $-Message section .text Start: sub RSP, 8 sub RSP, 32 mov ECX, STD_OUTPUT_HANDLE call GetStdHandle mov qword [REL StandardHandle], RAX add RSP, 32 sub RSP, 32 + 8 + 8 mov RCX, qword [REL StandardHandle] lea RDX, [REL Message] mov R8, MessageLength lea R9, [REL Written] mov qword [RSP + 4 * 8], NULL call WriteFile add RSP, 48 xor ECX, ECX call ExitProcess
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Assembly language
by haukex (Archbishop) on Dec 15, 2019 at 11:54 UTC | |
by harangzsolt33 (Deacon) on Dec 15, 2019 at 15:51 UTC | |
by Anonymous Monk on Dec 15, 2019 at 19:20 UTC | |
|
Re^4: Assembly language
by Anonymous Monk on Dec 15, 2019 at 12:41 UTC |