Jump to content

Recommended Posts

Posted

Olá?

Queria saber como copilo o NASM no Windows 11? e como uso o ld do Linux no Windows 11?

nasm -f elf64 hello.asm
ld -s -o hello hello.o
./hello

 

 

 

; =========================
; Programa Hello World
; =========================
; Compilação
; =========================
; nasm -f elf64 hello.asm
; ld -s -o hello hello.o
; ./hello
; =========================
; Resultado
; =========================
; Hello World
; =========================
section .data:
   msg db 'Hello World', 0xa
   len equ $ - msg
section .text:

global _start

_start:
   mov edx, len
   mov ecx, msg
   mov ebx, 1
   mov eax, 4
   int 0x80

; Saida
   mov eax, 1
   mov ebx, 0
   int 0x80
Posted
  bits  64
  default rel

  section .rdata

hello:
  db  `Hello\r\n`
hello_len equ $ - hello

  section .text

  extern __imp_GetStdHandle
  extern __imp_WriteConsoleA
  extern __imp_ExitProcess

  global _start

_start:
  sub   rsp,32

  mov   ecx,-11
  call  [__imp_GetStdHandle]

  mov   rcx,rax
  lea   rdx,[hello]
  mov   r8d,hello_len
  xor   r9,r9
  push  0
  call  [__imp_WriteConsoleA]

  xor   ecx,ecx
  call  [__imp_ExitProcess]

  ; Nunca chegará aqui!

Compilando e executando:

$ nasm -fwin64 -o hello.o hello.asm
$ ld -s -o hello.exe hello.o -lkernel32
$ ./hello

image.png.bd33cf820648feb7905fa0d805243c86.png

image.png.84e1273af1eab07ae717ebab66c38aa3.png

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...