Recent Posts

Pages: [1] 2 3 ... 10
1
Programming with NASM / Re: Is that a BUG ??
« Last post by nasmtaskforce on April 16, 2021, 09:06:10 PM »
I've just installed nasm 2.15 and everything seems to be ok.
No need to use function or func keyword with global, it already export the function correctly.  8)
2
Programming with NASM / Is that a BUG ??
« Last post by nasmtaskforce on April 16, 2021, 07:30:38 PM »
Hi everyone,

I use a small macro on my static library like :

%macro cglobal 1
   global %1
 %1:
%endmacro

Now, i have made a simple modification for shared library so:

%macro cglobal 1
   global %1:function
 %1:
%endmacro

The "function" key is not working. Maybe macro don't want to merge it.

but when I use this method :

%macro cglobal 1
   global %1:func <-- no function only func
 %1:
%endmacro

It works like a charm  :o
Is that a BUG ???

With regards.

PS: I work on Debian and NASM release 2.14
3
Using NASM / Re: Compiling recent versions of NASM with VC++ 2017
« Last post by Frank Kotler on April 09, 2021, 04:28:57 PM »
Thank you for posting your answers !

Best.
Frank

4
Using NASM / Re: Compiling recent versions of NASM with VC++ 2017
« Last post by mh-nexus on April 09, 2021, 01:22:51 PM »
There are two issues with substring replacement $(ALLOBJ:.@OBJEXT@=.c).

@OBJEXT@ has no effect since macro expansion is not supported by nmake:
https://stackoverflow.com/questions/18374299/how-do-i-substitute-a-string-and-add-a-prefix-or-suffix-in-microsoft-nmake

Therefore it has to be rewritten with string literals, as such:
$(ALLOBJ:.obj=.c)

Fixing all the bugs mentioned in the posts so far, we get:
Quote
asm\warnings.time: $(ALLOBJ:.obj=.c)
   type NUL > asm\warnings.time
   $(MAKE) $(WARNFILES)

But eventhough this string replacement works, we still have cyclic dependencies, for example:

asm\warnings.time -> asm\warnings.c -> asm\warnings.time

The last dependency occurs due to line 237:
Code: [Select]
asm\warnings.c: asm\warnings.pl asm\warnings.timesand the first dependency due to
Code: [Select]
asm\warnings.time: $(ALLOBJ:.obj=.c)
Whatever the purpose of this added code to the makefile was, it will not work with nmake, due to the cyclic dependency. So until the original developer fixes it, the best option is to edit the makefile as mentioned in my third post.
5
Using NASM / Re: Compiling recent versions of NASM with VC++ 2017
« Last post by mh-nexus on April 09, 2021, 12:06:47 PM »
Line 234 has the statement:
Code: [Select]
: > asm\warnings.timeWhich is an illegal command under Windows. I assume it is supposed to update the file modification time, which can be achieved like this:
Code: [Select]
type NUL > asm\warnings.timeIt will also create the file in case it does not exist.

But the real issue is the condition $(ALLOBJ:.@OBJEXT@=.c) in the line 233:
Code: [Select]
asm\warnings.time: $(ALLOBJ:.@OBJEXT@=.c)
But even if that issue would be solved, I am not sure I understand the logic behind that statement. The file asm\warnings.time has to exist already (which it does not in the default distribution), or nmake will still fail.
6
Using NASM / Re: Compiling recent versions of NASM with VC++ 2017
« Last post by mh-nexus on April 09, 2021, 11:30:50 AM »
After some more digging I found out the issue. Apparently the following makefile entries in msvc.mak cause the "A circular dependency exists in the dependency tree for the given target. " error.

The relevant 4 lines, starting at line no 231, are:
Code: [Select]
$(MAKE) asm\warnings.time

asm\warnings.time: $(ALLOBJ:.@OBJEXT@=.c)
: > asm\warnings.time

Comment out these 4 lines, then create the empty file asm\warnings.time manually.

After these steps compiling works again as expected with the usual command:
nmake /f Mkfiles\msvc.mak

I haven't found out a way to fix this issue properly yet, but this stackoverflow entry might give a hint:
https://stackoverflow.com/questions/32394965/makefile-cycle-in-dependency-tree
7
Example Code / Re: MSDOS screensaver TSR example
« Last post by robbo007 on April 09, 2021, 10:34:53 AM »
darn, crashes my IBM 5160 :(
8
Using NASM / Re: Compiling recent versions of NASM with VC++ 2017
« Last post by mh-nexus on April 09, 2021, 10:07:07 AM »
To answer my own question: 2.15.03 is missing config\config.h.in. Copying it from 2.15.04 solves the compiling problem for 2.15.03.

However 2.15.04 and 2.15.05 still don't compile because of this error:
Quote
Microsoft (R) Program Maintenance Utility, Version 14.16.27030.1
Copyright (C) Microsoft Corporation. Alle Rechte vorbehalten.

NMAKE : fatal error U1071: Schleife im Abhängigkeitsstruktur für Ziel "asm\nasm.
obj"
Stop.
9
Programming with NASM / Efficient bit array for kernel paging?
« Last post by kdx7214 on March 20, 2021, 12:31:23 AM »
I'm currently playing around with a 64-bit x86_64 kernel and am at the point where I need to do paging.
I've written bit arrays before in several languages but was wondering if there are more efficient ways to do
it in assembly.   It really only needs three operations:

1.  Set bit
2.  Clear bit
3.  Find first cleared bit

The set and clear bit functions are pretty straightforward, but the find first clear bit is a time hog.

I've google'd for this, but keep finding information on bit masking word sized values and the like.  Plus, I'm sure
my google-fu is weak.

Anyone come across information about optimizing this?

Cheers!
10
A little better approach:
Code: [Select]
; fib.asm
  bits  64
  default rel

  section .text

  global fib

; unsigned int fib( unsigned int n );
;
; Input: EDI = n (n >= 1)
; Output: EAX (fibonacci number).
  align 4
fib:
  ; Preserve RBP and RBX (SysV ABI).
  push  rbp
  push  rbx

  mov ebp, 1

  cmp edi, 3
  jb  .exit

  mov ebx, edi
  mov ebp, 1

  align 4
.loop:
  lea   edi, [rbx - 1]
  call  fib
  add   ebp, eax      ; Accumulate.
  sub   ebx, 2
  ja    .loop

.exit:
  mov eax, ebp

  ; Restore RBP and RBX (SysV ABI).
  pop rbx
  pop rbp

  ret
Test code:
Code: [Select]
/* test.c */
#include <stdio.h>

extern unsigned int fib( unsigned int );

int main( void )
{
  unsigned int i;

  for ( i = 1; i <= 10; i++ )
    printf( "%u ", fib(i) );
  putchar( '\n' );
}
Compiling, linking and testing:
Code: [Select]
$ cc -c -o test.o test.c
$ nasm -felf64 -o fib.o fib.asm
$ cc -o test test.o fib.o
$ ./test
1 1 2 3 5 8 13 21 34 55
Pages: [1] 2 3 ... 10