Okay, from
Introduction to UNIX assembly programming, it looks like you need the following to be true:
- EDX = length of message, in bytes
- ECX = pointer to message
- EBX = file descriptor; stdout = 1
- EAX = 4, sys-write system call
The data at the place pointed to by ECX better be ASCII data, or it isn't going to be pretty.
The example at the link above:
Code:
mov edx,len ;message length
mov ecx,msg ;message to write
mov ebx,1 ;file descriptor (stdout)
mov eax,4 ;system call number (sys_write)
int 0x80 ;call kernel
mov eax,1 ;system call number (sys_exit)
int 0x80 ;call kernel
section .data
msg db 'Hello, world!',0xa ;our dear string
len equ $ - msg ;length of our dear string
The label 'msg' is the start of a string of ASCII characters, followed by a linefeed. These are printable, being understood by the assembler as such because of their enclosure in quotes. The terminating '0xa', not enclosed in quotes is a defined byte with the explicit value '0x0a', ten in decimal, or possibly in ASCII as '\n'.
Add another section of defined bytes:
Code:
bindata db 0,1,2,3,4,5,6,7,8,9
asciidata db '0123456789'
Assemble the code with an option to see the assembler listing showing the opcodes, immediate data, and static data. Compare the two sections of binary data and ASCII data starting at the 'bindata' label. See the difference? The 'asciidata' section will be printable.
If you want to print static data, make the static bytes printable characters by enclosing it in quotes. If you have an arbitrary binary value that you want displayed in its ASCII string representation, you will have to convert it to ASCII in memory. This can be a bit tricky if you need to see it in its decimal notation, but relatively simple if you want to display it as hexadecimal.
--- rod.