News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

3 x 64

Started by jj2007, September 03, 2016, 09:27:08 AM

Previous topic - Next topic

jj2007

Quote from: tolmann on September 05, 2016, 05:09:09 AMIt could be argued that a "newbie" to 64 bit asembler should not use macros.

It could be argued that a newbie should use macros. How else can he make any progress?
include \Masm32\MasmBasic\Res\JBasic.inc ; OPT_64 1 ; put 0 for 32 bit, 1 for 64 bit assembly
Init
  mov rax, 123456789012345h
  mov rdx, rax
  shr rdx, 1
  mov rcx, rdx
  shl rcx, 1
  deb 4, "one bit shifted out to the right:", x:rax, x:rdx, x:rcx
EndOfCode


Output:
one bit shifted out to the right:
x:rax   123456789012345h
x:rdx   91a2b3c48091a2h
x:rcx   123456789012344h

hutch--

I have usually seen that experienced programmers from other languages get the swing of why you start with macros very quickly as they are used to using compilers that start with a runtime library but the true novice often asks for pure mnemonic code without macros only to find that an assembler that comes with no runtime library at all in fact needs its own runtime library and this is what a collection of static library modules and macros is all about.

The alternative for a true novice is to try and write their own which is a near to impossible task. When in the past I have had novices complain about macros, I refer them to the library AND the macro file to see that trivial things like putting text on the screen or converting numbers to text for display involves a lot more than they expect. The other factor is for both 32 and 64 bit Windows programming you need to have a good grasp of the historical Windows API and this is a task that a novice has little chance of doing.

The advice I give to true novices is learn a decent compiler first so that they understand what memory and addressing is about and when they have that done properly they can start on an assembler if they can find a use for it. I have always been of the view that assembler programming is a task for experienced programmers, not for novices and years of experience has born that out.

jj2007

Quote from: hutch-- on September 05, 2016, 08:48:34 AMassembler programming is a task for experienced programmers, not for novices

A great number of programmers, me included, started assembler as novices in the very moment when they found out that their favourite Basic dialect was too slow. I learned using pointers in assembly, and when many years later I had to use them in C, I was really astonished that they made such a big fuss about something as simple as pointers. C is just assembly with a lot of obfuscation.

What really helped me understanding assembly where two things:
- print str$(eax)  ; but it took me a while to find out that eax, edx and ecx are trashed afterwards
- Olly

I tried \Masm32\vkdebug but found it very clumsy to have a second window open; that's why I wrote the deb macro; and it was one of my first actions in 64-bit coding to port it. For any serious work, you either need to use the debugger, or a deb-style macro.