From b955a67daabf962d4cca9665a9801c2a185283e6 Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Sun, 22 Dec 2019 19:17:40 -0500 Subject: [PATCH] avra: add TST --- apps/zasm/README.md | 6 ++++++ apps/zasm/avr.asm | 10 ++++++---- tools/tests/avra/test1.asm | 1 + tools/tests/avra/test1.expected | Bin 48 -> 50 bytes 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/apps/zasm/README.md b/apps/zasm/README.md index 89b4d30..644a667 100644 --- a/apps/zasm/README.md +++ b/apps/zasm/README.md @@ -191,4 +191,10 @@ the instruction after the "foo" label would be "rjmp foo+1". In zasm, it's "rjmp foo+2". If your expression results in an odd number, the low bit of your number will be ignored. +Limitations: + +* `CALL` and `JMP` only support 16-bit numbers, not 22-bit ones. +* `BRLO` and `BRSH` are not there. Use `BRCS` and `BRCC` instead. +* No `high()` and `low()`. Use `&0xff` and `}8`. + [libz80]: https://github.com/ggambetta/libz80 diff --git a/apps/zasm/avr.asm b/apps/zasm/avr.asm index 0ad0808..67ef31f 100644 --- a/apps/zasm/avr.asm +++ b/apps/zasm/avr.asm @@ -94,9 +94,10 @@ instrNames: .db "SLEEP", 0 .db "SUB", 0 .db "SWAP", 0 +.db "TST", 0 .db "WDR", 0 .db "XCH", 0 -.equ I_ANDI 81 +.equ I_ANDI 82 .db "ANDI", 0 .db "CBR", 0 .db "CPI", 0 @@ -105,10 +106,10 @@ instrNames: .db "SBCI", 0 .db "SBR", 0 .db "SUBI", 0 -.equ I_RCALL 89 +.equ I_RCALL 90 .db "RCALL", 0 .db "RJMP", 0 -.equ I_CBI 91 +.equ I_CBI 92 .db "CBI", 0 .db "SBI", 0 .db "SBIC", 0 @@ -117,7 +118,7 @@ instrNames: ; ZASM limitation: CALL and JMP constants are 22-bit. In ZASM, we limit ; ourselves to 16-bit. Supporting 22-bit would incur a prohibitive complexity ; cost. As they say, 64K words ought to be enough for anybody. -.equ I_CALL 95 +.equ I_CALL 96 .db "CALL", 0 .db "JMP", 0 .db 0xff @@ -209,6 +210,7 @@ instrTbl: .db 0x00, 0b10010101, 0b10001000 ; SLEEP .db 0x02, 0b00011000, 0x00 ; SUB Rd, Rr .db 0x01, 0b10010100, 0b00000010 ; SWAP Rd +.db 0x41, 0b00100000, 0x00 ; TST Rd (Bit 6) .db 0x00, 0b10010101, 0b10101000 ; WDR .db 0x01, 0b10010010, 0b00000100 ; XCH Rd ; Rd(4) + K(8): XXXXKKKK ddddKKKK diff --git a/tools/tests/avra/test1.asm b/tools/tests/avra/test1.asm index f7753b7..025ec6c 100644 --- a/tools/tests/avra/test1.asm +++ b/tools/tests/avra/test1.asm @@ -23,3 +23,4 @@ call foo jmp bar mov r6, r30 lsl r3 +tst r12 diff --git a/tools/tests/avra/test1.expected b/tools/tests/avra/test1.expected index 94463218b934927048566ebf2571de7edad4db54..06305e7b2c91c71de0e756b50241e62d14cffeea 100644 GIT binary patch delta 7 OcmXponqa_mMgaf^(E