Bash script to compare expected output, print values in a way that's easy to test
This commit is contained in:
parent
7e74d1e9a2
commit
6e7783c623
19
asm_files/list-0043.txt
Normal file
19
asm_files/list-0043.txt
Normal file
@ -0,0 +1,19 @@
|
||||
--- test\listing_0043_immediate_movs execution ---
|
||||
mov ax, 1 ; ax:0x0->0x1
|
||||
mov bx, 2 ; bx:0x0->0x2
|
||||
mov cx, 3 ; cx:0x0->0x3
|
||||
mov dx, 4 ; dx:0x0->0x4
|
||||
mov sp, 5 ; sp:0x0->0x5
|
||||
mov bp, 6 ; bp:0x0->0x6
|
||||
mov si, 7 ; si:0x0->0x7
|
||||
mov di, 8 ; di:0x0->0x8
|
||||
|
||||
Final registers:
|
||||
ax: 0x0001 (1)
|
||||
bx: 0x0002 (2)
|
||||
cx: 0x0003 (3)
|
||||
dx: 0x0004 (4)
|
||||
sp: 0x0005 (5)
|
||||
bp: 0x0006 (6)
|
||||
si: 0x0007 (7)
|
||||
di: 0x0008 (8)
|
@ -10,13 +10,13 @@ execute_instruction :: proc(inst: Instruction) {
|
||||
case .MOV:
|
||||
if reg_id,ok := inst.dst.(RegisterId); ok {
|
||||
#partial switch val in inst.src {
|
||||
case Immediate8:
|
||||
case Immediate8:
|
||||
registers[reg_id].value.low = (u8)(val)
|
||||
case ImmediateU8:
|
||||
case ImmediateU8:
|
||||
registers[reg_id].value.low = (u8)(val)
|
||||
case Immediate16:
|
||||
registers[reg_id].value.low = (u8)(val)
|
||||
case RegisterId:
|
||||
case Immediate16:
|
||||
registers[reg_id].value.full = (u16)(val)
|
||||
case RegisterId:
|
||||
registers[reg_id].value.full = registers[val].value.full
|
||||
}
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ main :: proc() {
|
||||
for reg in registers {
|
||||
full := fmt.aprintf("%s (%s): %d ", reg.fullname, reg.bytename, reg.value.full)
|
||||
// hex := fmt.aprintf("%s %*[1]s 0x%x ", full, 25 - len(full), "|", reg.value.full)
|
||||
hex := fmt.aprintf("0x%x ", reg.value.full)
|
||||
hex := fmt.aprintf("0x%04x ", reg.value.full)
|
||||
fmt.printf("%s %*[1]s %s %*[4]s %08b %08b",
|
||||
full, 20 - len(full), "|", hex, 10 - len(hex), "|", reg.value.high, reg.value.low)
|
||||
fmt.println()
|
||||
|
23
test_registers.sh
Executable file
23
test_registers.sh
Executable file
@ -0,0 +1,23 @@
|
||||
#!/bin/sh
|
||||
|
||||
GREEN='\033[0;32m'
|
||||
RED='\033[0;31m'
|
||||
NC='\033[0m'
|
||||
|
||||
make asm_files > /dev/null
|
||||
|
||||
if [ ! "$(command -v ./sim8086)" ]; then
|
||||
echo -e "\nError: 'sim8086' executable not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
odin build . -out:sim8086
|
||||
|
||||
for asm_txt in asm_files/*.txt;
|
||||
do
|
||||
asm_listing=$(basename $asm_txt .txt)
|
||||
./sim8086 asm_files/${asm_listing}.bin | awk '{print $1 ":" $5}' | sort > temp1
|
||||
cat $asm_txt | awk '/Final registers/,0' | tail -n +2 | awk '{print $1 $2}' | sort > temp2
|
||||
diff -U0 --color temp1 temp2
|
||||
rm temp1 temp2
|
||||
done
|
Loading…
x
Reference in New Issue
Block a user