Author Topic: [SOLVED] Instructions in single-line  (Read 6584 times)

Offline shaynox

  • Full Member
  • **
  • Posts: 118
  • Country: gr
[SOLVED] Instructions in single-line
« on: December 29, 2014, 07:09:04 PM »
Is it a good idea to write multi asm instruction in same line for a better reading when they concern a same block through a new keyword (nasm) like " -> " for example.

( ->: mean nasm will read asm instruction left to right)
( <-: mean nasm will read asm instruction right to left)


Example for function:
Code: [Select]
%define float32(number) dword __float32__(number)
Code: [Select]
mov rsi, cube_game
mov rdi, end_cube_game
mov [add_angle_object + _y], float32(-1.0)
call rotate_object
begin:

Code: [Select]
call rotate_object <- mov  [add_angle_object + _y], float32(-1.0) <- mov  rdi, end_cube_game <- mov  rsi, cube_game

(And why not authorize brackets " ( ) " for surrounded the 'parameters')

Code: [Select]
call rotate_object (<- mov  [add_angle_object + _y], float32(-1.0) <- mov  rdi, end_cube_game <- mov  rsi, cube_game)



Example for calcule:
Code: [Select]
vmovdqu xmm0, [add_angle_object]
vaddps xmm0, [angle_object]
vmovdqu [angle_object], xmm0
begin:

Code: [Select]
vmovdqu  xmm0, [add_angle_object] -> vaddps  xmm0, [angle_object] -> vmovdqu  [angle_object], xmm0

(And why not do the inverse itteration of code bu changing " ->" in " <-" for another reading way)

Code: [Select]
vmovdqu  [angle_object], xmm0 <- vaddps  xmm0, [angle_object] <-  vmovdqu  xmm0, [add_angle_object]



Example for transfer value from RAM to another:
Code: [Select]
vmovss xmm0, [rsi + _color]
vmovss [screen + REPERE + r8], xmm0
begin:

Code: [Select]
vmovss  [screen + REPERE + r8], xmm0 <- vmovss xmm0, [rsi + _color]



PS: my goal is not transform asm in high level language (hate it anyway), is just for make it more readable cause even if assembly is fantastic programming way, the history make people's choose are turn in high level language.

So like assembly's fan, it will be great to "open" this langage by playing with additional syntaxe, by this way, make more simple to read and write, and finally, don't afraid person who want to be initiated by this wonderful language :)


Or a just semicolon is enough for read left to right, simple one char and same keyword for higher language level.
So the beginner of assembler will don't be lost with this ' ; ', but the more thing is we don't need to put this always, just for specify if we want enter more than 1 instruction in the same line.
« Last Edit: February 21, 2015, 10:25:34 AM by shaynox »

Offline HD1920.1

  • Jr. Member
  • *
  • Posts: 40
Re: suggestion
« Reply #1 on: January 01, 2015, 06:28:45 AM »
I don't believe this a good idea because it "makes" programmers mess up their code.

Offline shaynox

  • Full Member
  • **
  • Posts: 118
  • Country: gr
Re: suggestion
« Reply #2 on: January 01, 2015, 11:51:28 AM »
When i say, write in same line, i don't say we must put all the concern block in this line, we can split this line if we cannot see all block's code.

Exemple for long calcule:
Code: [Select]
vmulps ymm11, ymm10
vmulps ymm11, ymm4

vhsubps ymm11, ymm11
vhsubps ymm11, ymm11
begin:

Code: [Select]
vmulps  ymm11, ymm4 <- vmulps  ymm11, ymm10
vhsubps  ymm11, ymm11 <- vhsubps  ymm11, ymm11

After i know all programmers cannot like this new way for assembly programming, but if some people like this, it will be nice we'll found it next version of nasm.
« Last Edit: January 01, 2015, 11:57:54 AM by shaynox »

Offline shaynox

  • Full Member
  • **
  • Posts: 118
  • Country: gr
Re: suggestion
« Reply #3 on: February 20, 2015, 05:58:36 PM »
Finally I write a macro for do it:

Code: [Select]
; redefine name type of value
%define f8 (number) byte __float8__ (number)
%define f16(number) word __float16__(number)
%define f32(number) dword __float32__(number)
%define f64(number) qword __float64__(number)

%define i8 byte
%define i16 word
%define i32         dword
%define i64 qword

Code: [Select]
;===============================================================================.
; _  (multi line)                                                              |
; Purpose : Give the possibility to write multiple instructions in single line.|
;===============================================================================.
; %0 = number of parameters received
; %1 = 1st parameter received
%macro _ 1-*

%rep (%0) ; Reapet %0 times
%1
%rotate  1 ; Rotate element right to left for scanning all element parsing in macro.
%endrep

%endmacro
;===============================================================================.
; / _ (multi line)                                                            |
;===============================================================================.


Exemple:

Code: [Select]
; Set higher resolution correspond to Screen for windows creating
_{_GetSystemMetrics SM_CXSCREEN, [winapi_length]}, {_GetSystemMetrics SM_CYSCREEN, [winapi_width]}
_{vcvtdq2ps             xmm0, [winapi_length]       }, {vmovq                   [length], xmm0             } ; vcvtdq2ps 4*int32 -> 4*float32

                _{mov  [length], f32(1024.0)}, {mov  [width], f32(800.0)}, {mov  [winapi_length], i32 1024}, {mov  [winapi_width], i32 800}

Enjoy !
« Last Edit: March 12, 2015, 12:21:25 AM by shaynox »