The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,437 other followers

Archive for the ‘x86’ Category

A refefernce to 6502 by “Remember that in a stack trace, the addresses are return addresses, not call addresses – The Old New Thing”

Posted by jpluimers on 2018/09/11

On x86/x64/ARM/…:

It’s where the function is going to return to, not where it came from.

And:

Bonus chatter: This reminds me of a quirk of the 6502 processor: When it pushed the return address onto the stack, it actually pushed the return address minus one. This is an artifact of the way the 6502 is implemented, but it results in the nice feature that the stack trace gives you the line number of the call instruction.

Of course, this is all hypothetical, because 6502 debuggers didn’t have fancy features like stack traces or line numbers.

Source: [WayBackRemember that in a stack trace, the addresses are return addresses, not call addresses – The Old New Thing

Which resulted in these comments at [WayBack] CC +mos6502 – Jeroen Wiert Pluimers – Google+:

  • mos6502: And don’t forget the crucial difference in PC on 6502 between RTS and RTI!
  • Jeroen Wiert Pluimers: +mos6502 I totally forgot about that one. Thanks for reminding me
    <<Note that unlike RTS, the return address on the stack is the actual address rather than the address-1.>>

References:

[WayBack6502.org: Tutorials and Aids – RTI

RTI retrieves the Processor Status Word (flags) and the Program Counter from the stack in that order (interrupts push the PC first and then the PSW).

Note that unlike RTS, the return address on the stack is the actual address rather than the address-1.

[WayBack6502.org: Tutorials and Aids – RTS

RTS pulls the top two bytes off the stack (low byte first) and transfers program control to that address+1. It is used, as expected, to exit a subroutine invoked via JSR which pushed the address-1.

RTS is frequently used to implement a jump table where addresses-1 are pushed onto the stack and accessed via RTS eg. to access the second of four routines.

–jeroen

Posted in 6502, 6502 Assembly, Assembly Language, Development, History, Software Development, x64, x86 | Leave a Comment »

How to check if a binary is 32 or 64 bit on Windows? – Super User

Posted by jpluimers on 2018/08/17

It seems there are a few, but only loading the binary is the sure method to know what the process will be using: [WayBackHow to check if a binary is 32 or 64 bit on Windows? – Super User and [WayBack] How do I determine if a .NET application is 32 or 64 bit? – Stack Overflow.

Details in the answers of these questions, here are a few highlights:

  • The first few characters in the binary header reveal what it was originally designed for.
  • A .NET executable might still have an x64 header for bootstrapping.
  • The Windows SDK has a tool dumpbin.exe with the /headers option.
  • You can use sigcheck.exe from SysInternals.
  • The file utility (e.g. from cygwin, which comes with msysgit) will distinguish between 32- and 64-bit executables.
  • Use the command line 7z.exe on the PE file (Exe or DLL) in question which gives you a CPU line.
  • Virustotal File detail is a way to find out if a binary is 32 bit or 64 bit.
  • Even an executable marked as 32-bit can run as 64-bit if, for example, it’s a .NET executable that can run as 32- or 64-bit. For more information see https://stackoverflow.com/questions/3782191/how-do-i-determine-if-a-net-application-is-32-or-64-bit, which has an answer that says that the CORFLAGS utility can be used to determine how a .NET application will run.

–jeroen

Search terms: win64, win32, x64, x86_64, x86

Posted in Assembly Language, Development, Power User, Windows, x64, x86 | Leave a Comment »

Grammar Zoo – Browsable Borland Delphi Assembler Grammar

Posted by jpluimers on 2018/06/12

Interesting: [WayBackGrammar Zoo – Browsable Borland Delphi Assembler Grammar.

It is very complete, including constructs like the [WayBackspecial directives VMTOFFSET and DMTINDEX for Delphi virtual and dynamic methods.

You can contribute to it using https://github.com/slebok/zoo/tree/master/zoo/assembly/delphi

–jeroen

Posted in Assembly Language, Delphi, Development, Software Development, x86 | Leave a Comment »

Mixing x64 Outlook with x86 Delphi: never a good idea…

Posted by jpluimers on 2018/02/07

Via [WayBack] Hi all,I’m a bit stuck here with a “simple” task.Looks like Outlook 2016 doesn’t supports “MAPISendMail”, at least, if i trigger this, Thunderbird… – Attila Kovacs – Google+:

Basically only MAPISendMail works cross architecture and only if you fill all fields.

This edited [WayBackemail – MAPI Windows 7 64 bit – Stack Overflow answer by [WayBack] epotter is very insightful (thanks [WayBackRik van Kekem – Google+):

Calls to MAPISendMail should work without a problem.

For all other MAPI method and function calls to work in a MAPI application, the bitness (32 or 64) of the MAPI application must be the same as the bitness of the MAPI subsystem on the computer that the application is targeted to run on.

In general, a 32-bit MAPI application must not run on a 64-bit platform (64-bit Outlook on 64-bit Windows) without first being rebuilt as a 64-bit application.

For a more detailed explanation, see the MSDN page on Building MAPI Applications on 32-Bit and 64-Bit Platforms

–jeroen

Posted in Delphi, Delphi x64, Development, Office, Outlook, Power User, Software Development, x86 | Leave a Comment »

Compiler Explorer – how various C++ compilers translate code into various machine code targets

Posted by jpluimers on 2017/01/03

The first implementation of Compiler Explorer supports many versions of the gcc, clang and icc compilers on ARM, ARM64, AVR and x86 targets.

On the left you type your C++ code, on the right you see the resulting assembler code optionally with byte code and colorised so you can correlate the C++ lines with the assembly.

A great way to start the year: learning new things!

Related:

–jeroen

via:

Some videos:

Read the rest of this entry »

Posted in ARM, Assembly Language, C++, Conference Topics, Conferences, Development, Event, Software Development, x86 | Leave a Comment »

 
%d bloggers like this: