Questions tagged [basm]

BASM = Borland/Codegear/Embarcadero's Built-In Assembler, the Delphi inline assembler

50 questions
24
votes
13 answers

Intel x86 assembly optimization techniques for expanding 8 bits to 8 boolean bytes of 0 or 1

I am learning assembler quite a while and I am trying to rewrite some simple procedures \ functions to it to see performance benefits (if any). My main development tool is Delphi 2007 and first examples will be in that language but they can be…
Wodzu
  • 6,932
  • 10
  • 65
  • 105
13
votes
2 answers

What CPU registers are to be restored at the end of an asm procedure in Delphi

When writing a Delphi procedure or function in assembly code, which registers must be saved and restored to the original value at the end of the procedure? When calling another Delphi procedure or function from (inline) assembly code, what can I…
Servaas
  • 133
  • 5
9
votes
2 answers

Why eax gives zero if it contains self?

According to the "Using Assembler in Delphi", eax will contain Self. However, the content of eax is 0 as shown. I wonder what is wrong ? procedure TForm1.FormCreate(Sender: TObject); var X, Y: Pointer; begin asm mov X, eax mov Y, edx …
SOUser
  • 3,802
  • 5
  • 33
  • 63
8
votes
1 answer

How to probe the availability of Intel® Advanced Vector Extensions?

How can I check using Delphi 2007 that a box is AVX capable. My question is only restricted to querying the support in the CPU (Assumption is made that the OS is OK / Windows 7 with SP1). The PDF document entitled Introduction to Intel® Advanced…
menjaraz
  • 7,551
  • 4
  • 41
  • 81
8
votes
5 answers

Delphi read overflow flag

If I do this var a,b,c:cardinal; begin a:=$80000000; b:=$80000000; c:=a+b; end; c will equal 0, since the addition overflowed. What's the best way to catch this overflowed boolean? (a+b
Stijn Sanders
  • 35,982
  • 11
  • 45
  • 67
8
votes
5 answers

procedure that swaps the bytes (low/high) of a Word variable

I have this procedure that swaps the bytes (low/high) of a Word variable (It does the same stuff as System.Swap function). The procedure works when the compiler optimization is OFF but not when it is ON. Can anybody help me with this? procedure…
Gabriel
  • 20,797
  • 27
  • 159
  • 293
7
votes
5 answers

Good Resources for using Assembly in Delphi?

Question Are there any resources for learning how to use assembly in Delphi? Background Information I've found and read some general assembly and instruction set references (x86, MMX, SSE etc). But I'm finding it difficult to apply that information…
Shannon Matthews
  • 9,649
  • 7
  • 44
  • 75
7
votes
3 answers

Removing the prologue of a function written in pure assembly

I am using Delphi 2010. Is it possible to tell Delphi to not generate a prologue for a function? I'm writing some pure assembly functions like this: procedure SomeAssembly; stdcall; begin asm ... end; end; and I would like to tell…
K. Charles
  • 73
  • 3
7
votes
2 answers

Why Delphi compiler does not inline assembly functions?

Sometimes I write very short assembly functions like function SeniorBit(Value: LongWord): Integer; asm OR EAX,EAX JZ @@Done BSR EAX,EAX INC EAX @@Done: end; that seems to be the best candidates for…
kludg
  • 27,213
  • 5
  • 67
  • 118
7
votes
4 answers

How to use align-data-move SSE in Delphi XE3?

I was trying to run the following, type Vector = array [1..4] of Single; {$CODEALIGN 16} function add4(const a, b: Vector): Vector; register; assembler; asm movaps xmm0, [a] movaps xmm1, [b] addps xmm0, xmm1 movaps [@result],…
justyy
  • 5,831
  • 4
  • 40
  • 73
6
votes
3 answers

How to probe a computer if it supports SSE2 in Delphi 32?

The c++ way to do it is here (under Windows). The same answer but under Linux using GCC. Excerpt of the relevant asm code as I understand it: mov eax, 1 cpuid mov features, edx I'm not very comfortable at BASM. My Question: I need to wrap…
menjaraz
  • 7,551
  • 4
  • 41
  • 81
6
votes
1 answer

How to read data from absolute address in delphi XE2

Let's say that I want to read from absolute address gs:$30 in 64bit mode, so the asm code looks something like: asm mov rax, gs:[$30] end; ...and compiler translate this code to... 65 48 8B 05 30 00 00 00 mov rax,gs:[rel $00000030] But…
GJ.
  • 10,810
  • 2
  • 45
  • 62
6
votes
2 answers

Translate Delphi style ASM to English?

A recent Delphi project i've inherited has a procedure in ASM. I'm a complete ASM newbie, so i dont understand it. I've read up on the various ASM instructions to try and decipher the procedures flow, but i still dont get it. Could someone with…
Rucia
  • 249
  • 1
  • 9
6
votes
2 answers

unusual behaviour in delphi assembly block

I am running into some weird behaviour with Delphi's inline assembly, as demonstrated in this very short and simple program: program test; {$APPTYPE CONSOLE} uses SysUtils; type TAsdf = class public int: Integer; end; …
Okey
  • 105
  • 5
6
votes
3 answers

Checking parameters of multiplication by constant in 64 bit

For my BigInteger code, output turned out to be slow for very large BigIntegers. So now I use a recursive divide-and-conquer algorithm, which still needs 2'30" to convert the currently largest known prime to a decimal string of more than 22 million…
Rudy Velthuis
  • 28,387
  • 5
  • 46
  • 94
1
2 3 4