rcj
rcj

Reputation: 661

Assembly writing to stdout

I'm trying to write 4 bytes to the screen using:

nasm -f elf -g ****.asm

Nothing is happening.

Here is the relevant code segment:

mov     eax, 4             ; ow print error mesg
mov     ebx, 1
mov     ecx, DWORD [para]
mov     edx, 4
int     080h

This is my debug run of that portion of my code. Nothing is being printed, I'm showing you the contents of $ecx via gdb.

253             mov     eax, 4             ; ow print error mesg
(gdb)
254             mov     ebx, 1
(gdb)
255             mov     ecx, DWORD [para]
(gdb)
256             mov     edx, 4
(gdb)
257             int     080h
(gdb) p /t $ecx
$1 = 1100001010101001000010110000010
(gdb) step

No idea what I'm doing wrong. From previous posts here and on other websites, I can't see a discrepancy with the accepted method.

Upvotes: 1

Views: 2089

Answers (2)

Jean-Baptiste Noblot
Jean-Baptiste Noblot

Reputation: 330

What is the normal value of para ?

I have an old code and I don't use DWORD just

mov     ecx, [para]

Upvotes: 3

Frank Kotler
Frank Kotler

Reputation: 3119

ecx wants the address of the text to print. Unless para is a "pointer" (holds the address of the text), just mov ecx, para is probably correct. Strictly speaking, ebx might want to be 2 (stderr), but I doubt if that's your problem. Show us para!

Upvotes: 0

Related Questions