flat assembler
Message board for the users of flat assembler.
![]() Goto page 1, 2 Next |
Should a logical xor operator be added to Fasm? "^" | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
Total Votes : 27 |
Author |
|
MCD 23 Dec 2004, 16:10
HERE IS A STEP-BY-STEP IMPLEMENTATION INSTRUCTION
"PREPROCE.INC": --------------- At the very end Old: ---- Code: symbol_characters db 27 db 9,0Ah,0Dh,1Ah,' +-/*:=|&~()[]<>{},;\#`' New: ---- Code: symbol_characters db 28 db 9,0Ah,0Dh,1Ah,' +-/*:=|&^~()[]<>{},;\#`' "EXPRESSI.INC": --------------- At calculate_logical_expression Old: ---- Code: logical_loop: push eax lods byte [esi] cmp al,'|' je logical_or cmp al,'&' je logical_and New: ---- Code: logical_loop: push eax lods byte [esi] cmp al,'|' je logical_or cmp al,'&' je logical_and cmp al,'^' je logical_xor Just a few lines below Old: ---- Code: logical_and: call get_logical_value pop ebx and al,bl jmp logical_loop get_logical_value: New: ---- Code: logical_and: call get_logical_value pop ebx and al,bl jmp logical_loop logical_xor: call get_logical_value pop ebx xor al,bl jmp logical_loop get_logical_value: At get_logical_value Old: ---- Code: check_character: ; ... ~7 lines cmp al,'|' je stop cmp al,'&' je stop New: ---- Code: check_character: ; ... ~7 lines cmp al,'|' je stop cmp al,'&' je stop cmp al,'^' je stop "PARSER.INC": ------------- Old: ---- Code: parse_arguments: ; ... ~7 lines cmp al,'|' je separator cmp al,'&' je separator New: ---- Code: parse_arguments: ; ... ~7 lines cmp al,'|' je separator cmp al,'&' je separator cmp al,'^' je separator _________________ MCD - the inevitable return of the Mad Computer Doggy -||__/ .|+-~ .|| || |
|||
![]() |
|
Matrix 24 Dec 2004, 00:11
hy mcd
it seems to me you are beginning to make things more comfortable ![]() do i see it right? |
|||
![]() |
|
MCD 25 Dec 2004, 18:52
Perhaps. Explain, what do you mean with "more comfortable"?
If it means what I think now, than you should admit that from the "|" OR and "&" AND operator, 1 is superfluous because of the law of De Morgan: lets assume a and b or 2 boolean values, than this... Code: if a & b ;... some code end if if a | b ;... some other code end if could be written as Code: if a & b ;... some code end if if ~(~a & ~b) ;... some other code end if This means that you can sacrify either the AND or OR operator, but not both. E.g. you can rewrite any combination of ORs and ANDs to just ANDs or Ors. Even the XOR: Code: if a ^ b;lets assume it already exists with just the AND and NEGATION operators Code: if ~(~a & ~b) & ~(a & b) end if |
|||
![]() |
|
Madis731 28 Dec 2004, 20:22
I answered yes, but I've got something to add. I want "xor" not some character ("^"), because everything else is clearly written out like this:
((data1 shr 4) + (data1 shl 4)) and 0FFFFFFFFh I've already gotten used to it - that is why I hope BOTH can be implemented. Sure, (data1>>4+data1<<4)&(-1) would be short and clean, but again we might want to think about big project made with FASM. |
|||
![]() |
|
MCD 28 Dec 2004, 20:31
Perhaps I'm wrong, but I meant only the LOGICAL xor operator (see "|" and "&") used for "IF" blocks, not the numerical xor which is already implemented, eg
Code: db 1 xor 5 already works, but whereas Code: if (Somevalue < 5) ^ (Someothervalue = 0) ; some code end if does not. Also, I think that it would be difficult in implementing a logical xor operator with an outwritten "xor", since Fasm already uses this as a numerical one. _________________ MCD - the inevitable return of the Mad Computer Doggy -||__/ .|+-~ .|| || |
|||
![]() |
|
vid 28 Dec 2004, 21:04
i think both numerical "xor" and logical "^" should be added.
|
|||
![]() |
|
MCD 28 Dec 2004, 21:07
numerical "xor" already exists
|
|||
![]() |
|
vid 29 Dec 2004, 14:39
![]() |
|||
![]() |
|
comrade 30 Dec 2004, 05:02
Perhaps Privalov can also add bswap which he already implemented, and perhaps rol and ror as well
![]() |
|||
![]() |
|
Matrix 30 Dec 2004, 05:42
what do you think adding "^ equ xor"
? ![]() Code: |
|||
![]() |
|
vid 01 Jan 2005, 23:51
shit.
Saving two chars per instruction isn't worth of losing readiability (or forcing reader to learn all your such substitutions) |
|||
![]() |
|
Matrix 02 Jan 2005, 01:28
yeah, you're right, i have no problems with xor,
C has these kind of short forms ^ ! but it was probably not meant to be used like ^ ax,bx assembly mnemonics were developed so the programmers can easily learn the opcodes mov, add, sub, mul seems pretty easy to learn, not like some symbols ( apart from + - * / ) |
|||
![]() |
|
MCD 05 Jan 2005, 19:04
Matrix posted:
Quote: yeah, you're right, i have no problems with xor, vid posted: Quote:
I fully agree with you, Matrix and vid in term of assembly instructions. I mean that this "^" should only be implemented for Fasm's logical/boolean stuff, so that both the numerical constant "xor" and assembly instruction "xor" will remain as they are. Quote:
if anyone is interested in additional operators for Fasm, take a look at this post of mine. (also in flat assembler > Compiler Internals) http://board.flatassembler.net/topic.php?t=2679 _________________ MCD - the inevitable return of the Mad Computer Doggy -||__/ .|+-~ .|| || |
|||
![]() |
|
MCD 11 Jan 2005, 10:49
Just another thing:
Privalov, from all those stuff I proposed to add into Fasm, there is 1 feature I miss the most: I need a size detecting operator ![]() Code: macro MovAcc Var { if sizeof Var = 1 mov al,[Var] else if sizeof Var = 2 mov ax,[Var] else if sizeof Var = 4 mov eax,[Var] end if } ;I know, this is a bad example _________________ MCD - the inevitable return of the Mad Computer Doggy -||__/ .|+-~ .|| || |
|||
![]() |
|
vid 17 Jan 2005, 14:37
well, i think this might work, but there will have to be several cases:
sizeof label - size assigned to label. But what will sizeof do when label doesn't have assigned size, i suppose error message sizeof general purpose register - should work okay sizeof segment register - 16bits? sizeof size operator - size as number (in bytes) sizeof anything else - just like sizeof label with unassigned size, throw error. as i think of it, it may work. |
|||
![]() |
|
LocoDelAssembly 29 Aug 2007, 21:09
(Don't ask how is possible that I reached to this thread)
Why logical (non-numerical) xor was not implemented after all? |
|||
![]() |
|
vid 30 Aug 2007, 10:46
loco: probably because it is so seldom needed?
|
|||
![]() |
|
LocoDelAssembly 30 Aug 2007, 16:47
I suppose, but for the sake of completeness perhaps it should be included anyway?
Though, thinking about it better, is there a language that supports it (again, logical, not numerical)? |
|||
![]() |
|
vid 30 Aug 2007, 21:25
loco: you know, it is always possible to do with higher level constructs...
Code: if (c1) ^ (c2) ... if c1 x1 = 1 else x1 = 0 end if if c2 x2 = 1 else x2 = 0 end if if (x1 & !x2) | (!x1 & x2) yes, i agree this is lack of completness, but FASM never tried to be complete. It was designed to be clean and compact, and for that it does its job greatly |
|||
![]() |
|
Goto page 1, 2 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.