All Questions
4,616
questions
1
vote
0
answers
32
views
Unable to compile NASM without -no_pie on macOS
I'm trying to follow the tutorial for NASM and I made a few adjustments (like changing the entrypoint function from "start" to "_main") to get the following hello.asm to compile ...
0
votes
0
answers
49
views
How can I get this STDIN to work in GAS Assembler running on Linux?
I am new to Assembler and am currently reading a book about it by Jonathan Bartlett called 'Learn to Program with Assembly'. On pages 160-1 he gives the following sample program to demonstrate the use ...
0
votes
0
answers
30
views
Why is my assembly code giving extra output? [duplicate]
Before I start, it's important to say I am a complete beginner to Assembly, so I might be missing something very obvious.
I was trying to make an Assembly program where it prints the following output ...
1
vote
0
answers
48
views
Assembly jump instructions don't seem to work
bits 64
default rel
section .data
fmt db "%s", 0xd, 0xa, 0
err db "Correct usage: echo <string>"
section .text
extern printf
extern ExitProcess
global ...
3
votes
0
answers
51
views
How to pass arguments to a windows syscall in NASM assembly? [duplicate]
I am learning how to implement direct system calls using nasm assembly and c code, I have created a funcs.asm that contains
section .text
global NtOpenProcess
NtOpenProcess:
mov rax, 26h
...
4
votes
0
answers
59
views
Why does Intel x86 manual use +rd instead of +ro or +rq for 64-bit registers?
The description of the PUSH instruction in the Intel manual (PDF, Volume 2, Chapter 4.3, PUSH) contains the line 50+rd PUSH r64. It seems +rd is used throughout most of the instruction descriptions ...
0
votes
1
answer
47
views
Debugging assembly to call IUnknown::Release - is shadow space right?
I am getting a bug where sometimes this code works sometimes it does not:
48 8B 41 08 ; MOV RAX, [RCX + 0x08] gets the refcount
48 FF C8 ; DEC RAX ; decrement ...
1
vote
0
answers
64
views
How to Fix IMUL and DIV Errors in Assembly Calculator Code?
I'm currently learning assembly language and trying to write a simple calculator program. The program is supposed to read two numbers and an operator (+, -, *, /) from stdin, perform the specified ...
3
votes
1
answer
63
views
How to get NASM to encode `push` with a sign-extended 16-bit immediate?
When assembling the following with NASM:
BITS 64
push 32767
I get 68 ff 7f 00 00. This is interesting to me, since this is the 32b encoding (push dword). Any ideas why it doesn't resort to the 16b ...
1
vote
0
answers
66
views
Assembling with gcc gives error operand type mismatch for `cmp' for some integers, not others
This is a weird one. I'm using gcc to assemble a program and I want to know if the value in register rsi fits in 32 bits, so I use this instruction:
cmpq $0xffffffff, %rsi
I get back an error that ...
1
vote
1
answer
77
views
Working with 64-bit products and quotients of 32-bit integers in assembly x86-64
Starting to learn assembly x86-64, I'm writing a program that gets an array of integers and does some calculations on it. The purpose isn't relevant to the question, but the calculations include ...
2
votes
0
answers
45
views
(x86_64 NASM) Why is my program returning 0 instead of 256? [duplicate]
This is my first assembly code:
;program name - first.asm
section .data ;stores initialised var
section .bss ;stores uninit var
section .text ;actual code
global _start
_start:
mov eax,1
mov ...
2
votes
1
answer
75
views
ModR/M Historical Notation /0.../7
While learning about x64, I struggled to understand some notations in the intel manual.
Let's look at 0xC7 MOV:
opcode
instruction
Op/Enc
Description
C7 /0 iw
MOV r/m16, imm16
MI
Move imm16 to r/m16....
-1
votes
0
answers
53
views
Why does gcc not allocate space for local variable in this example? [duplicate]
This is the C code I compiled with gcc -
#include <stdio.h>
#include <stdlib.h>
int sum(int arr[20]) {
int s = 0;
for (int i = 0; i < 20; i++)
s += arr[i];
return s;...
-4
votes
0
answers
108
views
Why does the first code cause a segmentaiton fault while the later one doesn't?
I'm self-studying csapp, and currently stuck at level-3 of Attack Lab. This lab requires you to
inject some code by a 40-byte input string. The basic idea is that you input a 48-byte string,
with the ...