flat assembler
Message board for the users of flat assembler.

Index > Windows > FasmScript ?

Author
Thread Post new topic Reply to topic
Akujin



Joined: 11 Oct 2011
Posts: 26
Location: Exile
Akujin 14 Oct 2011, 04:59
FasmScript?

Open file _sample.asc (any text editor)
study/modify the script, save and run fasmscript.exe.

Test & Feedback please!


Description:
Download
Filename: fasmscript.rar
Filesize: 56.24 KB
Downloaded: 463 Time(s)


_________________
CLI
HLT


Last edited by Akujin on 14 Oct 2011, 16:04; edited 1 time in total
Post 14 Oct 2011, 04:59
View user's profile Send private message Visit poster's website Reply with quote
wht36



Joined: 18 Sep 2005
Posts: 106
wht36 14 Oct 2011, 09:48
Hi, the program ran, asked for & displayed input, and closed fine....
Post 14 Oct 2011, 09:48
View user's profile Send private message Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1635
Location: Toronto, Canada
AsmGuru62 14 Oct 2011, 14:22
What this program does?
Post 14 Oct 2011, 14:22
View user's profile Send private message Send e-mail Reply with quote
Akujin



Joined: 11 Oct 2011
Posts: 26
Location: Exile
Akujin 14 Oct 2011, 16:10
AsmGuru62 wrote:
What this program does?


almost everything...

_________________
CLI
HLT
Post 14 Oct 2011, 16:10
View user's profile Send private message Visit poster's website Reply with quote
Akujin



Joined: 11 Oct 2011
Posts: 26
Location: Exile
Akujin 14 Oct 2011, 22:09
Pseudo Ops:
Console Display:
PINT ; Print INT value in eax 32bit signed
PUNS ; Print UNSigned value in eax 32bit
PSTR ; Print STRing pointed by eax
PFLT ; Print FLoaT in eax 32bit single
Console Prompt:
ASKI ; Promp for a number (INT), prompt string address in eax, on exit eax=value entered
hex display todo!
force unsigned check removed!
skip header import table removed!

Pseudo Functions:
WinAPI:
MSGB ; Same as Windows API MessageBox
LDLL ; Same as Windows API LoadLibrary
GPRA ; Same as Windows API GetProcAddress
FDLL ; Same as Windows API FreeLibrary

Extension Vars:
hwnd ; Console Window Handle

Execution of script code start at start: label
Execution end on End Of File or RET opcode

_________________
CLI
HLT
Post 14 Oct 2011, 22:09
View user's profile Send private message Visit poster's website Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1635
Location: Toronto, Canada
AsmGuru62 14 Oct 2011, 22:49
Cool!
Post 14 Oct 2011, 22:49
View user's profile Send private message Send e-mail Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2139
Location: Estonia
Madis731 17 Oct 2011, 07:37
Yes, a start of something cool. I don't know what ... yet Smile
Post 17 Oct 2011, 07:37
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
Akujin



Joined: 11 Oct 2011
Posts: 26
Location: Exile
Akujin 17 Oct 2011, 10:30
Twisted Evil Qbasic code stolen from me239:
http://board.flatassembler.net/topic.php?t=13515

Code:
; Original code (c) me239
ALIGN 4      ;!
alert1    db 13,10,"ALERT! Tank spotted ",0
alert2   db "meters away",0  
alert3        db 13,10,"You have 3 shell types: ",13,10,\
  " Short range: 50 m/s and 255 meter max",13,10,\
     " Medium range: 100 m/s 1,020 meter max",13,10,\
     " Long range: 200 m/s 4,081 meter max",13,10,0 
input1  db "Short range(1), Medium range(2), Long range(3): ",0
input2        db "Launch angle (Integer degree only): ",0 
hitT      db 13,10,"HIT! Enemy tank has been destroyed!",0
missT     db 13,10,"MISS! The enemy tank has shot AND killed you ",0
distT   db 13,10,"Distance: ",0
timeT  db 13,10,"Time: ",0 
return    db 13,10,0

ALIGN 4
rdist      dd 0
veloc   dd 0
angle   dd 0
t       dd 0
d       dd 0
vtable  dd 50.0,100.0,200.0
d2r      dd 0.017453292519943295769236907685
cn2      dd 0.204081632653061224489795918366
hsize    dd 10.0

ALIGN 16
start:
       rdtsc
       shr eax,21
  mov [rdist],eax
;mov [rdist],109
;mov [rdist],1698

        mov eax,alert1
      PSTR 
       mov eax,[rdist]
     PINT
        mov eax,alert2
      PSTR 
       mov eax,alert3
      PSTR 
       mov eax,return
      PSTR

askRange:
   mov eax,input1
      ASKI
        test eax,eax
        jz askRange
 cmp eax,3
   ja askRange
 mov eax,[vtable+eax*4-4]
    mov [veloc],eax
     mov eax,return
      PSTR

askAngle:
   mov eax,input2
      ASKI            ;need ASKF
  test eax,eax
        jz askAngle
 cmp eax,180
 ja askAngle
 mov [angle],eax
;mov [angle],24
;mov [angle],12           

lazyFPUcoder:
   fild [angle]
        fmul [d2r]
  fsincos         ;RTFIM
      mov eax,missT
       fxch
        fmul [veloc]
        fmul [cn2]
  fst [t] ;!
  fmul [veloc]
        fmulp; [t]      ;!
  fstp [d]

        fild [rdist]    ;jxx safe
   fsub [hsize]
        fld [d] 
    fcomip st,st1
       fstp st
     jb miss

 fild [rdist]    ;jxx safe
   fadd [hsize]
        fld [d] 
    fcomip st,st1
       fstp st
     ja miss
hit:
 mov eax,hitT
miss:
   PSTR
        mov eax,distT
       PSTR
        mov eax,[d]
 PFLT
        mov eax,timeT
       PSTR
        mov eax,[t]
 PFLT
        mov eax,return
      PSTR
ret
;cli
;hlt
    


Usage:
Copy and paste this code over the _sample.asc file included in the .rar of the first post, save and run fasmscript.exe, for info about the game please refer to the link above

Random number not fully tested.
Sadly my program only accept Integers as input Sad
so testing the second picture in the original thread fails!

_________________
CLI
HLT
Post 17 Oct 2011, 10:30
View user's profile Send private message Visit poster's website Reply with quote
TmX



Joined: 02 Mar 2006
Posts: 841
Location: Jakarta, Indonesia
TmX 18 Oct 2011, 09:48
Cool. A kind of interpreter..
BTW is the source code available?
Post 18 Oct 2011, 09:48
View user's profile Send private message Reply with quote
Akujin



Joined: 11 Oct 2011
Posts: 26
Location: Exile
Akujin 18 Oct 2011, 18:19
Source code for fasm.dll at http://board.flatassembler.net/topic.php?t=6239

The fasmscript.exe its just an host for fasm.dll with some function to display data.

The Trick
At run time the file _sample.asc is loaded in memory...
A VirtualAlloc call prepare a Buffer to store the assembled code...
A Prologue file is made in memory...
Code:
format binary
use32
org 00000000h
jmp start
    

org directive is filled with the address of the VirtualAlloc Buffer...
An Epilogue file is made in memory...
Code:
ret ;  Shocked 
    

Prologue+ _sample.asc+Epilogue are send to fasm.dll for assembly
and the resulting bytecode! stored in the VirtualAlloc Buffer....
Host app call Buffer and execution start...

Easy! Twisted Evil

In fasmscript.exe a bug allow to see my Prologue code Cool ...

Regards.

_________________
CLI
HLT
Post 18 Oct 2011, 18:19
View user's profile Send private message Visit poster's website 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.