(20)
http://hironemu.hatenablog.com/entry/20090210/1234279094
apt install nasm
nasm --version
vim hello.asm
section .text
global _start
msg db 'Hello world!', 0x0A
msglen equ $ - msg
_start:
mov ecx, msg
mov edx, msglen
mov eax, 4
mov ebx, 1
int 0x80
mov eax, 1
mov ebx, 0
int 0x80
nasm -f elf64 hello.asm
ld -s -o hello hello.o
./hello
(10)
apt install nasm
nasm --version
vim hello.asm
section .text
global _start
msg db 'Hello world!', 0x0A
msglen equ $ - msg
_start:
mov ecx, msg
mov edx, msglen
mov eax, 4
mov ebx, 1
int 0x80
mov eax, 1
mov ebx, 0
int 0x80
nasm -f elf64 hello.asm
ld -s -o hello hello.o
./hello
(8)
dnf install https://www.nasm.us/pub/nasm/releasebuilds/2.15.05/linux/nasm-2.15.05-0.fc31.x86_64.rpm
nasm --version
vim hello.asm
section .text
global _start
msg db 'Hello world!', 0x0A
msglen equ $ - msg
_start:
mov ecx, msg
mov edx, msglen
mov eax, 4
mov ebx, 1
int 0x80
mov eax, 1
mov ebx, 0
int 0x80
nasm -f elf64 hello.asm
ld -s -o hello hello.o
./hello
- Windows Server
(2019)
https://qiita.com/0gajun/items/e772e1223f6e596eb362
https://stackoverflow.com/questions/1023593/how-to-write-hello-world-in-assembler-under-windows/1029093#1029093
前提:
「Build Tools for Visual Studio 2019」 インストール済み
「Visual Studio Community 2019」 インストール済み (ワークロード指定なしでよい)
https://www.nasm.us/pub/nasm/releasebuilds/2.15.05/win64/
cd C:\Users\Administrator\Downloads\nasm-2.15.05-win64\nasm-2.15.05
nasm --version
notepad hello.asm
global _main
extern _GetStdHandle@4
extern _WriteFile@20
extern _ExitProcess@4
section .text
_main:
; DWORD bytes;
; <- prepare local variable
mov ebp, esp
sub esp, 4
; hStdOut = GetStdHandle(STD_OUTPUT_HANDLE)
; (STD_OUTPUT_HANDLE = -11)
push -11
call _GetStdHandle@4
mov ebx, eax
; WriteFile( hStdOut, msg, length(msg), &size, 0)
push 0
lea eax, [ebp - 4]
push eax
push (message_end - message)
push message
push ebx
call _WriteFile@20
; ExitProcess(0)
push 0
call _ExitProcess@4
; never here
hlt
message:
db 'Hello world!', 10
message_end:
nasm -fwin32 hello.asm
"C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.27.29110\bin\Hostx86\x86\link.exe" hello.obj kernel32.lib /ENTRY:main /SUBSYSTEM:CONSOLE
hello
※kernel32.libは下記からコピー
C:\Program Files (x86)\Windows Kits\10\Lib\10.0.18362.0\um\x86