From d8b3ca9d02377cf04a09e0f518a3385b7324bc4d Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Sun, 19 Oct 2025 23:03:20 +0200 Subject: checkpoint --- .../listing_0053_add_loop_challenge | Bin 0 -> 33 bytes .../listing_0053_add_loop_challenge.asm | 35 ++++++++++++++++++++ .../listing_0053_add_loop_challenge.txt | 36 +++++++++++++++++++++ 3 files changed, 71 insertions(+) create mode 100644 src/data/simulating_memory/listing_0053_add_loop_challenge create mode 100644 src/data/simulating_memory/listing_0053_add_loop_challenge.asm create mode 100644 src/data/simulating_memory/listing_0053_add_loop_challenge.txt (limited to 'src/data/simulating_memory') diff --git a/src/data/simulating_memory/listing_0053_add_loop_challenge b/src/data/simulating_memory/listing_0053_add_loop_challenge new file mode 100644 index 0000000..0678532 Binary files /dev/null and b/src/data/simulating_memory/listing_0053_add_loop_challenge differ diff --git a/src/data/simulating_memory/listing_0053_add_loop_challenge.asm b/src/data/simulating_memory/listing_0053_add_loop_challenge.asm new file mode 100644 index 0000000..f1ec802 --- /dev/null +++ b/src/data/simulating_memory/listing_0053_add_loop_challenge.asm @@ -0,0 +1,35 @@ +; ======================================================================== +; +; (C) Copyright 2023 by Molly Rocket, Inc., All Rights Reserved. +; +; This software is provided 'as-is', without any express or implied +; warranty. In no event will the authors be held liable for any damages +; arising from the use of this software. +; +; Please see https://computerenhance.com for further information +; +; ======================================================================== + +; ======================================================================== +; LISTING 53 +; ======================================================================== + +bits 16 + +mov dx, 6 +mov bp, 1000 + +mov si, 0 +init_loop_start: + mov word [bp + si], si + add si, 2 + cmp si, dx + jnz init_loop_start + +mov bx, 0 +mov si, dx +sub bp, 2 +add_loop_start: + add bx, word [bp + si] + sub si, 2 + jnz add_loop_start diff --git a/src/data/simulating_memory/listing_0053_add_loop_challenge.txt b/src/data/simulating_memory/listing_0053_add_loop_challenge.txt new file mode 100644 index 0000000..79ead2b --- /dev/null +++ b/src/data/simulating_memory/listing_0053_add_loop_challenge.txt @@ -0,0 +1,36 @@ +--- test\listing_0053_add_loop_challenge execution --- +mov dx, 6 ; dx:0x0->0x6 ip:0x0->0x3 +mov bp, 1000 ; bp:0x0->0x3e8 ip:0x3->0x6 +mov si, 0 ; ip:0x6->0x9 +mov word [bp+si], si ; ip:0x9->0xb +add si, 2 ; si:0x0->0x2 ip:0xb->0xe +cmp si, dx ; ip:0xe->0x10 flags:->CPAS +jne $-7 ; ip:0x10->0x9 +mov word [bp+si], si ; ip:0x9->0xb +add si, 2 ; si:0x2->0x4 ip:0xb->0xe flags:CPAS-> +cmp si, dx ; ip:0xe->0x10 flags:->CAS +jne $-7 ; ip:0x10->0x9 +mov word [bp+si], si ; ip:0x9->0xb +add si, 2 ; si:0x4->0x6 ip:0xb->0xe flags:CAS->P +cmp si, dx ; ip:0xe->0x10 flags:P->PZ +jne $-7 ; ip:0x10->0x12 +mov bx, 0 ; ip:0x12->0x15 +mov si, dx ; ip:0x15->0x17 +sub bp, 2 ; bp:0x3e8->0x3e6 ip:0x17->0x1a flags:PZ-> +add bx, [bp+si] ; bx:0x0->0x4 ip:0x1a->0x1c +sub si, 2 ; si:0x6->0x4 ip:0x1c->0x1f +jne $-5 ; ip:0x1f->0x1a +add bx, [bp+si] ; bx:0x4->0x6 ip:0x1a->0x1c flags:->P +sub si, 2 ; si:0x4->0x2 ip:0x1c->0x1f flags:P-> +jne $-5 ; ip:0x1f->0x1a +add bx, [bp+si] ; ip:0x1a->0x1c flags:->P +sub si, 2 ; si:0x2->0x0 ip:0x1c->0x1f flags:P->PZ +jne $-5 ; ip:0x1f->0x21 + +Final registers: + bx: 0x0006 (6) + dx: 0x0006 (6) + bp: 0x03e6 (998) + ip: 0x0021 (33) + flags: PZ + -- cgit v1.2.3-70-g09d2