Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  nodelist  faq  login

COBOL is for morons. -- E. W. Dijkstra


programming / comp.lang.asm.x86 / Nasm error undefined reference to printf

SubjectAuthor
o Nasm error undefined reference to printfMohammad Fayad

1
Subject: Nasm error undefined reference to printf
From: Mohammad Fayad
Newsgroups: comp.lang.asm.x86
Organization: A noiseless patient Spider
Date: Mon, 20 Dec 2021 01:08 UTC
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: 11910...@nospicedham.students.liu.edu.lb (Mohammad Fayad)
Newsgroups: comp.lang.asm.x86
Subject: Nasm error undefined reference to printf
Date: Sun, 19 Dec 2021 17:08:48 -0800 (PST)
Organization: A noiseless patient Spider
Lines: 73
Approved: fbkotler@myfairpoint.net - comp.lang.asm.x86 moderation team.
Message-ID: <20b4adae-99d8-4195-807a-cbf78a7e18e5n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Injection-Date: Mon, 20 Dec 2021 01:08:48 +0000
Injection-Info: reader02.eternal-september.org; posting-host="d1bde99e6fd078d33b134caceb416225";
logging-data="31903"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18Hj407DfcRIVjQ5f8rHFQ32X/pf/Fu3kE="
User-Agent: G2/1.0
Cancel-Lock: sha1:oJmgsnNO8fhkQsm5rkxDQK6JvRM=
View all headers
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



1
rocksolid light 0.7.2
clearneti2ptor