311 questions
1
vote
0
answers
49
views
Why does +JSUB in SIC/XE behave differently from LDA regarding dereferencing?
I’m learning SIC/XE assembly and I ran into a confusing behavior with addressing modes. Consider these two examples:
MOJPRG START 0
+JSUB #WRREC
HALT J HALT
WRREC RSUB
MOJPRG START 0
+JSUB ...
4
votes
0
answers
183
views
How to properly use MSVC's undocumented #pragma extern_absolute with functions?
I am looking for information about the following preprocessor #pragma directive:
#include <string>
class Base {
public:
void Test();
};
int main() {
Base b;
b.Test();
return 0;
...
3
votes
2
answers
185
views
What segment register will [SI+BP] use?
In my computer architecture class, we learned about registers (intel 8086 microprocessor) and were given exercises about determining the physical address from a line of assembly. Something like: MOV [...
1
vote
1
answer
101
views
Correct immediate range of ldr in apple arm, possible clang assmbler bug
Running clang-as on this code produces "error: index must be an integer in range [-256, 255]"
.section __TEXT,__text,regular,pure_instructions
.p2align 2
_foo:
...
8
votes
1
answer
304
views
Why do GCC and Clang stop using RIP-relative loads for arrays bigger than 16MB?
My understanding is that RIP-relative addressing should work for offsets up to 2GB in size, but for some reason GCC (14.2) and Clang (19.1.0) stop using it when grabbing values more than 16MB away.
...
2
votes
1
answer
114
views
What is addressing mode [IndexReg * ScaleFactor + Offset] used for?
In X86 assembly, what type of operations use the addressing mode with this format?
IndexReg * ScaleFactor + Offset
mov rax, [r15 * 8 + 56]
4
votes
0
answers
126
views
FASM/NASM/GCC don't optimize [RBP + reg] addressing modes to use RBP as the index, costing an extra byte of code size?
I have assembled the (somewhat weird) instruction ADD EAX, DWORD PTR [RBP + RAX*1] with GCC, FASM and NASM. All of them produce the following suboptimal output
0: 03 44 05 00 add eax,...
0
votes
1
answer
164
views
Need clarification on the dummy read in absolute X indexed
While messing around with an emulator, I came across the following note (see here):
Note on the MOS 6502:
The value at the specified address, ignoring the the addressing mode's
X offset, is read (and ...
1
vote
1
answer
88
views
In MASM what is array[4]
I have a code in MASM, which contains
mov bx, 4
mov ax, array[bx] + 4
So array[4] here is the fifth element of the array or 4 bytes and then we add 4 bytes ?
What will be the value of AX then?
2
votes
1
answer
2k
views
Struggling to understand 'Zero-Page Indirect Address Indexed by Y' for the 6502 Assembly Language
This is specifically for the NES console which uses a slightly modified 8-bit 6502 microprocessor. Below follows the code with my comments explaining what each line does as far as my basic ...
1
vote
2
answers
306
views
How is address arithmetic handled in NASM for x86 in hardware
If I have an address in the rbx register and use an instruction like
mov rax, [rbx+1]
Is rbx+1 computed in hardware during runtime? If so are some registers used or is there a dedicated hardware ...
1
vote
2
answers
244
views
Why do parentheses do different things based on context in AT&T syntax?
I'm taking a class that deals with assembly. A few friends and I are debating what the difference between %rdi and (%rdi) in the following contexts:
Let's say RDI holds the character value 'w' in ...
3
votes
1
answer
440
views
32-bit registers in addressing modes in 64-bit assembly not allowed?
What is wrong with the following instruction:
movb $0xF, (%ebx)
The answer states that %ebx cannot be used as an address register. I am new to assembly so can someone explain what this means?
If the ...
1
vote
1
answer
178
views
How to interpret memory reference on right side of assembly equation?
I am trying to chase down an exception within some previously existing ARM assembly code. The line in question is:
ldr x0, [x21, x19, lsl #3]
The result of the above equation is x0 having an ...
0
votes
1
answer
275
views
Is there a way to dereference a pointer stored in memory?
I'm trying to store a pointer in a variable located on memory. How could I dereference it?
I'm trying to do it like this:
pointer: db 0 ; the pointer variable
var: db 44 ; the normal variable
...