assembly

transpose for 8 registers of 16-bit elements on SSE2/SSSE3

(I'm a newbie to SSE/asm, apologies if this is obvious or redundant) Is there a better way to transpose 8 SSE registers containing 16-bit values than performing 24 unpck[lh]ps and 8/16+ shuffles and using 8 extra registers? (Note using up to SSSE 3 instructions, Intel Merom, aka lacking BLEND* from SSE4.) Say you have registers v[0-7] ...

32bit to 64bit inline assembly porting

I have a piece of C++ code (compiled with g++ under a GNU/Linux environment) that load a function pointer (how it does that doesn't matter), pushes some arguments onto the stack with some inline assembly and then calls that function, the code is like : unsigned long stack[] = { 1, 23, 33, 43 }; /* save all the registers and the stack p...

how to identify the n,i,x, and e bit settings(SIC/XE)?

I have a project for my System Software class, we have to produce a subroutine to decompose a line of source into 4 components: label, op code, operand1, and operand2, and identify the n,i,x and e bit settings. I'm having a problem trying to figure out the nixbpe bit. thank you in advance for your help here are some examples: Compon...

setcontext and makecontext to call a generic function pointer

In another question i had the problem to port the code unsigned long stack[] = { 1, 23, 33, 43 }; /* save all the registers and the stack pointer */ unsigned long esp; asm __volatile__ ( "pusha" ); asm __volatile__ ( "mov %%esp, %0" :"=m" (esp)); for( i = 0; i < sizeof(stack); i++ ){ unsigned long val = stack[i]; asm __volatil...

What are CFI directives in Gnu Assembler (GAS) used for?

There seem to be a .CFI directive after every line and also there are wide varities of these ex.,.cfi_startproc , .cfi_endproc etc.. more here. .file "temp.c" .text .globl main .type main, @function main: .LFB0: .cfi_startproc pushq %rbp .cfi_def_cfa_offset 16 movq %rsp, %rbp .cfi_offset 6, -16...

How could I represent a interrupt (for microcontrollers) in a flowchart?

Does anyone have any visual examples? ...

No Program Entry Point TASM Error

I'm trying to develop a simple kernel using TASM, using this code: ; beroset.asm ; ; This is a primitive operating system. ; ;********************************************************************** code segment para public use16 '_CODE' .386 assume cs:code, ds:code, es:code, ss:code org 0 Start: mov ax...

Problem with bootstrap loader and kernel

We are working on a project to learn how to write a kernel and learn the ins and outs. We have a bootstrap loader written and it appears to work. However we are having a problem with the kernel loading. I'll start with the first part: bootloader.asm: [BITS 16] [ORG 0x0000] ; ; all the stuff in between ; ; the bottom of ...

gas: too many memory reference

when compiling the instruction movl 4(%ebp), 8(%ebp) i got 'too many memory referene', what's wrong with it?? ...

Segment register, IP register and memory addressing issue!

In the following text I asked two questions and I also described that what I know about these question so that you can understand my thinking. Your precious comments about the below text are required. Below is the Detail of 1ST Question As we know that if we have one mega byte memory then we need 20 bits to address this memory. Another...

"C variable type sizes are machine dependent." Is it really true? signed & unsigned numbers ;

Hello, I've been told that C types are machine dependent. Today I wanted to verify it. void legacyTypes() { /* character types */ char k_char = 'a'; //Signedness --> signed & unsigned signed char k_char_s = 'a'; unsigned char k_char_u = 'a'; /* integer types */ int k_int = 1; /* Same as "signe...

branch prediction

Consider the following sequence of actual outcomes for a single static branch. T means the branch is taken. N means the branch is not taken. For this question, assume that this is the only branch in the program. T T T N T N T T T N T N T T T N T N Assume a two-level branch predictor that uses one bit of branch history—i.e., a one-bit B...

What are the calling conventions for UNIX & Linux system calls on x86-64

Explains both UNIX (BSD flavor) & Linux system call conventions for x86-32: http://www.int80h.org/bsdasm/#system-calls http://www.freebsd.org/doc/en/books/developers-handbook/x86-system-calls.html Can any one please tell me or point me to similar doc for x86-64 on both UNIX & Linux? ...

Changing code at runtime

I have a pointer to a function (which i get from a vtable) and I want to edit the function by changing the assembler code (changing a few bytes) at runtime. I tried using memset and also tried assigning the new value directly (something like mPtr[0] = X, mPtr[1] = Y etc.) but I keep getting segmentation fault. How can I change the code?...

What does ESP mean in assembly?

ESP = ? stack pointer What does E stand for here? UPDATE RSP for 64bit? What does R mean here? ...

Having problem understanding Standard Entry Sequence

Standard Entry Sequence: _function: push ebp ;store the old base pointer mov ebp, esp ;make the base pointer point to the current ;stack location – at the top of the stack is the ;old ebp, followed by the return address and then ;the parameters. sub esp, x ...

Assembly Language Question: Display Characters to screen LIFO (Last In First Out) in assembly language

Given a stack that displays characters to the screen First in First Out(FIFO), how do you switch it to display them Last in First Out(LIFO). Theoretically speaking... is it simply just sending the characters to print in reverse order? ...

Directly Jump to another C++ function

I'm porting a small academic OS from TriCore to ARM Cortex (Thumb-2 instruction set). For the scheduler to work, I sometimes need to JUMP directly to another function without modifying the stack nor the link register. On TriCore (or, rather, on tricore-g++), this wrapper template (for any three-argument-function) works: template< class...

How can I go about writing to the console in fasm?

The code I currently have can be found at: http://fasm.pastebin.com/yY3C0aVF I'm exceptionally new to assembly, only picked it up yesterday and I've looked through many an example and still can't figure out for myself how to write to the console. I always get an error when I seem to replicate it in my own way. If I'm not on the right t...

Insight into how things get printed onto the screen (cout,printf) and origin of really complex stuff that I cant seem to find on textbooks

I've always wondered this, and still haven't found the answer. Whenever we use "cout" or "printf" how exactly is that printed on the screen?. How does the text come out as it does...(probably quite a vague question here, ill work with whatever you give me.). So basically how are those functions made?..is it assembly?, if so where does th...