nasm

Why does the sys_read system call end when it detects a new line?

我们两清 提交于 2021-02-20 05:56:48
问题 I'm a beginner in assembly (using nasm). I'm learning assembly through a college course. I'm trying to understand the behavior of the sys_read linux system call when it's invoked. Specifically, sys_read stops when it reads a new line or line feed . According to what I've been taught, this is true. This online tutorial article also affirms the fact/claim. When sys_read detects a linefeed, control returns to the program and the users input is located at the memory address you passed in ECX. I

Why does the sys_read system call end when it detects a new line?

徘徊边缘 提交于 2021-02-20 05:56:46
问题 I'm a beginner in assembly (using nasm). I'm learning assembly through a college course. I'm trying to understand the behavior of the sys_read linux system call when it's invoked. Specifically, sys_read stops when it reads a new line or line feed . According to what I've been taught, this is true. This online tutorial article also affirms the fact/claim. When sys_read detects a linefeed, control returns to the program and the users input is located at the memory address you passed in ECX. I

Why does the sys_read system call end when it detects a new line?

蹲街弑〆低调 提交于 2021-02-20 05:55:00
问题 I'm a beginner in assembly (using nasm). I'm learning assembly through a college course. I'm trying to understand the behavior of the sys_read linux system call when it's invoked. Specifically, sys_read stops when it reads a new line or line feed . According to what I've been taught, this is true. This online tutorial article also affirms the fact/claim. When sys_read detects a linefeed, control returns to the program and the users input is located at the memory address you passed in ECX. I

Collatz Conjecture in Assembly shortest form

☆樱花仙子☆ 提交于 2021-02-19 07:53:05
问题 We had an assignment where we had to write the collatz conjecture in 64bit nasm assembly with only 13 commands or less (RET included). Now we are wondering how much you can actually reduce it. We are currently on 9. Heres the collatz conjecture in pseudo code for reference: Heres the code we have so far. A few notes: A tutor of us said we can remove the XOR rax, rax because of some calling convention it's already zero. It doesn't work on my computer though so I've included it here. I'm aware

How to compile OpenSSL on Windows?

给你一囗甜甜゛ 提交于 2021-02-18 11:37:05
问题 I have been following the instructions in the OpenSSL User Guide, which links to a guide by 3noch for compiling OpenSSL. Here are the tools/versions I am using: ActiveState Perl v5.20.2 Microsoft Visual Studio 2012 Netwide Assembler (NASM) v2.12.02 OpenSSL 1.0.2j (source tarball) Following the instructions, I am able to execute the following commands without issue: perl Configure VC-WIN32 --prefix=C:\Build-OpenSSL-VC-32 ms\do_ms Then, when I go on to execute nmake -f ms\nt.mak I receive the

Error when trying to run .asm file on NASM on Ubuntu

喜你入骨 提交于 2021-02-17 08:26:10
问题 I'm using ubuntu 64-bit and trying to run a .asm file on NASM. But it returns this error when I try to run the following code. What Iḿ trying to do is build an executable by compiling (or assembling) object file from the source $ nasm -f elf hello.asm , and then after created the file hello.o is producing executable file itself from the object file by invoking linker $ ld -s -o hello hello.o This will finally build hello executable. I'm following this tutorial http://www.faqs.org/docs/Linux

Implementing a flow “(1) if {…} else if {…} … (2)” in Assembly

五迷三道 提交于 2021-02-17 05:57:57
问题 I have the following flow in C: // some stuff1 //................ if (something1) { func1(); func2(); } else if (something2) { func3(); func4(); } // some stuff2 I wonder, how can I encode that in Assembly? I mean, not exact intructions, but the flow. Should I use labels for jumping to what's inside if (something1) { ...} and "else if (something2)"? How would I return then to "// some stuff2"? ; some stuff1 ; and then cmp [some_struc], SOME_CONST je .... ???? cmp [some_struc], SOME_CONST2 je

Subtracting two characters

我的未来我决定 提交于 2021-02-16 18:13:12
问题 I just started programming in assembly so I am a beginner. To practice, I am trying to rewrite a basic libc in assembly (NASM Intel syntax). But I'm stuck on the strcmp function: ;; Compare two C-style NUL-terminated strings ;; Inputs : ESI = address of s1, EDI = address of s2 ;; Outputs : EAX = return an integer less than, equal to, or greater than zero if s1 is found, respectively, to be less than, to match, or be greater than s2 strcmp: call strlen mov ecx, eax ; ecx = length of the string

What is the explanation of this x86 Hello World using 32-bit int 0x80 Linux system calls from _start?

我的梦境 提交于 2021-02-15 07:50:37
问题 section .text global _start ;must be declared for using gcc _start: ;tell linker entry point mov edx, len ;message length mov ecx, msg ;message to write mov ebx, 1 ;file descriptor (stdout) mov eax, 4 ;system call number (sys_write) int 0x80 ;call kernel mov eax, 1 ;system call number (sys_exit) int 0x80 ;call kernel section .data msg db 'Hello, world!',0xa ;our dear string len equ $ - msg ;length of our dear string This is a basic 32-bit x86 Linux assembly code to print "Hello, World!" on

What is the explanation of this x86 Hello World using 32-bit int 0x80 Linux system calls from _start?

谁说我不能喝 提交于 2021-02-15 07:50:13
问题 section .text global _start ;must be declared for using gcc _start: ;tell linker entry point mov edx, len ;message length mov ecx, msg ;message to write mov ebx, 1 ;file descriptor (stdout) mov eax, 4 ;system call number (sys_write) int 0x80 ;call kernel mov eax, 1 ;system call number (sys_exit) int 0x80 ;call kernel section .data msg db 'Hello, world!',0xa ;our dear string len equ $ - msg ;length of our dear string This is a basic 32-bit x86 Linux assembly code to print "Hello, World!" on