title: Position independent code in macro-assembly
body: <p>Write a NASM macro: divide, which has 2 arguments, which specify unsigned integers in any addressing mode. The macro computes the ceiling of its first argument, divided by its second argument, and places the result in register edx. If the second argument is 0 (to be tested at runtime), the result should be 0, and a message "divide by zero" should be printed to stdout.</p>
  
  <p>This is the code I wrote. How to write this code without labels? (position independs code)</p>
  
  <pre><code>%macro divide 2
  
  section .rodata
          LC1: DB "divide by zero ", 10, 0
  
  section .text
  
    mov eax, %1
    mov ebx, %2
    cmp ebx, 0 ; divide by zero
    jne rest1
    push LC1
    call printf
    add esp,4
    mov edx, 0
    jmp end1
  
  rest1:
    mov edx, 0
    div ebx
    add eax, edx
    mov edx , eax ; the result should be in edx
  
  end1:
   %endmacro
  </code></pre>