I\'m trying to print a single character or a number using NASM, targeting an x86 GNU/Linux architecture.
Here\'s the code I\'m using:
The system call you are executing expects ecx to contain an address in memory. This can be an arbitrary literal address (i.e. in your code, "A" translates to the address 041h), an address on the stack, or an address defined by a label in the program.
Here's an example of defining a byte in memory and writing it to the standard output stream of your terminal:
section .rodata ; This section contains read-only data
buffer: db 'A' ; Define our single character in memory
section .text
global start
_start:
; Prints the letter 'A', then exits
mov eax, 4 ; sys_write()
mov ebx, 1 ; ... to STDOUT
mov ecx, buffer ; ... using the following memory address
mov edx, 1 ; ... and only print one character
int 80h ; SYSCALL
mov eax, 1 ; Return to system
mov ebx, 0 ; Exit zero, success
int 80h ; SYSCALL