Skip to main content

Questions tagged [assembly]

Assembly language questions. Please tag the processor and/or the instruction set you are using, as well as the assembler, a valid set should be like this: ([assembly] [x86] [gnu-assembler] or [att]). Use the [.net-assembly] tag instead for .NET assemblies, [cil] for .NET assembly language, [wasm] for web assembly, and for Java bytecode, use the tag java-bytecode-asm instead.

1 vote
1 answer
73 views

RISC-V assembly: global pointer set to a weird value

I am experimenting with RISC-V assembly language on an emulator (qemu64, ubuntu for RISC-V). Here is a simple program, its function is to convert the instr string to uppercase, outstr is the resulting ...
Wheatley's user avatar
  • 214
0 votes
1 answer
36 views

x86 NASM Crash - Iterate over string

How to iterate over individual characters of a string in x86 assembly and print them? global _main ; declare _main entry point extern _printf ; extern method section ....
OutOfBrainExcepction's user avatar
0 votes
0 answers
40 views

How can I disassemble a whole obj file in valid asm, amend some sections of such asm code and reassemble to obj?

Is it possible on Linux to use objdump (or any other utility) to fully disassemble an obj file to asm code, modify such code and then pass the asm to as? The challenge I have with objdump is that it ...
Emanuele's user avatar
  • 1,428
20 votes
2 answers
1k views

How to prepare stack pointer for bare metal Rust?

I'm trying to write an x86 bootloader and operating system completely in Rust (no separate assembly files, only inline assembly within Rust). My bootloader works completely as intended within the QEMU ...
suman's user avatar
  • 305
5 votes
1 answer
116 views

Logical shift right without dedicated shift instruction

I am working with an assembly language that does not contain either multiply, divide, or bit-shift instructions. I am aware that a left bit-shift can be achieved by just adding the same number to ...
Kestrel's user avatar
  • 73
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 ...
Kenshi's user avatar
  • 11
-1 votes
1 answer
44 views

Does stack work differently in assembly than how it works in C?

I just started learning assembly code. As far as I understand, when a functions calls in assembly code, the main variables are stored to stack from registers and stored back to registers after ...
uykb's user avatar
  • 11
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 ...
Newlearner826's user avatar
1 vote
1 answer
44 views

E2028: _small_code_ is an undefined reference

I am working on my own bootloader. I want it to print "Hello world". For some reason, I get an error: Error! E2028: small_code is an undefined reference Hello! I am working on my own ...
Артем Соколов's user avatar
0 votes
1 answer
35 views

Print the greatest number in assembly programming

Trying to print the greatest number (a & b) by using the below assembly code. But it is printing the "first" (Welcome) message only. I just want to print the "second" (i.e ...
Jai K's user avatar
  • 387
2 votes
2 answers
53 views

Forth: What is the standard way to define a word using machine code?

I wrote a Forth interpreter in Assembler (core set), but is there a standard way to define a Forth word using Assembler instructions or directly machine code? Example I want to define "+" (...
Candid Moe's user avatar
3 votes
1 answer
42 views

Why are multiple B.Cond statements always resolving only one way for variable input?

Utilizing arm64, on qemu. I want to check whether a user inputted value is negative, positive, or zero. I have a SUBS instruction, followed by three B.Cond instructions. I'm using scanf with a %d ...
DPorter's user avatar
  • 33
2 votes
0 answers
76 views

How does this assembly code perform the source code b = a/3 when a = 2? [duplicate]

I'm trying to trace this C source code (when a = 2): b = a/3; To this ARM assembly code (for unsigned 1 byte value): ldrb r2, [fp, #-6] @ zero_extendqisi2 @ tmp162, a ldr r3, .L34 @ tmp164, ...
Evan Lehr's user avatar
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 ...
Angadh's user avatar
  • 21
2 votes
1 answer
50 views

Why does the code show only some white lines when you compiled it?

.MODEL SMALL .STACK 100h .DATA COLUMNA DW ? FILA DW ? AVANCEH DW ? AVANCEV DW ? .CODE DETENER_POR_TIEMPO PROC MOV CX, 2000h MOV DX, 2000h MOV BX, 2000h NOP RET DETENER_POR_TIEMPO ...
Betsy CamachoM's user avatar

15 30 50 per page