The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: ASMManiac on March 12, 2012, 07:17:50 PM

Title: Multiple instructions on one line?
Post by: ASMManiac on March 12, 2012, 07:17:50 PM
Is there a way to place multiple assembly instructions on one line?
Some lines are simple and would be nice for readability to place all on one line.
Is there a switch that allows the assembler to do this?  I'm using JWasm and it doesn't seem to allow this
Title: Re: Multiple instructions on one line?
Post by: qWord on March 12, 2012, 07:19:59 PM
You can write a macro that allows this, but what would be the sense of it?

e.g.:
asm macro args:VARARG
asm_txt TEXTEQU <>
FORC char,<&args>
IFDIF <&char>,<!\>
asm_txt CATSTR asm_txt,<&char>
ELSE
asm_txt
asm_txt TEXTEQU <>
ENDIF
ENDM
asm_txt
endm

usage:
asm mov eax,-1 \ mov ebx,2
Title: Re: Multiple instructions on one line?
Post by: ASMManiac on March 13, 2012, 07:26:53 PM
It's easier for me to read the code if multiple similar actions are taken at the same line.
For example
add rax, 16  \  add rbx, 16   \  add rdx, 16
at the end of a loop
Title: Re: Multiple instructions on one line?
Post by: dedndave on March 13, 2012, 07:45:06 PM
your just a maniac   :P

reminds me of BASIC - lol
FOR N=1 TO 5:PRINT N;:NEXT N
believe it or not, the old ibm basic compiler yielded more efficient code if you did it that way
Title: Re: Multiple instructions on one line?
Post by: qWord on March 13, 2012, 07:54:55 PM
Quote from: ASMManiac on March 13, 2012, 07:26:53 PM
It's easier for me to read the code if multiple similar actions are taken at the same line.
For example
add rax, 16  \  add rbx, 16   \  add rdx, 16
at the end of a loop
using above macro, you can do this. You can rename the macro to "_" thus it comes closer to your syntax idea:
_ add rax, 16  \  add rbx, 16   \  add rdx, 16  :lol

Title: Re: Multiple instructions on one line?
Post by: jj2007 on March 13, 2012, 08:39:40 PM
Quote from: ASMManiac on March 13, 2012, 07:26:53 PM
It's easier for me to read the code if multiple similar actions are taken at the same line.

Personally, I wouldn't do it, and I doubt it can improve your ability to grasp a bigger chunk of code. But you have a point here: Assembly is a "vertical" language with short instructions and many lines. If you can, try to turn your monitor in vertical position. Or try to remove all unnecessary menus to get more lines on the screen. I typically see around 45 lines per screen, enough especially when you make heavy use of macros. For example, print "hello", 13, 10 can easily expand, in "true" assembler, to
.data
CrLf db 13, 10, 0
Hello db "Hello", 0
.code
push offset Hello
call StdOut
push offset CrLf
call StdOut

Learn how to make good use of Masm32 macros, and take your time to study \masm32\macros\macros.asm. The rv macro, for example, saves many lines.