News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Multiple instructions on one line?

Started by ASMManiac, March 12, 2012, 07:17:50 PM

Previous topic - Next topic

ASMManiac

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

qWord

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
FPU in a trice: SmplMath
It's that simple!

ASMManiac

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

dedndave

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

qWord

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

FPU in a trice: SmplMath
It's that simple!

jj2007

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.