URL
https://opencores.org/ocsvn/openmsp430/openmsp430/trunk
Subversion Repositories openmsp430
[/] [openmsp430/] [trunk/] [core/] [sim/] [rtl_sim/] [src/] [two-op_add.s43] - Rev 219
Go to most recent revision | Compare with Previous | Blame | View Log
/*===========================================================================*//* Copyright (C) 2001 Authors *//* *//* This source file may be used and distributed without restriction provided *//* that this copyright statement is not removed from the file and that any *//* derivative work contains the original copyright notice and the associated *//* disclaimer. *//* *//* This source file is free software; you can redistribute it and/or modify *//* it under the terms of the GNU Lesser General Public License as published *//* by the Free Software Foundation; either version 2.1 of the License, or *//* (at your option) any later version. *//* *//* This source is distributed in the hope that it will be useful, but WITHOUT*//* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *//* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public *//* License for more details. *//* *//* You should have received a copy of the GNU Lesser General Public License *//* along with this source; if not, write to the Free Software Foundation, *//* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *//* *//*===========================================================================*//* TWO-OPERAND ARITHMETIC: ADD INSTRUCTION *//*---------------------------------------------------------------------------*//* Test the ADD instruction with all addressing modes *//* *//* Author(s): *//* - Olivier Girard, olgirard@gmail.com *//* *//*---------------------------------------------------------------------------*//* $Rev: 200 $ *//* $LastChangedBy: olivier.girard $ *//* $LastChangedDate: 2015-01-21 23:01:31 +0100 (Wed, 21 Jan 2015) $ *//*===========================================================================*/.include "pmem_defs.asm".global mainmain:/* ---------------------- INITIALIZE REGISTERS --------------------- */mov #0x2202, r2mov #0x3333, r3mov #0x4444, r4mov #0x5555, r5mov #0x6666, r6mov #0x7777, r7mov #0x8888, r8mov #0x9999, r9mov #0xaaaa, r10mov #0xbbbb, r11mov #0xcccc, r12mov #0xdddd, r13mov #0xeeee, r14mov #0x1000, r15/* ---------------------- TEST WHEN SOURCE IS Rn ------------------- */.set Rn_EDE, DMEM_212+PMEM_EDE_LENGTH.set Rn_TONY, DMEM_214mov #0x4444, r4mov #0x5555, r5add r4, r5 ;# Add r4+r5 (0x4444+0x5555=0x9999)mov #0x000a, r4add r4, r0nopnopnopmov #0x1234, r4 ;# Make sure the jump is takentest_Rn_PC:mov #0x2222, &DMEM_210mov #DMEM_200, r6mov #0x3333, r7add r7, 16(r6) ;# Write 0x2222+0x3333=0x5555 to memory @0x0210mov #0x4444, &DMEM_212mov #0x5678, r7add r7, Rn_EDE ;# Write 0x4444+0x5678=0x9abc to memory @0x0212mov #0x5555, &DMEM_214mov #0x1234, r8add r8, &Rn_TONY ;# Write 0x5555+0x1234=0x6789 to memory @0x0214mov #0x2000, r15/* ---------------------- TEST WHEN SOURCE IS @Rn ------------------ */.set aRn_EDE, DMEM_212+PMEM_EDE_LENGTH.set aRn_TONY, DMEM_214mov #DMEM_200, r4mov #0x1111, &DMEM_200mov #0x6666, r5add @r4, r5 ;# Add @r4+r5 (0x1111+0x6666=0x7777)mov #DMEM_200, r4mov #0x000a, &DMEM_200add @r4, r0nopnopnopmov #0x1234, r4 ;# Make sure the jump is takentest_aRn_PC:mov #0x1234, &DMEM_20Emov #0x5432, &DMEM_210mov #DMEM_200, r6mov #DMEM_20E, r7add @r7, 16(r6) ;# Write 0x1234+0x5432=0x6666 to memory @0x0210mov #0x5f12, &DMEM_200mov #0x8e1c, &DMEM_212mov #DMEM_200, r7add @r7, aRn_EDE ;# Write 0x5f12+0x8e1c=0xed2e to memory @0x0212mov #0x3112, &DMEM_202mov #0x1541, &DMEM_214mov #DMEM_202, r8add @r8, &aRn_TONY ;# Write 0x3112+0x1541=0x4653 to memory @0x0214mov #0x3000, r15/* ---------------------- TEST WHEN SOURCE IS @Rn+ ----------------- */.set aRni_EDE, DMEM_212+PMEM_EDE_LENGTH.set aRni_TONY, DMEM_214mov #DMEM_200, r4mov #0x2222, &DMEM_200mov #0x8888, r5add @r4+, r5 ;# Add @r4+r5 (0x2222+0x8888=0xaaaa)mov #DMEM_204, r6mov #0x000a, &DMEM_204add @r6+, r0nopnopnopmov #0x1234, r6 ;# Make sure the jump is takentest_aRni_PC:mov #0x1234, &DMEM_20Emov #0x5432, &DMEM_210mov #DMEM_200, r8mov #DMEM_20E, r7add @r7+, 16(r8) ;# Write 0x1234+0x5432=0x6666 to memory @0x0210mov #0x5f12, &DMEM_206mov #0x8e1c, &DMEM_212mov #DMEM_206, r8add @r8+, aRni_EDE ;# Write 0x5f12+0x8e1c=0xed2e to memory @0x0212mov #0x3112, &DMEM_202mov #0x1541, &DMEM_214mov #DMEM_202, r9add @r9+, &aRni_TONY ;# Write 0x3112+0x1541=0x4653 to memory @0x0214mov #0x4000, r15/* ---------------------- TEST WHEN SOURCE IS #N ------------------- */.set N_EDE, DMEM_210+PMEM_EDE_LENGTH.set N_TONY, DMEM_206mov #0x3210, r4add #0x1234, r4 ;# Write 0x3210+0x1234=0x4444 to R4mov #0x0000, r5add #0x000a, r0nopnopnopmov #0x1234, r5 ;# Make sure the jump is takentest_N_PC:mov #0x5432, &DMEM_230mov #DMEM_200, r6add #0x5a5a, 48(r6) ;# Write 0x5432+0x5a5a=0xae8c to memory @0x0230mov #0x4325, &DMEM_210add #0x1a2b, N_EDE ;# Write 0x4325+0x1a2b=0x5d50 to memory @0x0210mov #0x3254, &DMEM_206add #0x3c4d, &N_TONY ;# Write 0x3254+0x3c4d=0x6ea1 to memory @0x0206mov #0x5000, r15/* ---------------------- TEST WHEN SOURCE IS x(Rn) ---------------- */.set xRn_EDE, DMEM_220+PMEM_EDE_LENGTH.set xRn_TONY, DMEM_208mov #0x8347, &DMEM_210mov #0x1234, r5mov #DMEM_200, r4add 16(r4), r5 ;# Write 0x8347+0x1234=0x957b to R5mov #0x000a, &DMEM_208mov #DMEM_200, r4mov #0x1234, r6add 8(r4), r0nopnopnopnopmov #0x0000, r6 ;# Make sure the jump is takentest_xRn_PC:mov #0x4241, &DMEM_210mov #0x1535, &DMEM_214mov #DMEM_200, r7mov #DMEM_202, r8add 16(r7), 18(r8) ;# Write 0x4241+0x1535=0x5776 to memory @0x214mov #0x7238, &DMEM_204mov #0x2143, &DMEM_220mov #DMEM_200, r7add 4(r7), xRn_EDE ;# Write 0x7238+0x2143=0x937b to memory @0x220mov #0x98b2, &DMEM_216mov #0x1432, &DMEM_208mov #DMEM_200, r7add 22(r4), &xRn_TONY ;# Write 0x0x98b2+0x1432=0xace4 to memory @0x208mov #0x6000, r15/* ---------------------- TEST WHEN SOURCE IS 'EDE' ---------------- */.set EDE_EDE, DMEM_216+PMEM_EDE_LENGTH.set EDE_TONY, DMEM_212.set EDE_200, DMEM_200+PMEM_EDE_LENGTH.set EDE_202, DMEM_202+PMEM_EDE_LENGTH.set EDE_204, DMEM_204+PMEM_EDE_LENGTH.set EDE_206, DMEM_206+PMEM_EDE_LENGTH.set EDE_208, DMEM_208+PMEM_EDE_LENGTHmov #0xc3d6, &DMEM_200mov #0x1234, &DMEM_204mov #0x4321, r4add EDE_200, r4 ;# Write 0xc3d6+0x4321=0x06f7 to R4mov #0x000a, &DMEM_202mov #0x1234, &DMEM_204mov #0x3456, r6add EDE_202, r0nopnopnopnopmov #0x0000, r6 ;# Make sure the jump is takentest_EDE_PC:mov #DMEM_202, r8mov #0xf712, &DMEM_204mov #0x1234, &DMEM_214mov #0x0000, &DMEM_208add EDE_204, 18(r8) ;# Write 0xf712+0x1234=0x0946 to memory @0x214mov #0xb3a9, &DMEM_206mov #0x058a, &DMEM_216mov #0x1234, &DMEM_208add EDE_206, EDE_EDE ;# Write 0xb3a9+0x058a=0xb933 to memory @0x216mov #0x837A, &DMEM_208mov #0xA738, &DMEM_212mov #0x1234, &DMEM_20Aadd EDE_208, &EDE_TONY ;# Write 0x837A+0xA738=0x2ab2 to memory @0x212mov #0x7000, r15/* ---------------------- TEST WHEN SOURCE IS '&EDE' --------------- */.set aEDE_EDE, DMEM_218+PMEM_EDE_LENGTH.set aEDE_TONY, DMEM_202mov #0x23d4, &DMEM_200mov #0x1234, &DMEM_202mov #0x4321, r4add &DMEM_200, r4 ;# Write 0x23d4+0x4321=0x66f5 to R4mov #0x000a, &DMEM_202mov #0x1234, &DMEM_204mov #0x3456, r6add &DMEM_202, r0nopnopnopnopmov #0x0000, r6 ;# Make sure the jump is takentest_aEDE_PC:mov #DMEM_202, r7mov #0x481c, &DMEM_204mov #0x3ab5, &DMEM_214mov #0x1234, &DMEM_206add &DMEM_204, 18(r7) ;# Write 0x481c+0x3ab5=0x82d1 to memory @0x214mov #0x5c1f, &DMEM_206mov #0x6e2f, &DMEM_218mov #0x1234, &DMEM_208add &DMEM_206, aEDE_EDE ;# Write 0x5c1f+0x6e2f=0xca4e to memory @0x218mov #0xc16e, &DMEM_208mov #0x51ca, &DMEM_202mov #0x1234, &DMEM_20Aadd &DMEM_208, &aEDE_TONY ;# Write 0xc16e+0x51ca=0x1338 to memory @0x202mov #0x8000, r15/* ---------------------- TEST WHEN SOURCE IS CONSTANT ------------- */.set CONST_EDE0, DMEM_220+PMEM_EDE_LENGTH.set CONST_EDE1, DMEM_222+PMEM_EDE_LENGTH.set CONST_EDE2, DMEM_224+PMEM_EDE_LENGTH.set CONST_EDE4, DMEM_226+PMEM_EDE_LENGTH.set CONST_EDE8, DMEM_228+PMEM_EDE_LENGTH.set CONST_EDEm1, DMEM_22A+PMEM_EDE_LENGTH.set CONST_TONY0, DMEM_230.set CONST_TONY1, DMEM_232.set CONST_TONY2, DMEM_234.set CONST_TONY4, DMEM_236.set CONST_TONY8, DMEM_238.set CONST_TONYm1, DMEM_23Amov #0x4444, r4 ;# Initialize registersmov #0x5555, r5mov #0x6666, r6mov #0x7777, r7mov #0x8888, r8mov #0x9999, r9add #0x0000, r4 ;# Write 0x4444+0 to R4add #0x0001, r5 ;# Write 0x5555+1 to R5add #0x0002, r6 ;# Write 0x6666+2 to R6add #0x0004, r7 ;# Write 0x7777+4 to R7add #0x0008, r8 ;# Write 0x8888+8 to R8add #0xffff, r9 ;# Write 0x9999-1 to R9mov #0x1234, r11add #0x0004, r0clr r11clr r11jmp end_const_r0clr r11clr r11end_const_r0:mov #DMEM_202, r10mov #0x4444, &DMEM_210 ;# Initialize Memorymov #0x5555, &DMEM_212mov #0x6666, &DMEM_214mov #0x7777, &DMEM_216mov #0x8888, &DMEM_218mov #0x9999, &DMEM_21Aadd #0x0000, 14(r10) ;# Move 0x4444+0 to memory @0x210add #0x0001, 16(r10) ;# Move 0x5555+1 to memory @0x212add #0x0002, 18(r10) ;# Move 0x6666+2 to memory @0x214add #0x0004, 20(r10) ;# Move 0x7777+4 to memory @0x216add #0x0008, 22(r10) ;# Move 0x8888+8 to memory @0x218add #0xffff, 24(r10) ;# Move 0x9999-1 to memory @0x21Amov #0x4444, &DMEM_220 ;# Initialize Memorymov #0x5555, &DMEM_222mov #0x6666, &DMEM_224mov #0x7777, &DMEM_226mov #0x8888, &DMEM_228mov #0x9999, &DMEM_22Aadd #0x0000, CONST_EDE0 ;# Move 0x4444+0 to memory @0x220add #0x0001, CONST_EDE1 ;# Move 0x5555+1 to memory @0x222add #0x0002, CONST_EDE2 ;# Move 0x6666+2 to memory @0x224add #0x0004, CONST_EDE4 ;# Move 0x7777+4 to memory @0x226add #0x0008, CONST_EDE8 ;# Move 0x8888+8 to memory @0x228add #0xffff, CONST_EDEm1 ;# Move 0x9999-1 to memory @0x22Amov #0x4444, &DMEM_230 ;# Initialize Memorymov #0x5555, &DMEM_232mov #0x6666, &DMEM_234mov #0x7777, &DMEM_236mov #0x8888, &DMEM_238mov #0x9999, &DMEM_23Aadd #0x0000, &CONST_TONY0 ;# Move 0x4444+0 to memory @0x230add #0x0001, &CONST_TONY1 ;# Move 0x5555+1 to memory @0x232add #0x0002, &CONST_TONY2 ;# Move 0x6666+2 to memory @0x234add #0x0004, &CONST_TONY4 ;# Move 0x7777+4 to memory @0x236add #0x0008, &CONST_TONY8 ;# Move 0x8888+8 to memory @0x238add #0xffff, &CONST_TONYm1 ;# Move 0x9999-1 to memory @0x23Amov #0x9000, r15/* ------------------------------ TEST FLAGS ---------------------- */mov #0x0000, r2 ;# V=0, N=0, Z=0, C=0mov #0x0444, r4 ;#mov #0x0555, r5 ;#add r4, r5 ;# Add r4+r5 (0x0444+0x0555=0x0999)mov #0xA000, r15mov #0x0000, r2 ;# V=0, N=0, Z=0, C=1mov #0x0011, r4 ;#mov #0xfff0, r5 ;#add r4, r5 ;# Add r4+r5 (0xfff0+0x0011=0x0001)mov #0xA001, r15mov #0x0000, r2 ;# V=0, N=0, Z=1, C=0mov #0x0000, r4 ;#mov #0x0000, r5 ;#add r4, r5 ;# Add r4+r5 (0x0000+0x0000=0x0000)mov #0xA002, r15mov #0x0000, r2 ;# V=0, N=1, Z=0, C=0mov #0xff00, r4 ;#mov #0x0010, r5 ;#add r4, r5 ;# Add r4+r5 (0xff00+0x0010=0xff10)mov #0xA003, r15mov #0x0000, r2 ;# V=1, N=1, Z=0, C=0mov #0x7fff, r4 ;#mov #0x0010, r5 ;#add r4, r5 ;# Add r4+r5 (0x7fff+0x0010=0x800f)mov #0xA004, r15mov #0x0000, r2 ;# V=1, N=0, Z=0, C=1mov #0xff00, r4 ;#mov #0x8000, r5 ;#add r4, r5 ;# Add r4+r5 (0xff00+0x8000=0x7f00)mov #0xA005, r15/* ---------------- TEST WHEN SOURCE IS CONSTANT IN BYTE MODE ------ */## NOTE: The following section would not fit in the smallest ROM# configuration for the "two-op_add-b.s43" pattern.# It is therefore executed here.#.set CONSTL_TONY0, DMEM_250.set CONSTL_TONY1, DMEM_252.set CONSTL_TONY2, DMEM_254.set CONSTL_TONY4, DMEM_256.set CONSTL_TONY8, DMEM_258.set CONSTL_TONYm1, DMEM_25A.set CONSTH_TONY0, DMEM_25D.set CONSTH_TONY1, DMEM_25F.set CONSTH_TONY2, DMEM_261.set CONSTH_TONY4, DMEM_263.set CONSTH_TONY8, DMEM_265.set CONSTH_TONYm1, DMEM_267mov #0xaa44, &DMEM_250 ;# Initialize Memorymov #0xaa55, &DMEM_252mov #0xaa66, &DMEM_254mov #0xaa77, &DMEM_256mov #0xaa35, &DMEM_258mov #0xaa99, &DMEM_25Amov #0xaa55, &DMEM_25Cmov #0xbb55, &DMEM_25Emov #0xcc55, &DMEM_260mov #0xdd55, &DMEM_262mov #0xee55, &DMEM_264mov #0x3355, &DMEM_266add.b #0x0000, &CONSTL_TONY0 ;# Move +0 to memory @0x250add.b #0x0001, &CONSTL_TONY1 ;# Move +1 to memory @0x252add.b #0x0002, &CONSTL_TONY2 ;# Move +2 to memory @0x254add.b #0x0004, &CONSTL_TONY4 ;# Move +4 to memory @0x256add.b #0x0008, &CONSTL_TONY8 ;# Move +8 to memory @0x258add.b #0xffff, &CONSTL_TONYm1 ;# Move -1 to memory @0x25Aadd.b #0x0000, &CONSTH_TONY0 ;# Move +0 to memory @0x25Dadd.b #0x0001, &CONSTH_TONY1 ;# Move +1 to memory @0x25Fadd.b #0x0002, &CONSTH_TONY2 ;# Move +2 to memory @0x261add.b #0x0004, &CONSTH_TONY4 ;# Move +4 to memory @0x263add.b #0x0008, &CONSTH_TONY8 ;# Move +8 to memory @0x265add.b #0xffff, &CONSTH_TONYm1 ;# Move -1 to memory @0x267mov #0xB000, r15/* ------------------ TEST FLAGS IN BYTE MODE --------------------- */mov #0x0000, r2 ;# V=0, N=0, Z=0, C=0mov #0xaa04, r4 ;#mov #0x6605, r5 ;#add.b r4, r5 ;# Add r4+r5 (0xaa04+0x6605=0x0009)mov #0xC000, r15mov #0x0000, r2 ;# V=0, N=0, Z=0, C=1mov #0xaa11, r4 ;#mov #0x66f0, r5 ;#add.b r4, r5 ;# Add r4+r5 (0x0011+0x00f0=0x0001)mov #0xC001, r15mov #0x0000, r2 ;# V=0, N=0, Z=1, C=0mov #0xaa00, r4 ;#mov #0x6600, r5 ;#add.b r4, r5 ;# Add r4+r5 (0x0000+0x0000=0x0000)mov #0xC002, r15mov #0x0000, r2 ;# V=0, N=1, Z=0, C=0mov #0xaaf0, r4 ;#mov #0x6603, r5 ;#add.b r4, r5 ;# Add r4+r5 (0x00f0+0x0003=0x00f3)mov #0xC003, r15mov #0x0000, r2 ;# V=1, N=1, Z=0, C=0mov #0x007f, r4 ;#mov #0x0010, r5 ;#add.b r4, r5 ;# Add r4+r5 (0x007f+0x0010=0x008f)mov #0xC004, r15mov #0x0000, r2 ;# V=1, N=0, Z=0, C=1mov #0x00ff, r4 ;#mov #0x0080, r5 ;#add.b r4, r5 ;# Add r4+r5 (0x00ff+0x0080=0x007f)mov #0xC005, r15/* ---------------------- END OF TEST --------------- */mov #0xD000, r15end_of_test:nopbr #0xffff/* ---------------------- INTERRUPT VECTORS --------------- */.section .vectors, "a".word end_of_test ; Interrupt 0 (lowest priority) <unused>.word end_of_test ; Interrupt 1 <unused>.word end_of_test ; Interrupt 2 <unused>.word end_of_test ; Interrupt 3 <unused>.word end_of_test ; Interrupt 4 <unused>.word end_of_test ; Interrupt 5 <unused>.word end_of_test ; Interrupt 6 <unused>.word end_of_test ; Interrupt 7 <unused>.word end_of_test ; Interrupt 8 <unused>.word end_of_test ; Interrupt 9 <unused>.word end_of_test ; Interrupt 10 Watchdog timer.word end_of_test ; Interrupt 11 <unused>.word end_of_test ; Interrupt 12 <unused>.word end_of_test ; Interrupt 13 <unused>.word end_of_test ; Interrupt 14 NMI.word main ; Interrupt 15 (highest priority) RESET
Go to most recent revision | Compare with Previous | Blame | View Log
