Skip to content
Advertisement

Tag: nasm

Segmentation fault when using memory with custom ELF file

I am trying to program a small ELF program with a custom ELF header but have a segmentation fault whenever i am writing to memory. Why would that code trigger a segmentation fault ? %assign LOAD_ADDRESS 0x08048000 BITS 32 org LOAD_ADDRESS ; load address ehdr: ; Elf32_Ehdr db 0x7F, “ELF”, 1, 1, 1 ; e_ident times 9 db 0 ;

Pass values from C program to Assembly language

I would like to pass values from C program to Assembly using the linked assembly method instead of inline assembly method in C. Below is the Assembly program(GCD) which is am working on. And this is the C program from with I am trying to pass the values to assembly program When I compile using the below method and run

NASM division using variables instead of actual values

I’m learning some basic arithmetic using NASM on Linux. I need to divide two numbers using variables NUMBER1 and NUMBER2. My code works if I type in actual value instead of variables. For example if I type in ‘6’ instead of NUMBER2 and ‘2’ instead of NUMBER1, the program does division and gives me answer of 3. Running code with

Reading user input as an integer

I wrote an Assembly program (x86_64 Linux NASM) that prints an integer to console, based in the algorithm suggested my the comments in this post, which is basically this: All works just fine under the following script: After compiling it, the number 567 gets printed on the screen (console). But if I try to do the same but allowing the

Assembly NASM x86 – Simple Stack Project

I’m writing a subroutine to simply reprint decimal numbers as strings using the stack, but not getting the values I expected. When I run it through the debugger I see that I can’t get the value from esi into al. I suspect that I’m not allowed to use esi in the manner that I am, but I’m not sure on

How is the $ token treated when used under a label vs in a single line?

The NASM manual includes the following on the $ token in section 3.5: $ evaluates to the assembly position at the beginning of the line containing the expression and earlier in section 3.1 there is a note about source lines: NASM uses backslash () as the line continuation character; if a line ends with backslash, the next line is considered

Converting User Input Hexadecimal to Decimal in Assembly

I am trying to create an assembly program that takes a user input hexadecimal number no greater than 4 digits and outputs the same number in base 10. This is being done using NASM on a Linux install. Using some tutorials I’ve found and my very limited understanding of this language, I have come up with this. It should be

Advertisement