flat assembler
Message board for the users of flat assembler.

flat assembler > Programming Language Design > On my new assembler

Goto page Previous  1, 2, 3, 4, 5 ... 9, 10, 11  Next
Author
Thread Post new topic Reply to topic
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 6871
Location: Kraków, Poland
I updated the package to a new version that supports INCLUDE environment variable.
Post 01 Sep 2015, 10:56
View user's profile Send private message Visit poster's website Reply with quote
shoorick



Joined: 25 Feb 2005
Posts: 1603
Location: Ukraine
i'm not able to use it...
Code:
[olex@localhost 8048-counter]$ export INCLUDE=~/fasmg/examples/8048 [olex@localhost 8048-counter]$ echo "$INCLUDE" /home/olex/fasmg/examples/8048 [olex@localhost 8048-counter]$ ls $INCLUDE 8048.asm 8048.bin 8048.inc 8048.wap bv.inc make.cmd [olex@localhost 8048-counter]$ ../../fasmg 8048-counter.asm 8048-counter.bin flat assembler g version 0.90.1438379288 8048-counter.asm [2] Error: source file not found. [olex@localhost 8048-counter]$ grep "INCLUDE" 8048-counter.asm INCLUDE "8048.inc" [olex@localhost 8048-counter]$

you can see i've set INCLUDE var, check if it is set and wether "8048.inc" can be found via INCLUDE, letter case is matching everywhere, but no way...
setting full path in source lets file to assemble...
same problem with fasmg.exe under wine...

_________________
UNICODE forever!
Post 02 Sep 2015, 19:26
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 6871
Location: Kraków, Poland
shoorick wrote:
i'm not able to use it...
Code:
(...) flat assembler g version 0.90.1438379288 (...)
This is not the right version, the one I uploaded has a version 0.90.1441104278.
Post 03 Sep 2015, 19:29
View user's profile Send private message Visit poster's website Reply with quote
shoorick



Joined: 25 Feb 2005
Posts: 1603
Location: Ukraine
thanks! now it works Wink
i found that file-roller i was using to unpack zip did not overwrite existing files without any notification Smile
Post 03 Sep 2015, 21:16
View user's profile Send private message Visit poster's website Reply with quote
shoorick



Joined: 25 Feb 2005
Posts: 1603
Location: Ukraine
I have noticed that multyline implementation of the opcode inside the macros may shift value of "$" placeholder.
In this case the usage of such trivial constructions like this:
Code:
Jcc $ ; infinite loop waiting for event

becomes not trivial and may lead to inexpective behavior Wink

_________________
UNICODE forever!
Post 06 Sep 2015, 20:56
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 6871
Location: Kraków, Poland
It is one of the reasons why I use the "proxy" variables for the instruction arguments in my examples - the value is then evaluated before instruction encoding starts.

As a side note: the primary function of these proxies is to sanitize macro parameters. Let me show this on a sample from the AVR macroinstruction set:
Code:
macro DES? K local value value = +K if value >= 0 & value <= 0x0F dw 1011b + value shl 4 + 10010100b shl 8 else err 'value out of range' end if end macro
If there was no "value" proxy and the "K" parameter was used directly in the subsequent expressions, it could lead to incorrect evaluation of condition if some rogue expression was provided as an argument. For example writing "DES 1 & 0" would cause the "if K >= 0 & K <= 0x0F" become "if 1 & 0 >=0 & 0 <= 0x0F" and thus IF block would be entered even though the argument is not even a correct numeric expression. In this case this is harmless, because DW is going to signalize an error anyway, but in some more complex macros this could lead to unexpected behavior and undetected errors. In case when you have a proxy, the rogue expression is going to be detected and signalized as an error at the time the proxy is defined.
Post 07 Sep 2015, 10:30
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 15870
Location: 162173 Ryugu
Do brackets achieve the same effect?
Code:
if (K) >= 0 & (K) <= 0x0F
I've often used brackets for ensure correct processing order but maybe this is mistaken?
Post 07 Sep 2015, 10:36
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 6871
Location: Kraków, Poland
I think you could fool brackets by passing a malformed expression like "1) & (0".
Post 07 Sep 2015, 10:39
View user's profile Send private message Visit poster's website Reply with quote
shoorick



Joined: 25 Feb 2005
Posts: 1603
Location: Ukraine
Tomasz Grysztar wrote:
It is one of the reasons why I use the "proxy" variables for the instruction arguments in my examples

thanks! i have to update 8048 support in this manner...

_________________
UNICODE forever!
Post 07 Sep 2015, 18:57
View user's profile Send private message Visit poster's website Reply with quote
Treant



Joined: 09 Oct 2009
Posts: 16
Location: Russia
I propose to add 'union' into tables.inc.
now union can be realized through virtual directive ...
https://en.wikipedia.org/wiki/Turing_tarpit
Post 08 Sep 2015, 18:40
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 6871
Location: Kraków, Poland
I think of an 'union' syntax as a HLL concept that does not really fit the assembly language well. It obfuscates the size of the underlying memory area and at a quick peek it can also be easily confused with a sequential data structure. In assembly language, where you need to be much more aware of the structure of your data, the VIRTUAL syntax for the so-called 'union' has an advantage. If you feel the other way, it may be because of your habits from other programming languages - but that is the case with many features of assembly language.
Post 08 Sep 2015, 22:10
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 6871
Location: Kraków, Poland
I have updated the package with a small change to LOAD/STORE directives - now when size of loaded/stored data is not explicitly specified, the size associated with the address is used (so if you defined "a dd ?" then "store -1 at a" is going to fill 4 bytes). I think this is a nice feature that could also be applied to fasm 1, but I did not want to break the backward-compatibility there.
Post 30 Oct 2015, 18:21
View user's profile Send private message Visit poster's website Reply with quote
shoorick



Joined: 25 Feb 2005
Posts: 1603
Location: Ukraine
Code:
show "high -1 = ",-1 shr 8

displays:
Code:
high -1 = 0

-- is it correct?
Post 24 Nov 2015, 14:51
View user's profile Send private message Visit poster's website Reply with quote
l_inc



Joined: 23 Oct 2009
Posts: 881
shoorick
The operator shr has higher precedence than the unary + and - . You should use parentheses.

_________________
Faith is a superposition of knowledge and fallacy
Post 24 Nov 2015, 15:00
View user's profile Send private message Reply with quote
shoorick



Joined: 25 Feb 2005
Posts: 1603
Location: Ukraine
thanks Smile
parentheses gave me:
Code:
Error: value out of allowed range.


this works:
Code:
((-1) shr 8) and 255
Post 24 Nov 2015, 15:06
View user's profile Send private message Visit poster's website Reply with quote
l_inc



Joined: 23 Oct 2009
Posts: 881
shoorick
Quote:
thanks Smile
parentheses gave me:
Code:
Error: value out of allowed range.

That's because fasmg loops are incompatible with fasm's rept . The latter is able to work with negative counter values. I suppose the author might consider changing that. I mean extending the allowed range for fasmg, not reducing it for fasm, obviously.

_________________
Faith is a superposition of knowledge and fallacy
Post 24 Nov 2015, 15:36
View user's profile Send private message Reply with quote
shoorick



Joined: 25 Feb 2005
Posts: 1603
Location: Ukraine
From time to time I wish to know exact value of a label or numeric variable, calculated while assembling source. As there is no regular listing support, I usually store it somewhere and then look for it in the dump. It's really not handy Wink It would be not bad to be able to display those values as message. Macro show from fasmg doc works, but it is a trick and still is not handy Wink
I would suggest a feature for this:

label shownum var [, [H][U] ]
flags:
H - hex
U - unsigned

Code:
VV = 0x777 AA shownum VV, HU display "value = ",`AA,"h"

-- this should output:
Code:
value = 777h


any other more clever keyword can be used instead of shownum
Post 01 Dec 2015, 05:43
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 6871
Location: Kraków, Poland
While the "show" macro in the manual is just a simple trick that is there to demonstrate some of the features of fasm g, any of the various macros that have been written for this purpose for fasm 1 could probably be easily converted to fasm g syntax. Or you could just write a new one from scratch and be able to use some of the added features of fasm g:
Code:
struc shownum value,base:10 local x,sgn,dgt,txt x = value sgn = 0 if x < 0 x = -x sgn = 1 end if txt = '' while x | ~txt dgt = x mod base x = x / base if dgt < 10 dgt = '0' + dgt else dgt = 'A' + dgt - 10 end if txt = txt shl 8 + dgt end while if sgn txt = txt shl 8 + '-' end if . = string txt end struc A shownum 1234567890 B shownum 65535, 16 C shownum 3003, 2 display 'A = ',A,13,10 display 'B = ',B,'h',13,10 display 'C = ',C,'b',13,10 D shownum 1 shl 512 display 'D = ',D,13,10
Note about "unsigned": for fasm the numbers are always signed and if you have a negative value, it is assumed to have an endless sequence of "1" bits extending to the left (in manual I defined it to be compatible with 2-adic arithmetic, even though the actual 2-adic numbers are much more than that, but that's a story for another day). Therefore if you want to treat the negative value as unsigned and not get an infinity as a result, you must specify a truncated size you want to work with. For example when you wrote "((-1) shr 8) and 255", you specified that you want to convert signed value to unsigned with the 8-bit size. For different sizes you (obviously) get different results.
Post 01 Dec 2015, 09:02
View user's profile Send private message Visit poster's website Reply with quote
shoorick



Joined: 25 Feb 2005
Posts: 1603
Location: Ukraine
thanks a lot!
i thinks this should be enough for me Smile
Post 01 Dec 2015, 09:34
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 6871
Location: Kraków, Poland
I played with the macro a bit more and created a variant that displays floating-point decimal numbers. I have no idea if this might become useful for anything in the actual applications (this is something that fasm 1 never had), but for now it allows to test some of the new features.
Code:
struc showfloat value,precision:2 local x,i,pos,sgn,dgt,txt x = value x = x * 1e#precision sgn = 0 if x < 0 x = -x sgn = 1 end if i = trunc x if x - i >= float 1/2 i = i + 1 end if pos = 0 txt = '' while i | pos <= precision dgt = i mod 10 i = i / 10 txt = txt shl 8 + '0' + dgt pos = pos + 1 if pos = precision txt = txt shl 8 + '.' end if end while if sgn txt = txt shl 8 + '-' end if . = string txt end struc f = 1 e = f repeat 33 f = f * % e = e + 1f/f end repeat out showfloat e, 37 display out
Post 02 Dec 2015, 12:31
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:  
Goto page Previous  1, 2, 3, 4, 5 ... 9, 10, 11  Next

< 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 © 2004-2018, Tomasz Grysztar.

Powered by rwasa.