flat assembler
Message board for the users of flat assembler.
 Home   FAQ   Search   Register 
 Profile   Log in to check your private messages   Log in 
flat assembler > Macroinstructions > irps { % }

Author
Thread Post new topic Reply to topic
Gyricon



Joined: 09 Jun 2011
Posts: 4
Location: Ukraine

irps { % }

[Eng]

Why does not the standard % counter in the irps design work?


Code:

                @mycounter=101
                irps i,Play Stop Pause {
                    command_ #i=@mycounter
                    @mycounter=@mycounter+1 }
                ; Displays the correct:
                ; command_Play = 101
                ; command_Stop = 102
                ; command_Pause = 103

                irps iPlay Stop Pause { command_#i=100+% }
                ; The results are incorrect:
                ; command_Play = 100
                ; command_Stop = 100
                ; command_Pause = 100



[Rus]

Почему не работает стандартный счётчик % в конструкции irps ?


Code:
 
                @счётчик=101
                irps i,Воспроизведение Стоп Пауза {
                    команда_#i=@счётчик
                    @счётчик=@счётчик+1 }
                ; Результаты правильные:
                ; команда_Воспроизведение=101
                ; команда_Стоп=102
                ; команда_Пауза=103

                irps i,Play Stop Pause { команда_#i=100+% }
                ; Результаты неверные:
                ; команда_Воспроизведение=100
                ; команда_Стоп=100
                ; команда_Пауза=100


Post 06 Feb 2018, 13:22
View user's profile Send private message ICQ Number Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 15638
Location: Thasus

"%" is an assembly variable. IRPS is a preprocessor directive so it is processed at a different time from the assembly stage.
Post 06 Feb 2018, 14:43
View user's profile Send private message Visit poster's website Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 130
Location: Russian Federation, Sochi

[ENG]
Hello, Gyricon, thou maybe want to get solution of your problem instead of reading that way thou goes is wrong.


Code:

macro syntax v {
 IF v eq
  define ?s 1
 ELSE
  define ?s v
 END IF
}

if.syntax fix IF ?s eq
if.not.syntax fix IF ?s eq 0 
 
;;;;;;;;;;;;;; NUMERIC CONSTANTS ;;;;;;;;;;;;;;;;;

; create incremental (0-n) list of numeric
; constants with optional prefix. each token
; can be assigned or it equals previous+1.
; if first token ends with *, it becomes the
; prefix for subsequent tokens. example:

; numeric COLOR.*,\
; BLACK, WHITE, RED, GREEN, BLUE

; COLOR.BLACK=0 ; output...
; COLOR.WHITE=1
; COLOR.RED=2
; COLOR.GREEN=3
; COLOR.BLUE=4

macro numeric ?p, [p] {
 common
  local n
  n=0                ; n=0
  syntax 0
  match z$*, ?p \{   ; extract prefix
   syntax 1
  \}
  match a==b?p \{  ; first item
   a=b
   n=b+1
   syntax 1
  \}
  match =0?s \{    ; else, first=0
   ?p=0
   n=1
  \}
 forward
  syntax 0
  match a==bp \{   ; assigment?
   n=b               ; set n
   match z$*, ?p \\{ ; extract prefix
    z$\\#a=b
    syntax 1
   \\}
   if.syntax 0       ; no prefix
    a=b
   END IF
   syntax 1          ; yes, specified
  \}
  match =0?s \{    ; else=n (previous+1)
   match z$*, ?p \\{ ; extract prefix
    z$\\#p=n
    syntax 1
   \\}
   if.syntax 0       ; no prefix
    p=n
   END IF
  \}
  n=n+1              ; n++
}

KB=1024             ; 1<<10
MB=1048576          ; 1<<20
GB=1073741824       ; 1<<30

numeric YES=1NO=0TRUE=1FALSE=0,\
 NULL=0DEFAULT=0NONE=-1INVALID=-1,\
 DETECT=-1INFINITE=-1NOTHING=-1 



All such things like above in attachment of topic https://board.flatassembler.net/topic.php?t=17600
codestar is author. (To codestar: You are realy bad guy, in your sources author is missed, it was hard to find your topic)

In freshlib ( http://fresh.flatassembler.net/ ) it is solved too. Or maybe not, however, there too a lot of tasty macros. the main author - john found (there more then 1 author).

use this two sources as base for exploring fasm macros.

[RUS]
Не увлекайся сильно высокоуровневыми украшательствами.
Post 06 Feb 2018, 19:20
View user's profile Send private message Send e-mail Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >

Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Main index   Download   Documentation   Examples   Message board
Copyright © 2004-2018, Tomasz Grysztar.
Powered by rwasa.