Author Topic: how do we print in assembly?  (Read 26567 times)

Offline maplesirop

  • Jr. Member
  • *
  • Posts: 60
Re: how do we print in assembly?
« Reply #15 on: March 14, 2013, 02:55:58 PM »
Code: [Select]
segment .data



segment .bss



segment .text

extern _printf

global _start

_start:


mov ecx, 1
mov edx, ecx
add edx, 30h
mov ecx, edx
mov eax, 4
mov ebx, 1
int 0x80

mov eax, 1
xor ebx, ebx
int 0x80

This doesn't even work.

Offline maplesirop

  • Jr. Member
  • *
  • Posts: 60
Re: how do we print in assembly?
« Reply #16 on: March 14, 2013, 03:10:57 PM »
/usr/bin/ld: skipping incompatible /nfs/encs/ArchDep/x86_64.linux26-RHEL5/pkg/gcc-4.1.2/root/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.1.2/libgcc.a when searching for -lgcc
/usr/bin/ld: skipping incompatible /encs/pkg/gcc-4.1.2/root/lib/gcc/x86_64-unknown-linux-gnu/4.1.2/libgcc.a when searching for -lgcc

I get this when I write:

gcc -o exz exz.o -m elf_i386



and when i write this:

gcc -o exz exz.o

I get this:

/usr/bin/ld: warning: i386 architecture of input file `exz.o' is incompatible with i386:x86-64 output

Offline TightCoderEx

  • Full Member
  • **
  • Posts: 103
Re: how do we print in assembly?
« Reply #17 on: March 14, 2013, 03:14:35 PM »
Here are a few Display strings examples

Offline maplesirop

  • Jr. Member
  • *
  • Posts: 60
Re: how do we print in assembly?
« Reply #18 on: March 14, 2013, 03:23:02 PM »
I want to print two digits integers.

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: how do we print in assembly?
« Reply #19 on: March 14, 2013, 06:19:50 PM »
It appears your system hasn't got the 32-bit libraries...
Code: [Select]
apt-get install ia32-libs

Or, write yourself some 64-bit code. This is very different from 32-bit code! There are examples around...

Or, go back to 32-bit system calls... or 64-bit system calls. You've got my example of "print the matrix" (not very good, but it works). You'll have to tell ld "-melf_i386", but you won't be looking for libraries you don't have.

You wanna do just two digits?
Code: [Select]
; value in al
aam
add ax, 0x3030
xchg al, ah
mov [buffer[, ax
mov eax, 4
mov ebx, 1
mov ecx, buffer
mov edx, 2
int 0x80
(untested!)

Best,
Frank