Guus Assmann wrote:
Hello,
I my attempt to reassemble some code, I run into a problem.
The documentation is not very extensive, so I cannot find some stuff.
The original code is: (ttoutt&255)+1
If I understan this correctly, it transforms a decimal number from the label into a hex value and by adding 1, it prevents the outcome to be zero.
How do I get this done with the "Kowalski" program?
2nd Q, is there some more documentation? I have some things from Bill (Big....dynosaur) and his code for the POC V1, that's been a big help....
BR/
Guus
You can write the above expression as
[ttoutt & 255] + 1. In the Kowalski assembler, square brackets are used in the same way parentheses would be used in algebraic notation.
As long as Guus has brought up the use of the bit-wise operator
&, here is an example program that may be assembled in the Kowalski assembler to illustrate the various operators.
Code:
.opt proc65c02,caseinsensitive
;KOWALSKI ASSEMBLER LOGICAL, BITWISE & ARITHMETIC OPERATORS
;
;
; number radices...
;
; @ binary, e.g., @01011010
; $ hex, e.g., $5a
; none decimal
;
test0001 =@00001111
test0002 =test0001 << 4 ;logical shift left 4 bits
test0003 =test0002 >> 4 ;logical shift right 4 bits
test0004 =test0001 & test0002 ;bitwise AND
test0005 =test0001 | test0002 ;bitwise OR
test0006 =test0001 && test0002 ;logical AND
test0007 =test0001 || test0002 ;logical OR
test0008 =!0 ;bitwise NOT
test0009 =$5a ^ test0005 ;bitwise XOR
test0010 =4 == 3 ;equality test
test0011 =4 == 4 ;equality test
test0012 =4 != 3 ;inequality test
test0013 =4 != 4 ;inequality test
test0014 =4 > 3 ;greater-than test
test0015 =4 < 3 ;lesser-than test
test0016 =~1 ;2s complement
;
;
; arithmetic operators...
;
; + addition
; - subtraction
; * multiplication
; / division
; % modulo
;
sum = 5 + 6 ;evaluates to 11
diff = sum - 6 ;evaluates to 5
prod = 5 * 6 ;evaluates to 30
quot =prod / diff ;evaluates to 6
mod =prod % sum ;evaluates to 8
;
;
; example using square brackets to alter evaluation precedence...
;
test0017 =5 + 6 * 2 ;strictly left-to-right: evaluates to 17
test0018 =[5 + 6] * 2 ;sum of 5 & 6 computed 1st: evaluates to 22
;
.end
Assembling the above produces the following listing:
Code:
00001 ;KOWALSKI ASSEMBLER LOGICAL, BITWISE & ARITHMETIC OPERATORS
00002 ;
00003 ;
00004 ; number radices...
00005 ;
00006 ; @ binary, e.g., @01011010
00007 ; $ hex, e.g., $5a
00008 ; none decimal
00009 ;
00010 000F test0001 =@00001111
00011 00F0 test0002 =test0001 << 4 ;logical shift left 4 bits
00012 000F test0003 =test0002 >> 4 ;logical shift right 4 bits
00013 0000 test0004 =test0001 & test0002 ;bitwise AND
00014 00FF test0005 =test0001 | test0002 ;bitwise OR
00015 0001 test0006 =test0001 && test0002 ;logical AND
00016 000F test0007 =test0001 || test0002 ;logical OR
00017 0001 test0008 =!0 ;bitwise NOT
00018 00A5 test0009 =$5a ^ test0005 ;bitwise XOR
00019 0000 test0010 =4 == 3 ;equality test
00020 0001 test0011 =4 == 4 ;equality test
00021 0001 test0012 =4 != 3 ;inequality test
00022 0000 test0013 =4 != 4 ;inequality test
00023 0001 test0014 =4 > 3 ;greater-than test
00024 0000 test0015 =4 < 3 ;lesser-than test
00025 FFFE test0016 =~1 ;2s complement
00026 ;
00027 ;
00028 ; arithmetic operators...
00029 ;
00030 ; + addition
00031 ; - subtraction
00032 ; * multiplication
00033 ; / division
00034 ; % modulo
00035 ;
00036 000B sum = 5 + 6 ;evaluates to 11
00037 0005 diff = sum - 6 ;evaluates to 5
00038 001E prod = 5 * 6 ;evaluates to 30
00039 0006 quot =prod / diff ;evaluates to 6
00040 0008 mod =prod % sum ;evaluates to 8
00041 ;
00042 ;
00043 ; example using square brackets to alter evaluation precedence...
00044 ;
00045 0011 test0017 =5 + 6 * 2 ;strictly left-to-right: evaluates to 17
00046 0016 test0018 =[5 + 6] * 2 ;sum of 5 & 6 computed 1st: evaluates to 22
00047 ;
00048 .end
Although the above code shows whitespace around the various operators in some cases, it's only for clarity. I usually leave out whitespace where it isn't needed to avoid evaluation ambiguity.