Questions tagged [assembly]

Assembly language (asm) programming questions. BE SURE TO ALSO TAG with the processor and/or instruction set you're using, as well as the assembler. WARNING: For .NET assemblies, use the tag [.net-assembly] instead. For Java ASM, use the tag [java-bytecode-asm] instead.

0
votes
0answers
7 views

Why doesnt my switch to 16 bit function written in assembly return to my kernel?

I am making a small operating system and I want to make stuff about video modes ( like getting vesa info, setting video mode ) and it is really hard to do so in 32 bit So I decided to switch back to ...
-1
votes
1answer
6 views

IM having trouble trying to run my assembly code, on ubuntu x64 bit sys

Im having trouble running assembly code on ubuntu. Im getting a 'undefined reference to _printf' MakeFile: nasm -f elf64 hello.asm # assemble the program ld -s -o hello hello.o ./hello # ...
0
votes
0answers
7 views

How to sort 3 variables without using loops in Assembler?

I want to write a program in assembler that asks user about 3 variables, then the user write the numbers to the registers ( I know how to write that), but now I have a problem: I have to sort these 3 ...
0
votes
0answers
5 views

MIPS : parsing and modifying a string

I have to write a program in MIPS where I have to open a file whose name is entered by the user and parse it,using the MARS simulator . However, since the syscall 8 (which reads a string from user ...
1
vote
1answer
39 views

Assembling this code in linux gives me syntax errors

I've have a raspberry pi that I use for University purposes. Since at home I don't have a monitor, I decided to code in assembly from my laptop, using Lubuntu. The problem is, even if this works when ...
0
votes
1answer
12 views

How to determine if ModR/M is needed through Opcodes?

I am reading the ia-32 instruction format and found that whether ModR/M is one byte if required, but how to determine if it is required, someone says it is determined by Opcode, but how? I want to ...
0
votes
0answers
27 views

Why won't this change the values of some of the elements in array1 in memory?

I wrote some assembly code on Keil where if an element in array is < 5, the program increments that element. Trouble is, the ARM code does not change the values of array1 in memory. What changes do ...
0
votes
1answer
31 views

How to encode the operands for a sub immediate 83 /5 opcode, like sub edx, 0x3a?

I'm having trouble looking at assembly instructions such as this in GAS syntax subl $0x3a, %edx and then being able to use the Intel manual to manually produce the matching machine code which ...
0
votes
0answers
22 views

How to use for loop in Assembly?

I was tasked to do a code that would output the equal amount of 'Text Here' depending on the user input. However, I seem to get bewildered by my cmp function. ;Get keyboard input mov ah, 01h int ...
2
votes
1answer
30 views

How to implement logical OR || in an if() condition in easy68k?

Suppose I have a to compare a data register and i have to compare it to equalling one of 2 numbers. how would i go about that? I know how to do it for just comparing with one number not 2. CMP #0, ...
0
votes
0answers
23 views

Why is my function not looping? And how would I create this function in ARM Assembly?

Click for question description This code is implemented using ARM assembly and there is a main function calling the magic number function inputting the 'Yusuf Ozturk' /* * AssemblyFunctions.S * */...
2
votes
2answers
51 views

How to pass structs to C function from x86-64 assembly on Mac (NASM)

From here: nanosleep((const struct timespec[]){{0, 500000000L}}, NULL); It passes a struct. I am not sure how to pass structs to the syscall or library functions via registers. Wondering if one can ...
0
votes
0answers
61 views

How to call C function from x86-64 Assembly on Mac (stack alignment and/or Makefile build issues)

tl;dr I am getting a few different errors depending on how I try to call a C _print function from x86-64 assembly. I would like to get it printing by calling the C function, so I know I can call C ...
0
votes
0answers
26 views

Assembly: Syscall is being skipped

I have the following assembly code down here. Basically I want to execute sys_write syscall twice to write something to stdout. section .text global _start _start: ;write hello world ...
0
votes
0answers
12 views

Data pseudoinstruction in CPUSIM

We are required to create a machine in cpusim.This are the text instruction that are given by our Prof. Start: load data1 ; add data2 ; store data1 ; load data3 ; add ...
-1
votes
0answers
56 views

How to move code to video memory (NASM, x86)

This is a followup to x86 Assembly : How to move code to video memory and execute the code?, using NASM instead of MASM, and trying to use the advice I got there. Previous question : I’m working on ...
0
votes
0answers
28 views

How to use the monitor / mwait instructions in x86-64 assembly on Mac or baremetal

Originally I asked about umonitor and umwait, but it turns out as @harold suggested, that you can't even buy a processor that has those instructions yet. So this question is about monitor and mwait, ...
1
vote
2answers
42 views

If there is any pausing/sleeping or events in x86 assembly

I am wondering if there is anything at the assembly level in x86-64 that allows you to sleep/wait, such that no instructions are run until the wait is done. I have seen the WAIT and PAUSE instructions,...
1
vote
0answers
33 views

What address regions are protected/forbidden by the linux kernel?

I'm experimenting with the ELF file format, and I haven't yet figured out the pattern here. Here is a minimal ELF file: $ cat zero.asm .text .global _start _start: movl $0,%ebx # ...
0
votes
1answer
26 views

Is the difference between programming model wrt Program Counter and Stack Pointer in case of Assembly?

Processor model I ● Registers  PC – Program Counter  Single data register (accumulator) without name  We will use symbol A to describe operations on this register ● Stack with ...
0
votes
1answer
22 views

How to print signed integer in x86 assembly (NASM) on Mac

I found an implementation of unsigned integer conversion in x86 assembly, and I tried plugging it in but being new to assembly and not having a debugging env there yet, it's difficult to understand ...
0
votes
1answer
29 views

X86-64 passing float and int as arguments

When passing a float to a function as the first argument the %xmm0 register gets set. What if we want to pass an integer as the second argument in the function. Which one of %rdi or %rsi gets the ...
0
votes
1answer
37 views

How to get length of long strings in x86 assembly to print on assertion

I am trying to build an x86 program that reads a file into memory. It uses a few different syscalls, and messes with memory and such. There's a lot in there to figure out. To simplify debugging and ...
0
votes
1answer
39 views

Trying to understand this MIPS function that branches if its input is negative

I'm reading the following excerpt about assembly language code: "Labels can be used in assembly in replace[sic] of calculating exact values for branch and jump instructions. The following is an ...
1
vote
1answer
38 views

How to load C library functions into assembly, and use assembly library functions in another C or assembly project

Currently I am building a foo.h and foo.c with: $ clang -I . -dynamiclib \ -undefined dynamic_lookup \ -o foo.dylib foo.c I am able to use this in other C libraries like this: clang -I . -...
0
votes
1answer
24 views

MIPS - Reading double from stack

I have problems with MIPS. I can store and write floats on the stack without any problems. But If I try to do the same thing with a double, the following message appears: Error in line 12: Runtime ...
0
votes
0answers
34 views

Shared memory between threads on assembly level

So i have program in C that creates threads using pthread library and calls function written in assembly. My question is: How can I get shared memory between threads that run assembly code? I know ...
0
votes
0answers
27 views

Segmentation fault in a program that uses scanf [duplicate]

I have problem with assembly program on my VirtualBox. On VB I have Linux Mint(64 bit). I tried to compile this assembler code(in file my_file.asm): extern printf extern scanf section .data ...
0
votes
1answer
14 views

ld linker script, mark section RW

I do not understand why my linker script is not working as expected, I am compiling my assembly code using nasm -f elf64 file.asm and later I link it using my custom linker script ld -o file....
-1
votes
0answers
43 views

What does the call to: intel fast memset means in assembly code?

In this simple for loop for(k=0;k<Nbody;k++){ r[k] = 0.0; } the generated assembly is this: movl $r, %edi xorl %esi, %esi movl $32768, %edx call ...
0
votes
2answers
40 views

ARM assembly appending multiple bits

The aim of my program is to take the value in register 0 and copy it in the form '1011' into register 1. EDIT I did not initially make this clear, not to be achieved with a simple mov, the goal was ...
1
vote
1answer
92 views

Is there no stack segment? Is it simply a concept?

I have been doing some tests and realized that it is wrong to say that the stack segment exists, because when I analyze a binary, I realized that any data type, which is neither in the register nor in ...
0
votes
0answers
25 views

CMP and JMP kick off when char is found, but does not run what's within the operation label

I'm building a basic x86 calculator. I am trying to make the calculator increment in a loop in pebbleStorage, so i can print however many pebbles are collected during each round of input (whether ...
0
votes
1answer
41 views

Different asm on Windows x64 from a CS:APP x86-64 Linux example function for swapping a long

i am reading CS:APP 3rd edition (Ch3. pic 3.7 GAS assembly code) long exchange(long* xp, long y) { long x = *xp; *xp = y; return x; } exchange: movq (%rdi), %rax movq %rsi, (%rdi) ...
-2
votes
0answers
28 views

Stuck in running pk on ariane [on hold]

I want load and run simple program through pk on Ariane, but has some problems on running pk. Follow are my steps: 1) pk -> pk.bin 2) parting sdcard 3) write pk.bin into sdcard partition 1 :sudo ...
2
votes
1answer
79 views

How to properly create a kernel in C and link to bootloader

I have a simple bootloader in assembly here: ;initialization type stuff [bits 16] [org 0x7c00] ;make message and print it mov si, MESSAGE call print ;infinite loop to stall jmp $ ;print "method" ...
0
votes
0answers
11 views

Error: Invalid combination of opcodes and operands in nasm 64 bit [duplicate]

I am a newbie for nasm 64 bit. So, please help me in fixing the error in below asm code. error: invalid combination of opcode and operands in nasm 64 bit %macro HandleException0x00 0 global ...
0
votes
0answers
11 views

Assembly Stdin / Stdout [duplicate]

I am prettey new to assembly and confused about a very basic topic. mov ah,01h ; int 21h mov dl,al; line 3 mov ah,02h ; display a character int 21h int 20h ; exit to dos I find the code above to ...
0
votes
0answers
19 views

Why does not print the number in assembly

I'm trying to make a program in assembler about Fibonacci secuence, but when I try to print out the number, prints symbols. I run out of ideas. What am I doing wrong? This is the code I've done: ...
0
votes
1answer
15 views

I get an EFAULT error from open after using file_name equ “a.txt”?

I got an error message when running my assembly x86-64 program called time2.asm. I am using Ubuntu x86-64. after executing sys_open syscall, rax register changes its value to -14 - which means ...
0
votes
0answers
23 views

Reading a file in MASM

I'm trying to open a file for reading, read from it, manipulate the data and then write it back to the file. I have to use the CreateFile, GetFileSize, VirtualAlloc, ReadFile/WriteFile, CloseHandle ...
0
votes
1answer
20 views

How can I properly multiply two 4x4 arrays in MIPS assembly in row-major order?

for an assignment in my assembly programming course, I am to multiply two 4x4 matrices and store the result in row-major order and then column-major order. I have coded the functions for the row-major ...
0
votes
1answer
33 views

Crash using movapd with aligned memory

I have a block of memory allocated with malloc using 64 bit NASM on Windows. When I use movapd (move two aligned packed double-precision floating-point values), my program crashes, but I can use ...
2
votes
1answer
37 views

Boot loader keeps adding eax to al

I'm trying to build my first bootloader, and it actually works, but thers is one thing that happens, according to gdb, that I don't understand. This is my bootloader written in nasm: org 0x7c00 ...
0
votes
0answers
43 views

How to reference r8-r15 registers in gcc inline assembly? [duplicate]

Example: __asm__ __volatile__("rdrand %%rax\nrdrand %%rbx\nrdrand %%rcx\nrdrand %%rdx\n" : "=a" (varr[0]), "=b" (varr[1]), "=c" (varr[2]), "=d" (varr[3]) in this example, I can ...
-2
votes
0answers
23 views

Can any assembly be directly executed by a CPU without intermediate steps? [duplicate]

Assembly is a type of programming language, which can be directly executed by a CPU, without any intermediate step? True or False?
-2
votes
1answer
21 views

Check input if it is a letter, number, or special character in assembly language

Just like the title, I’m sorry but i’m really new to this language and it would greatly help if someone could help me.
1
vote
1answer
23 views

SegFault when calling function in asm

I started to learn calling a function in assembly. I followed much tutorial in the internet and make some modification to it. But it doesnot really work as expected. .data hello: .ascii "hello ...
-1
votes
1answer
63 views

Why does the Linux Open system call not need a buffer size parameter for the path?

Why does the open system call not need a buffer size parameter like the write system call does? How do these two system calls treat their string parameters differently? Does the open system call ...
1
vote
1answer
33 views

How to manipulate certain registers on assembly on PIC (18F452)?

I have a register called TEST and I want to invert (toggle?) bits 1 and 2 and also put zero to bits 3 and 4. I have just started learning assembly and I do not know how to check whether my solution ...

http://mssss.yulina-kosm.ru