home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.asm.x86      Ahh, the lost art of x86 assembly      4,675 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 4,434 of 4,675   
   Mohammad Fayad to All   
   Nasm error undefined reference to printf   
   19 Dec 21 17:08:48   
   
   From: 11910171@nospicedham.students.liu.edu.lb   
      
   Hello im trying to write a program that checks if a number is divisble by 2   
   and 8 and prints numbers in loop and im getting error undefined reference to   
   printf   
   This is the code:   
   global _start   
      
   extern _printf   
      
   SECTION .data   
       message1: db "Enter a number: ", 0   
       number1: db "%d", 0   
       integer1: times 10 db 0 ; 32-bits integer = 10 bytes   
   	msg db 'Divisible by 2 and 8', 0xa,0xd   
   	len equ	$ - msg   
   	SYS_EXIT equ 1   
   	STDOUT EQU 1   
   	SYS_WRITE EQU 4   
   SECTION .bss   
      val2 resb 2   
      
   SECTION .text   
      
   _start:   
      
      push message1   
      call _printf   
      pop rbx   
      mov eax, 3   
      mov ebx, 1   
      mov ebx, val2   
      mov edx, 2   
      int 0x80   
      push val2   
      mov al, [val2]	   
      
   l1:   
   .divisble_by_2:   
       mov ax, [number1]   
       xor dx, dx   
       mov bx, 2   
       div bx   
       cmp dx, 0   
       jnz .not_divisible   
      
   .divisble_by_8:   
       mov ax, [number1]   
       xor dx, dx   
       mov bx, 8   
       div bx   
       cmp dx, 0   
       jnz .not_divisible   
      
   .print_number:   
       mov edx, [number1]   
       add edx, 48   
       mov [number1], edx   
      
       mov eax, 4   
       mov ebx, 1   
       mov ecx, [number1]   
       mov edx, len   
       int 0x80   
       mov eax, .divisble_by_2   
       int 0x80   
      
   .not_divisible:   
   	xor	eax, eax   
   	mov	edx, [eax+len]   
   	mov	al, 1   
   	mov	esi, .divisble_by_2   
   	mov	edi, eax   
       mov eax, 1   
       int 0x80   
       jmp _start   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca