From 2652c815190da91606660f9632a27ecdbec72299 Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Sun, 15 Dec 2019 16:43:32 -0500 Subject: [PATCH] avra: make CLR work properly --- apps/zasm/avr.asm | 10 +++++++++- tools/tests/avra/blink_tn45.asm | 2 +- tools/tests/avra/blink_tn45.expected | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/apps/zasm/avr.asm b/apps/zasm/avr.asm index 0dde676..1319caf 100644 --- a/apps/zasm/avr.asm +++ b/apps/zasm/avr.asm @@ -129,6 +129,8 @@ instrNames: ; AVR's mnemonics has those args reversed for more consistency ; (destination is always the first arg). The goal of this flag is to ; allow this kind of syntactic sugar with minimal complexity. +; +; Bit 6: Second arg is a copy of the first ; In the same order as in instrNames instrTbl: @@ -136,7 +138,7 @@ instrTbl: .db 0x02, 0b00011100, 0x00 ; ADC .db 0x02, 0b00001100, 0x00 ; ADD .db 0x02, 0b00100000, 0x00 ; AND -.db 0x02, 0b00100100, 0x00 ; CLR +.db 0x41, 0b00100100, 0x00 ; CLR (Rr copies Rd) .db 0x02, 0b00010100, 0x00 ; CP .db 0x02, 0b00000100, 0x00 ; CPC .db 0x02, 0b00010000, 0x00 ; CPSE @@ -291,6 +293,8 @@ parseInstruction: ; InstrID is E bit 7, (ix) call nz, .swapHL ; Bit 7 set, swap H and L again! + bit 6, (ix) + call nz, .cpHintoL ; Bit 6 set, copy H into L ld a, e ; InstrID cp I_ANDI jr c, .spitRd5Rr5 @@ -474,6 +478,10 @@ parseInstruction: ld l, a ret +.cpHintoL: + ld l, h + ret + ; Argspecs: two bytes describing the arguments that are accepted. Possible ; values: ; diff --git a/tools/tests/avra/blink_tn45.asm b/tools/tests/avra/blink_tn45.asm index 09a9344..5b64245 100644 --- a/tools/tests/avra/blink_tn45.asm +++ b/tools/tests/avra/blink_tn45.asm @@ -25,7 +25,7 @@ main: ori r16, 0x05 ; CS00 + CS02 = 1024 prescaler out TCCR0B, r16 - ;clr r1 + clr r1 loop: in r16, TIFR ; TIFR0 diff --git a/tools/tests/avra/blink_tn45.expected b/tools/tests/avra/blink_tn45.expected index f245628..d2b0c0b 100644 --- a/tools/tests/avra/blink_tn45.expected +++ b/tools/tests/avra/blink_tn45.expected @@ -1 +1 @@ -å ¿à¿·`¿·ýÐüÏà¿”þ• \ No newline at end of file +å ¿à¿·`¿$·ýÐüÏà¿”þ• \ No newline at end of file