Recent Posts

Pages: [1] 2 3 ... 10
1
I personally prefer the simpler method using by using %define because of simplicity, but thanks for the answer.
Ok... just keep in mind that using the hardcoded [ebp+offset] can lead to bugs. In your example the offsets are wrong... Using the structure you avoid this problem.
2
Programming with NASM / Re: bad syntax for EQU - when using aParam equ [rbp+16]
« Last post by dindibo4 on July 04, 2019, 07:25:30 PM »
I personally prefer the simpler method using by using %define because of simplicity, but thanks for the answer.
3
First. Since you are using the stack to pass the arguments for your function AND 'int 0x80', I assume you are dealing with 32 bits SysV ABI. You cannot use Rxx registers there.

Second, there is a better approach:
Code: [Select]
bits 32   ; to be sure!

section .text

global putstr

; Stack frame for putstr() function call.
struc putstrstk
.retaddr: resd  1   ; call will push the return address.
.len:     resd  1   ; cdecl calling convention will push len first,...
.textptr: resd  1   ; ... then, textptr, before calling putstr().
endstruc

; void putstr(char *text, size_t len)
putstr:
  ; You don't need to use EBP!!!
  mov eax, 4      ; write syscall [write( int fd, void *buff, size_t size );]
  mov ebx, 1      ; stdout
  mov ecx, [esp + putstrstk.textptr]
  mov edx, [esp + putstrstk.len]
  int 0x80
  ret

Third, EQU is not a lexical substitution directive. For that purpose you should use %define:
Code: [Select]
%define aParam [ebp+4]
%define bParam [ebp+8]
4
Programming with NASM / bad syntax for EQU - when using aParam equ [rbp+16]
« Last post by dindibo4 on July 04, 2019, 02:25:12 PM »
Hello, i'm pretty new to NASM and I've tried to make a procedure like printf and assign the arguments with EQU

Code: [Select]
; void printf(char *text, int len)
printf:
push rbp
mov rbp, rsp

aParam equ [rbp+16]
bParam equ [rbp+24]

mov eax, 4
mov ebx, 1
mov ecx, bParam
mov edx, aParam
int 0x80

pop rbp
ret
 

It didn't worked and showed "bad syntax for EQU" exception on the code.
What is the right syntax of EQU for this usage?
5
Using NASM / MOVED: Install Office : office.com/setup
« Last post by Frank Kotler on June 25, 2019, 07:32:41 PM »
6
Programming with NASM / MOVED: Install Office : office.com/setup
« Last post by Frank Kotler on June 25, 2019, 07:29:25 PM »
7
Using NASM / Re: NASM on Raspberry Pi
« Last post by shishili on June 23, 2019, 01:30:47 AM »
Fine, i will try to install it on win again. Thank you so much! ;D
8
Using NASM / Re: NASM on Raspberry Pi
« Last post by Frank Kotler on June 22, 2019, 06:23:24 PM »
 Hi shishili,

Welcome to the forum!

Nasm should work on any Intel/AMD x86 or x86-64 CPU. From what I can find out, the Raspberry Pi has an ARM CPU, which unfortunately means that Nasm won't work for you. I wish I could give you better news! 

If you want to try programming on your Windows machine, perhaps we can help you there.

Best,
Frank

9
Using NASM / NASM on Raspberry Pi
« Last post by shishili on June 22, 2019, 12:39:39 PM »
Hi! I'm a students from China. And my professor request us edit a little program with Assembly language. I downloaded NASM installer for win-64 in the morning. After the installation finished, i click the icon to open it. But the window look like a command window without other operations(I want insert an image here, but failed). I don't know what should i do next.
And i have a Raspberry Pi. Could NASM work on it? And how? Thank you from the bottom of my heart in advance!
10
Programming with NASM / Re: How do I remove zero termination from a string
« Last post by yoran on June 10, 2019, 09:33:03 AM »
16 Bit bare bones, and I have a function which I feed a string from a memaddress. However this function takes stringlen instead of zero-termination, so how do I remove the zero-termination?
Pages: [1] 2 3 ... 10