From 12d48aea27025f86d54eb13f76fa100cfcf9820a Mon Sep 17 00:00:00 2001 From: iliya <iliya.saroukha@hes-so.ch> Date: Sun, 15 Oct 2023 11:40:10 +0200 Subject: [PATCH] feat: ex2 labo3 finished --- 2-3_asm/.cproject | 4 ++-- 2-3_asm/src/assembleur.s | 23 +++++++++++++++++++++-- 2-3_asm/src/labo2.3_asm.c | 2 +- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/2-3_asm/.cproject b/2-3_asm/.cproject index d5614f2..4ee1181 100644 --- a/2-3_asm/.cproject +++ b/2-3_asm/.cproject @@ -55,7 +55,7 @@ <tool id="com.crt.advproject.link.exe.debug.742972049" name="MCU Linker" superClass="com.crt.advproject.link.exe.debug"> <option id="com.crt.advproject.link.arch.1188867588" name="Architecture" superClass="com.crt.advproject.link.arch" value="com.crt.advproject.link.target.cm3" valueType="enumerated"/> <option id="com.crt.advproject.link.thumb.1248295488" name="Thumb mode" superClass="com.crt.advproject.link.thumb" value="true" valueType="boolean"/> - <option id="com.crt.advproject.link.script.1785160227" name="Linker script" superClass="com.crt.advproject.link.script" value="labo2_3_asm_Debug.ld" valueType="string"/> + <option id="com.crt.advproject.link.script.1785160227" name="Linker script" superClass="com.crt.advproject.link.script" value="2-3_asm_Debug.ld" valueType="string"/> <option id="com.crt.advproject.link.manage.994083104" name="Manage linker script" superClass="com.crt.advproject.link.manage" value="true" valueType="boolean"/> <option id="gnu.c.link.option.nostdlibs.1585246591" name="No startup or default libs (-nostdlib)" superClass="gnu.c.link.option.nostdlibs" value="true" valueType="boolean"/> <option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.c.link.option.other.2121008218" name="Other options (-Xlinker [option])" superClass="gnu.c.link.option.other" valueType="stringList"> @@ -139,7 +139,7 @@ <tool id="com.crt.advproject.link.exe.release.1012924607" name="MCU Linker" superClass="com.crt.advproject.link.exe.release"> <option id="com.crt.advproject.link.arch.287050390" name="Architecture" superClass="com.crt.advproject.link.arch" value="com.crt.advproject.link.target.cm3" valueType="enumerated"/> <option id="com.crt.advproject.link.thumb.1115921405" name="Thumb mode" superClass="com.crt.advproject.link.thumb" value="true" valueType="boolean"/> - <option id="com.crt.advproject.link.script.754134938" name="Linker script" superClass="com.crt.advproject.link.script" value="labo2_3_asm_Release.ld" valueType="string"/> + <option id="com.crt.advproject.link.script.754134938" name="Linker script" superClass="com.crt.advproject.link.script" value="2-3_asm_Release.ld" valueType="string"/> <option id="com.crt.advproject.link.manage.1283042874" name="Manage linker script" superClass="com.crt.advproject.link.manage" value="true" valueType="boolean"/> <option id="gnu.c.link.option.nostdlibs.2116952709" name="No startup or default libs (-nostdlib)" superClass="gnu.c.link.option.nostdlibs" value="true" valueType="boolean"/> <option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.c.link.option.other.2082339787" name="Other options (-Xlinker [option])" superClass="gnu.c.link.option.other" valueType="stringList"> diff --git a/2-3_asm/src/assembleur.s b/2-3_asm/src/assembleur.s index 7ec1956..9339342 100644 --- a/2-3_asm/src/assembleur.s +++ b/2-3_asm/src/assembleur.s @@ -29,7 +29,7 @@ funcexo1: eor r0, r2 eor r0, r3 str r0, [r4] - pop {r4} + pop {r4} // restitution du registre bx lr @@ -58,8 +58,27 @@ mult32: *****************************************************/ .thumb_func funcexo2: + push {r4, r5, lr} // sauvegarde du registre + bl mult32 + cmp r1, #1 + beq err_ex2 + mov r4, r0 + mov r0, r2 + mov r1, r3 + bl mult32 + cmp r1, #1 + beq err_ex2 + mov r5, r0 + adds r4, r5 + bhi err_ex2 + mov r0, r4 + pop {r4, r5, lr} // restitution du registre + bx lr - bx lr +err_ex2: + pop {r4, r5, lr} // restitution du registre + mov r0, #0 + bx lr /***************************************************** diff --git a/2-3_asm/src/labo2.3_asm.c b/2-3_asm/src/labo2.3_asm.c index 2cc60df..e18d205 100644 --- a/2-3_asm/src/labo2.3_asm.c +++ b/2-3_asm/src/labo2.3_asm.c @@ -24,7 +24,7 @@ uint32_t funcexo2(uint32_t a, uint32_t b, uint32_t c, uint32_t d); int funcexo3(numbers_t s); /* global variables */ -int exo = 1; // change this number with the exercise number you want to test; +int exo = 2; // change this number with the exercise number you want to test; int main(void) { -- GitLab