123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272 |
- ORGANIZATION_BLOCK OB 1
- BEGIN
- // Test: NOPs
- BLD 123
- NOP 1
- NOP 0
- // Test: "A" load/store
- L DW#16#12345678
- T AB 0
- T AW 2
- T AD 4
- L AB 0
- __ASSERT== __ACCU 1, DW#16#00000078
- L AW 2
- __ASSERT== __ACCU 1, DW#16#00005678
- L AD 4
- __ASSERT== __ACCU 1, DW#16#12345678
- // Test: "E" load/store
- L DW#16#12345678
- T EB 0
- T EW 2
- T ED 4
- L EB 0
- __ASSERT== __ACCU 1, DW#16#00000078
- L EW 2
- __ASSERT== __ACCU 1, DW#16#00005678
- L ED 4
- __ASSERT== __ACCU 1, DW#16#12345678
- // Test: Direct peripheral read
- // Note: This test only succeeds on dummy hardware.
- L DW#16#87654321
- T ED 10
- L PEB 10
- __ASSERT== __ACCU 1, DW#16#00000087
- L PEW 10
- __ASSERT== __ACCU 1, DW#16#00008765
- L PED 10
- __ASSERT== __ACCU 1, DW#16#87654321
- // Test; Direct peripheral write
- // Note: This test only succeeds on dummy hardware.
- L 0
- T AD 10
- L DW#16#87654321
- T PAB 10
- L AD 10
- __ASSERT== __ACCU 1, DW#16#21000000
- L 0
- T AD 10
- L DW#16#87654321
- T PAW 10
- L AD 10
- __ASSERT== __ACCU 1, DW#16#43210000
- L 0
- T AD 10
- L DW#16#87654321
- T PAD 10
- L AD 10
- __ASSERT== __ACCU 1, DW#16#87654321
- // Test: LAR1/LAR2 with immediate pointer
- LAR1 P#L 8.7
- LAR2 P#L 7.1
- __ASSERT== __AR 1, DW#16#86000047
- __ASSERT== __AR 2, DW#16#86000039
- // Test: LAR1/LAR2 with accu
- L P#DBX 8.6
- LAR1
- L P#DBX 7.0
- LAR2
- __ASSERT== __AR 1, DW#16#84000046
- __ASSERT== __AR 2, DW#16#84000038
- // Test: +AR1/+AR2 with immediate pointer
- LAR1 P#E 55.6
- LAR2 P#A 99.7
- __ASSERT== __AR 1, DW#16#810001BE
- __ASSERT== __AR 2, DW#16#8200031F
- +AR1 P#E 1.0
- +AR2 P#A 0.1
- __ASSERT== __AR 1, DW#16#810001C6
- __ASSERT== __AR 2, DW#16#82000320
- // Test: +AR1/+AR2 with accu
- LAR1 P#E 55.1
- LAR2 P#A 99.2
- __ASSERT== __AR 1, DW#16#810001B9
- __ASSERT== __AR 2, DW#16#8200031A
- L P#M 1.1
- +AR1
- L P#M 0.2
- +AR2
- __ASSERT== __AR 1, DW#16#810001C2
- __ASSERT== __AR 2, DW#16#8200031C
- // Test: TAK
- L DW#16#01234567
- L DW#16#89ABCDEF
- __ASSERT== __ACCU 1, DW#16#89ABCDEF
- __ASSERT== __ACCU 2, DW#16#01234567
- TAK
- __ASSERT== __ACCU 1, DW#16#01234567
- __ASSERT== __ACCU 2, DW#16#89ABCDEF
- // Test: TAR
- L P#M 12.3
- LAR1
- L P#M 32.1
- LAR2
- __ASSERT== __AR 1, DW#16#83000063
- __ASSERT== __AR 2, DW#16#83000101
- TAR
- __ASSERT== __AR 1, DW#16#83000101
- __ASSERT== __AR 2, DW#16#83000063
- // Test: TDB
- AUF DB 2
- AUF DI 1
- __ASSERT== __DBR 1, 2
- __ASSERT== __DBR 2, 1
- TDB
- __ASSERT== __DBR 1, 1
- __ASSERT== __DBR 2, 2
- // Test: PUSH
- L DW#16#01234567
- L DW#16#89ABCDEF
- __ASSERT== __ACCU 1, DW#16#89ABCDEF
- __ASSERT== __ACCU 2, DW#16#01234567
- PUSH
- __ASSERT== __ACCU 1, DW#16#89ABCDEF
- __ASSERT== __ACCU 2, DW#16#89ABCDEF
- // Test: POP
- L DW#16#01234567
- L DW#16#89ABCDEF
- __ASSERT== __ACCU 1, DW#16#89ABCDEF
- __ASSERT== __ACCU 2, DW#16#01234567
- POP
- __ASSERT== __ACCU 1, DW#16#01234567
- __ASSERT== __ACCU 2, DW#16#01234567
- // Test: STW write
- __STWRST
- L W#16#FFFF
- T STW
- __ASSERT== __STW 0, 1
- __ASSERT== __STW 1, 1
- __ASSERT== __STW 2, 1
- __ASSERT== __STW 3, 1
- __ASSERT== __STW 4, 1
- __ASSERT== __STW 5, 1
- __ASSERT== __STW 6, 1
- __ASSERT== __STW 7, 1
- __ASSERT== __STW 8, 1
- L 0
- T STW
- __ASSERT== __STW 0, 0
- __ASSERT== __STW 1, 0
- __ASSERT== __STW 2, 0
- __ASSERT== __STW 3, 0
- __ASSERT== __STW 4, 0
- __ASSERT== __STW 5, 0
- __ASSERT== __STW 6, 0
- __ASSERT== __STW 7, 0
- __ASSERT== __STW 8, 0
- L W#16#AAAA
- T STW
- __ASSERT== __STW 0, 0
- __ASSERT== __STW 1, 1
- __ASSERT== __STW 2, 0
- __ASSERT== __STW 3, 1
- __ASSERT== __STW 4, 0
- __ASSERT== __STW 5, 1
- __ASSERT== __STW 6, 0
- __ASSERT== __STW 7, 1
- __ASSERT== __STW 8, 0
- L W#16#5555
- T STW
- __ASSERT== __STW 0, 1
- __ASSERT== __STW 1, 0
- __ASSERT== __STW 2, 1
- __ASSERT== __STW 3, 0
- __ASSERT== __STW 4, 1
- __ASSERT== __STW 5, 0
- __ASSERT== __STW 6, 1
- __ASSERT== __STW 7, 0
- __ASSERT== __STW 8, 1
- // Test B#(...) immediate
- L B#(66, 99)
- __ASSERT== __ACCU 1, DW#16#00004263
- L B#(66, 99, 88, 55)
- __ASSERT== __ACCU 1, DW#16#42635837
- CALL FB 1, DB 1 (
- IN_CHAR := 'x',
- OUT_CHAR := MB 0,
- )
- L MB 0
- __ASSERT== __ACCU 1, DW#16#00000044
- CALL SFC 46 // STOP CPU
- END_ORGANIZATION_BLOCK
- FUNCTION_BLOCK FB 1 : VOID
- VAR_INPUT
- IN_CHAR : CHAR;
- END_VAR
- VAR_OUTPUT
- OUT_CHAR : CHAR;
- END_VAR
- BEGIN
- // Check parameters
- L #IN_CHAR
- __ASSERT== __ACCU 1, DW#16#00000078
- // Test CHAR immediate
- L 'ABCD'
- __ASSERT== __ACCU 1, DW#16#41424344
- L 'ABC'
- __ASSERT== __ACCU 1, DW#16#00414243
- L 'AB'
- __ASSERT== __ACCU 1, DW#16#00004142
- L 'A'
- __ASSERT== __ACCU 1, DW#16#00000041
- L ''
- __ASSERT== __ACCU 1, DW#16#00000000
- // Output parameter
- L 'ABCD'
- T #OUT_CHAR
- END_FUNCTION_BLOCK
- DATA_BLOCK DB 1
- FB 1
- BEGIN
- IN_CHAR := ' ';
- OUT_CHAR := ' ';
- END_DATA_BLOCK
- DATA_BLOCK DB 2
- STRUCT
- XYZ : INT;
- END_STRUCT
- BEGIN
- END_DATA_BLOCK
|