It's probably way too introductory for you, but the game Turing Complete gets you to make your own toy assembly language (twice for different architectures) in the later parts and this helped me immensely when learning assembly myself.
While curious, that's not at all what I'm looking for in this case. I am looking for an example of working code and commands to build an executable from it.
Its not windows or NASM but this site has some 64 bit linux examples using gnu assembler (the gnu userland default assembler). You could probably find some examples for windows with nasm if you look around.
::: spoiler example code from the site
# ----------------------------------------------------------------------------------------
# Writes "Hello, World" to the console using only system calls. Runs on 64-bit Linux only.
# To assemble and run:
#
# gcc -c hello.s && ld hello.o && ./a.out
#
# or
#
# gcc -nostdlib hello.s && ./a.out
# ----------------------------------------------------------------------------------------
.global _start
.text
_start:
# write(1, message, 13)
mov $1, %rax # system call 1 is write
mov $1, %rdi # file handle 1 is stdout
mov $message, %rsi # address of string to output
mov $13, %rdx # number of bytes
syscall # invoke operating system to do the write
# exit(0)
mov $60, %rax # system call 60 is exit
xor %rdi, %rdi # we want return code 0
syscall # invoke operating system to exit
message:
.ascii "Hello, world\n"
Unfortunately, I am looking specifically for examples for Windows. I need to figure out what I'm doing wrong.
You could probably find some examples for windows with nasm if you look around
I have looked around, and I have not found any working examples of such. That is exactly why I'm asking.
For the CLI commands: https://www.nasm.us/xdoc/2.16.03/html/nasmdoc2.html#section-2.1
Have you seen this?
I haven't written asm in years though, so I cant whip up a putc loop example.
No, but this doesn't provide any relevant answers.
Sadly, this doesn't work. When trying to link the object file, I get a bunch of errors:
i386 architecture of input file `test.obj' is incompatible with i386:x86-64 output
test.obj:test.asm:(.text+0x6): undefined reference to `_printf'
undefined reference to `WinMain'
collect2.exe: error: ld returned 1 exit status
I currently do not have the time to debug this.
technology
On the road to fully automated luxury gay space communism.
Spreading Linux propaganda since 2020
- Ways to run Microsoft/Adobe and more on Linux
- The Ultimate FOSS Guide For Android
- Great libre software on Windows
- Hey you, the lib still using Chrome. Read this post!
Rules:
- 1. Obviously abide by the sitewide code of conduct. Bigotry will be met with an immediate ban
- 2. This community is about technology. Offtopic is permitted as long as it is kept in the comment sections
- 3. Although this is not /c/libre, FOSS related posting is tolerated, and even welcome in the case of effort posts
- 4. We believe technology should be liberating. As such, avoid promoting proprietary and/or bourgeois technology
- 5. Explanatory posts to correct the potential mistakes a comrade made in a post of their own are allowed, as long as they remain respectful
- 6. No crypto (Bitcoin, NFT, etc.) speculation, unless it is purely informative and not too cringe
- 7. Absolutely no tech bro shit. If you have a good opinion of Silicon Valley billionaires please manifest yourself so we can ban you.