flat assembler
Message board for the users of flat assembler.

Index > Projects and Ideas > Challenge ! Who less ?!

Author
Thread Post new topic Reply to topic
Roman



Joined: 21 Apr 2012
Posts: 1796
Roman 05 Sep 2024, 15:54
parse c++ to fasm 242 bytes.
Code:
txtC db ' dGeomSetPosition (&box,p[0],11,22,&p[1],p[2],&dat1,dat2);',0
;out: dGeomSetPosition,box,[p.0],11,22,p.1,[p.2],dat1,[dat2]

macro FindAnySymbol t { local .1,.2,.3
      xor cl,cl
      mov al,[t]
      mov ah,al
      sub ah,"a"
      cmp ah,"z"-"a"
      ja  .1   
      mov cl,1
.1:
      sub al,48
      cmp al,9
      ja  .3
      mov cl,2      
.3:   test cl,cl
      }                        
Start:  mov edx,txtC

        mov ebx,outTxt+6
        mov dword [ebx-6],'ode_'
        mov word  [ebx-2],' ,'
.back:  mov al,[edx]
        mov [ebx],al
        inc ebx
        inc edx
        cmp byte [edx],"("
        jnz .back
        mov word [ebx-1],' ,'
        add ebx,2

        mov esi,ptrKu
upp:    inc edx
        cmp byte [edx],0
        jz ennnn
        FindAnySymbol edx
        jz upp
        mov [esi],edx
        mov [esi+4],cl
        add esi,6
upp2:   inc edx
        cmp byte [edx],0
        jz  ennnn
        cmp byte [edx],'('
        jnz enn2
        mov byte [edx],','
        jmp  upp
enn2:
        cmp byte [edx],','
        jnz upp2
        jmp upp
ennnn:
;copy txt
        
        mov esi,ptrKu
        lea edx,[ebx-1]         
.zu:
        mov cl,[esi+4]
        mov eax,[esi]
        test eax,eax
       jz endinn
        cmp cl,2
        jz  .zu0
        cmp byte [eax-1],'&'
        jnz .zu2
        mov byte [skobnet],1
.zu0:   mov ch,[eax]
        cmp ch,'['
        jnz .zuX
        mov ch,'.'
.zuX:
        cmp ch,','
        jz  @f
        cmp ch,';'
        jz  endinn
        mov [edx],ch
        inc eax
        inc edx
        jmp .zu0
.zu2:   mov byte [edx],'['
        inc edx
        jmp .zu0
@@:     cmp cl,2
        jz  .ziko
        cmp byte [skobnet],1
        ;jz  .ziko
        jnz  .zikoU
        cmp byte [edx-1],']'
        jnz .ziko
        mov byte [edx-1],' '
        jmp .ziko
.zikoU:
        cmp byte [edx-1],']'
        jz  .ziko
        mov byte [edx],']'
        inc edx
.ziko:  mov byte [edx],','
        inc edx
        mov byte [skobnet],0
        add esi,6        
        jmp .zu

 
endinn:  mov byte [edx-1],']'    

invoke MessageBox,0,outTxt,0,0
;outTxt rb 50000
;ptrKu rd 200
;skobnet db 0
    


Last edited by Roman on 06 Sep 2024, 09:23; edited 1 time in total
Post 05 Sep 2024, 15:54
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1796
Roman 05 Sep 2024, 18:41
Interesting variants avx or sse.
Post 05 Sep 2024, 18:41
View user's profile Send private message 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


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.