Hugh Aguilar | 3 Nov 07:12
Picon
Favicon

[Nasm-users] libraries

Hello. I'm starting a project that will be written in assembly language. I had intended to use HLA, but I can't get on their mailing list, and I'm hesitant to commit to using HLA without live support --- that is why I'm considering NASM now.

What had impressed me about HLA was that it comes with a large library, and that programs can assemble for either Windows or Linux so long as the programs restrict themselves to using this library. Is there anything like that for NASM? Specifically, for console interface, file access and serial communication? It may be too complicated to support both Windows and Linux, in which case I will support Linux --- but it would be nice to support both.

Also, other than the Windows/Linux issue, I was impressed with HLA's library in general. Are there any libraries of NASM code available? I would be interested in basic data-structure support (lists, arrays, associative arrays, etc.), such as I provided in my Forth novice package:
Is there a repository of NASM code somewhere?

Does NASM work with any debugger, such as GDB?

Is NASM source-code available, and if so, is it BSD or GPL license? What language is it written in?

Thanks for your help --- Hugh

------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
Nasm-users mailing list
Nasm-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nasm-users
Philipp Kloke | 11 Nov 18:02
Picon

[Nasm-users] Suggestion: Limit instruction set to specific CPU type

Hi,
 
I would like to suggest to add a –cpu option to the command line flags of nasm (somewhat similar to GCCs –march option) where the user can specify the CPU type he is programming for. If the user uses an instruction that is not supported by the CPU, the assembler can warn about this. This can help to keep code running on old machines.
 
What do you think about this?
 
 
Philipp
------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
Nasm-users mailing list
Nasm-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nasm-users
Littlefield, Tyler | 11 Aug 16:12

[Nasm-users] linking nasm programs to windows libraries

Hello all:
I am writing a couple nasm functions to test this out with, and have 
been experiencing a problem. I want to link my nasm program to 
user32.lib, which I have done, but when I use the microsoft visual 
studio link command with user32.lib, I still get told that MessageBoxA 
is undefined. How do I do this?

I am aware of alink, but it seems to be a work in progress and I'd 
rather just link to the normal libraries if I possibly can; help is 
appreciated.
Thanks in advance,

--

-- 

Take care,
Ty
my website:
http://tds-solutions.net
my blog:
http://tds-solutions.net/blog
skype: st8amnd127
My programs don't have bugs; they're randomly added features!

------------------------------------------------------------------------------
Get a FREE DOWNLOAD! and learn more about uberSVN rich system, 
user administration capabilities and model configuration. Take 
the hassle out of deploying and managing Subversion and the 
tools developers use with it. 
http://p.sf.net/sfu/wandisco-dev2dev
Frank Kotler | 19 Jun 16:13
Favicon

[Nasm-users] macro variables in labels? strange problem!

Hi Per,
Hi List,

As "owner" of this list, I got the following...

> As list administrator, your authorization is requested for the
> following mailing list posting:

blah, blah, blah...

But when I logged in to approve it, I was informed that there were "no 
pending requests". Did you "cancel" it somehow, Per? (how?) Or is SF 
just messin' with me (us)? Well, I'll attempt to "answer" it anyhow! :)

> I'm trying generate labels using a macro, e.g. like this:
> 
>    %macro blop 1
>    %assign n 0
> 
>    %rep %1
>    %assign n n+1
> label_n:
>    somecode
>    
>    %endrep
> 
>    %endmacro
> 
> I was hoping to end up with a set of labels
> 
> label_1:
>    somecode
> label_2:
>    somecode
> etcetera
> 
> I'm feeling pretty stupid having to ask, but how do I get the
> variable 'n' expanded in(to) the label?

It's a better question than it might seem at first! At one time, in some 
cases, Nasm would have done what you want. But it's been "tightened up" 
in recent versions, and you really need to use the "%+" operator!

label_%+n:

This generates "label_1:", "label_2:", etc. Nasm complains about 
"somecode" being redefined... so I replaced that with... well... "some 
code"... just "ret" to begin with. Same code in each "label" doesn't 
seem useful, but it worked... as long as we only do it once. But:

blop 3

blop 4

Now Nasm complains about "label_1" (etc.) being redfined! The solution 
to this is "macro-local" labels...

%%label_%+n:

Now Nasm generates (use the "-E" switch on the command line to see this):

..@0.label_1:
ret
..@0.label_2:
ret
..@0.label_3:
ret
..@1.label_1:
ret
...etc.

In order to get different code, I added "cmp eax, n" to the macro. I'm a 
little surprised that Nasm doesn't complain about "n" being redefined, 
but it still worked...

> Later I also want to generate:
> 
> global  label_n:func
> lenlab_n    db      *-label_n
> 
> (with 'n' being my variable).

I suspect you want '$', not '*'. The '$' is evaluated where it occurs, 
so this length calculation needs to be done right after the "label" 
code. This means that the "db" gets executed, which we surely don't 
want! I changed it to "equ", which may or may not suit your purposes. 
There may be a better workaround to this(?). I've come up with this, so far:

;-----------------------
    %macro blop 1
    %assign n 0

    %rep %1
    %assign n n+1

global %%label_%+n:func

%%label_%+n:
     cmp eax, n
     ret
%%label_%+n%+_len equ $ - %%label_%+n
    %endrep

    %endmacro

blop 3

blop 4

mov cl, ..@4.label_1_len
;---------------------------

This seems to "work"... Note that instead of "..@1", "..@2" as I would 
have expected, Nasm has jumped to "..@4" for the "macro-local labels" in 
the second invocation of the macro (dunno why). This makes it rather a 
PITA to use the length outside of the macro! I don't know if it's 
"useful" or not...

FWIW, I created this list at the request of another developer, to keep 
this kind of question off the "developer's list". It gets very little 
traffic. There's the "Nasm Forum" here:

http://forum.nasm.us

which is also suitable for this kind of question. You might get better 
results there.

Reminder to all subscribers: hit "reply all" to reply to this list - 
just "reply" goes only to the poster (me, in this case).

My apologies if you intended to "withdraw" the question. I thought it 
was worth trying to answer, even if SF denies that it exists. :)

Best,
Frank

------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
Fritz Wuehler | 16 May 12:57

[Nasm-users] What debugger front end for Linux?

Hi guys, I am trying to learn x86 assembly with NASM since it uses the less
hideous Intel syntax! However the debugger front end I tried doesn't seem to
recognize this format and I can't set breakpoints. Whoever is using NASM on
Linux can you explain your environment a bit, what tools should I be using
etc. for best results. Thanks guys.

------------------------------------------------------------------------------
Achieve unprecedented app performance and reliability
What every C/C++ and Fortran developer should know.
Learn how Intel has extended the reach of its next-generation tools
to help boost performance applications - inlcuding clusters.
http://p.sf.net/sfu/intel-dev2devmay
Frank Kotler | 9 Mar 12:22
Favicon

Re: [Nasm-users] please help

kevin becker wrote:
> ok thank you  :)
> 
> im trying to learn ASM so i can make an OS, im working on logo

You might find some of the information on this site useful:

http://wiki.osdev.org/Main_Page

Good luck!

Best,
Frank

------------------------------------------------------------------------------
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d
Frank Kotler | 8 Mar 23:06
Favicon

Re: [Nasm-users] please help

kevin becker wrote:
> uhm ok iguess.
> ive heard of something called virtual computer which i guess simulates 
> what happens if you run things/do things on your comp, but since its a 
> simulation there's no danger of screwing up files.

Mmmm, no chance of altering files legitimately either, then?

> if i download Mac on it, would Nasm work normally??

Dunno. It "should", if the emulation is correct, I guess. Try it. Seems 
like it might be the hard way... Try it... no harm done(?) if it doesn't 
work normally...

Best,
Frank

> 
> ss simOn Tue, Mar 8, 2011 at 1:13 PM, Frank Kotler <fbkotler <at> zytor.com 
> <mailto:fbkotler <at> zytor.com>> wrote:
> 
>     kevin becker wrote:
> 
>         uhm
> 
>         when i click on the NASM.exe, it pops upon, and then closes
>         before anything can be even SEEN
> 
>         it doesn't do anything....
> 
> 
>     Ah, okay. Nasm is a "command line" utility. That is, at a "command
>     prompt", you'd type "nasm -f win32 -i c:\my\includes\ -o myfile.obj
>     myfile.asm", or so. You can get a command prompt by doing
>     start->run->"cmd" - I think that still works. Alternatively, there's
>     a way to make a "shortcut" to Nasm that will pop up a dialog-box
>     when you click on it that will allow you to enter a command line.
>     I'm afraid I don't remember how that one goes -
>     "properties->advanced" somewhere, no doubt...
> 
>     Or, you might prefer an "IDE" - an "Integrated Development
>     Environment" which will allow you to clickie-clickie to edit,
>     assemble, run, debug, etc. NaGoA was one created for Nasm. It
>     appears to be "abandoned", but still works, AFAIK.
> 
>     http://www.visual-assembler.pt.vu/
> 
>     (wow! that's *really* looking abandoned!)
> 
>     Probably the most popular IDE is RadAsm...
> 
>     http://radasm.cherrytree.at/radasm/
> 
>     You can use Nasm with Visual Studio, too, I understand, though it
>     may take more "setup" than with RadAsm(?). I prefer working from a
>     command prompt, myself, and I'm not running Windows, so I can't help
>     you much. Maybe someone who is can give you more specific advice...
>     What you're seeing is "normal behavior" from Nasm. The error
>     message, which goes by too fast to see, says "error: no input file
>     specified".
> 
>     Best,
>     Frank
> 
> 
> 
> 
> -- 
> (>^_^)># I made you a waffle
> #<(^_^<) But then I was like...
> (>^#^<) "I'm hungry..."
> (>^_^)> So I ate it.
>  
> 

------------------------------------------------------------------------------
What You Don't Know About Data Connectivity CAN Hurt You
This paper provides an overview of data connectivity, details
its effect on application quality, and explores various alternative
solutions. http://p.sf.net/sfu/progress-d2d
kevin becker | 8 Mar 01:00
Picon

[Nasm-users] please help


i have ap orblem whenever i try to run it it shuts down instantly. It does the same thing when i run a program in Dev C++, but that i can just type system("PAUSE);
please help me
thanx
--
(>^_^)># I made you a waffle
#<(^_^<) But then I was like...
(>^#^<) "I'm hungry..."
(>^_^)> So I ate it.
 

------------------------------------------------------------------------------
What You Don't Know About Data Connectivity CAN Hurt You
This paper provides an overview of data connectivity, details
its effect on application quality, and explores various alternative
solutions. http://p.sf.net/sfu/progress-d2d
_______________________________________________
Nasm-users mailing list
Nasm-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nasm-users
Frank Kotler | 20 Dec 21:36
Favicon

Re: [Nasm-users] Working with pointers

Littlefield, Tyler wrote:
> Rather than filling everyone's inbox replying to all of these, just 
> wanted to say thanks for all the help.

Hi Tyler,

You're welcome. I'm going to undo your consideration and fill up 
everybody's mailbox, though, 'cause I think your questions are 
interesting, and might lead to some discussion. If anyone thinks this 
list is generating too much traffic, they can complain... or just 
unsubscribe. :)

> It helped. I have two more 
> questions. First, I'm working with Unix systems. How would I go about 
> creating a socket, closing the socket, etc?

ASSuming you want to do this via the int 80h interface, there's really 
only one sys_socketcall (102). This is usually "wrapped" to socket 
(create), connect, bind, listen, etc. Even Konstantin's "asmutils" 
provides macros for sys_socket, etc. But the "real" interface is just 
sys_socketcall, with the subfunctions or "commands" in ebx - ecx points 
to remaining parameters. In order to not "hide" anything, I like to do 
it that way, although we're "supposed" to use the C library interface 
(they make me say that). There are "send" and "recv" commands, but 
sys_write/sys_read seem to work - sys_close seems to work - just like 
any other file descriptor.

> Last, do we have some sort 
> of method for using malloc? I don't think it's an actual syscall, but I 
> need to be able to allocate memory.

Well, "just call malloc". There are a couple of system calls that will 
get us a chunk of memory - sys_mmap (or mmap2?) and sys_brk. These get 
us a minimum of 4096 bytes. To "malloc" smaller pieces, we're on our 
own. I think Jonathan Bartlett's "PGU" has an example. I think sys_mmap 
gets us memory starting about 40000000h, sys_brk gives us memory 
contiguous with the end of our existing memory, which may be an 
advantage(?). As I recall, "man 2 brk" isn't too helpful (unusually).

xor ebx, ebx
mov eax, 45
int 80h
; check for error - shouldn't be any(?)
mov [orig_break], eax
mov ebx, eax
add ebx, 4096 ; or some multiple
mov eax, 45
int 80h
; check for error - might be out of memory

Now eax should have our new "break" (where memory ends for our process). 
We can use memory between "orig_break" and "new_break". To "free" it:

mov ebx, [orig_break]
mov eax, 45
int 80h

Now we should be back where we were. I think that works...

Getting back to sockets, here's my adaptation of Scott Lanning's 
"daytime_cli.s" (available at Konstantin's linuxassembly.org, or 
http://asm.sf.net somewhere):

;-----------------------------
; daytime client in Linux asm, syscalls only
; loosely based on daytime_cli.s from Scott Lanning
;
; nasm -f elf32 daytime.asm
; ld -o daytime daytime.o

global _start

struc sockaddr_in
     .sin_family resw 1
     .sin_port resw 1
     .sin_addr resd 1
     .sin_zero resb 8
endstruc

_ip equ 0x7F000001		; loopback - 127.0.0.1
_port equ 13

; Convert numbers to network byte order

IP equ ((_ip & 0xFF000000) >> 24) | ((_ip & 0x00FF0000) >>  8) | ((_ip & 
0x0000FF00) <<  8) | ((_ip & 0x000000FF) << 24)
PORT equ ((_port >> 8) & 0xFF) | ((_port & 0xFF) << 8)

AF_INET        equ 2
SOCK_STREAM    equ 1

BUFLEN         equ  0x80

STDIN          equ 0
STDOUT         equ 1

__NR_exit	equ 1
__NR_read       equ 3
__NR_write      equ 4
__NR_socketcall equ 102

SYS_SOCKET     equ 1
SYS_CONNECT    equ 3

section .data

my_sa istruc sockaddr_in
     at sockaddr_in.sin_family, dw AF_INET
     at sockaddr_in.sin_port, dw PORT
     at sockaddr_in.sin_addr, dd IP
     at sockaddr_in.sin_zero, dd 0, 0
iend

socket_args dd AF_INET, SOCK_STREAM, 0

; first of these wants to be socket descriptor
; we fill it in later...
connect_args dd 0, my_sa, sockaddr_in_size

section .bss
     my_buf resb BUFLEN
     sock_desc resd 1

section .text
  _start:

     ; socket(AF_INET, SOCK_STREAM, 0)

     mov     ecx, socket_args	; address of args structure
     mov     ebx, SYS_SOCKET     ; subfunction or "command"
     mov     eax, __NR_socketcall     ;c.f. /usr/src/linux/net/socket.c
     int     80h

     cmp     eax, -4096
     ja      exit

     mov     [sock_desc], eax
     ; and fill in connect_args
     mov	    [connect_args], eax

      ; connect(sock, (struct sockaddr *)&sa, sizeof(struct sockaddr))

     mov     ecx, connect_args
     mov     ebx, SYS_CONNECT	; subfunction or "command"
     mov     eax, __NR_socketcall
     int     80h

     cmp     eax, -4096
     ja      exit

     ; read(sock, buf, len)
     mov     edx, BUFLEN		; arg 3: max count
     mov     ecx, my_buf		; arg 2: buffer
     mov     ebx, [sock_desc]	; arg 1: fd
     mov     eax, __NR_read	; sys_read
     int     80h

     cmp     eax, -4096
     ja      exit

     ; write(stdout, buf, len)
     mov     edx, eax		; length read is length to write
     mov     ecx, my_buf
     mov     ebx, STDOUT
     mov     eax, __NR_write
     int     80h

     xor eax, eax		; success
  exit:
     mov     ebx, eax		; exitcode
     mov     eax, __NR_exit
     int     80h
;----------------------

That probably won't do anything, unless you've already got a "daytime" 
server running. Edit (as root) /etc/inetd.conf and uncomment the 
"daytime" line. Do "ps x" to get the ID for inetd, and "kill -HUP xxxx". 
Works for me. If your system is different, enlighten me!

I have a couple other examples... an "echo" (or echo-like) client and 
server (not a very good "server"). I also have a couple examples Nathan 
Baker sent me - Windows programs using the NASMX package. I've written a 
"fakeapi.asm" containing functions with the same names and parameters as 
the Windows APIs, that do "approximately" the same thing. Linking 
(statically) against this allows the same programs to run in Linux. This 
is just a novelty, and will *not* work in the "general case", but I 
thought it was amusing...

If anyone wants to see any of these, give a yell.

Best,
Frank

------------------------------------------------------------------------------
Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.
http://p.sf.net/sfu/lotusphere-d2d
Littlefield, Tyler | 17 Dec 07:27

[Nasm-users] Working with pointers

hello all,
I have a quick question.
I have the following:
section .data
ptr dd 0
array times 100 db 0

Now, when I want to assign array to p, I can't mov it--how can I assign 
the pointer to point there? Last, is there a way to get the type of 
processor?
(32-64), as that will make a difference on the code in some places?

--

-- 

Thanks,
Ty

------------------------------------------------------------------------------
Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.
http://p.sf.net/sfu/lotusphere-d2d
Tyler Littlefield | 13 Oct 01:47

[Nasm-users] learning asm


Hello all,
I'm looking for a few things, and maybe someone can help me out some.
I've been toying with asm for a while, but I'd really like to dive in.
One of my problems is proper information on what things like enter and
leave do, etc. Is there a good reference somewhere?
I'm also curious of the output of a .lst file, and how it's organized:
There don't seem to be column headers, so I'm having issues figuring out
what's what with my reader.
Also, are there some good nasm samples out there to play with? Iseen a
text editor, but that might just confuse me, then confuse me again.

--

-- 
Thanks,
Tyler Littlefield

Gmane