perfaware/part1: Support listing 0044
This commit is contained in:
parent
36ef7ff7e2
commit
3d29edbfc8
@ -7,15 +7,6 @@ set script_dir=%script_dir_backslash:~0,-1%
|
|||||||
set build_dir=%script_dir%\build
|
set build_dir=%script_dir%\build
|
||||||
if not exist %build_dir% mkdir %build_dir%
|
if not exist %build_dir% mkdir %build_dir%
|
||||||
|
|
||||||
copy /Y %script_dir%\listing_0037_single_register_mov %build_dir% 1>NUL
|
|
||||||
copy /Y %script_dir%\listing_0038_many_register_mov %build_dir% 1>NUL
|
|
||||||
copy /Y %script_dir%\listing_0039_more_movs %build_dir% 1>NUL
|
|
||||||
copy /Y %script_dir%\listing_0040_challenge_movs %build_dir% 1>NUL
|
|
||||||
copy /Y %script_dir%\listing_0041_add_sub_cmp_jnz %build_dir% 1>NUL
|
|
||||||
copy /Y %script_dir%\listing_0042_completionist_decode %build_dir% 1>NUL
|
|
||||||
copy /Y %script_dir%\listing_0043_immediate_movs %build_dir% 1>NUL
|
|
||||||
copy /Y %script_dir%\listing_0043_immediate_movs.txt %build_dir% 1>NUL
|
|
||||||
|
|
||||||
REM Build
|
REM Build
|
||||||
REM ===========================================================================
|
REM ===========================================================================
|
||||||
pushd %build_dir%
|
pushd %build_dir%
|
||||||
@ -24,36 +15,58 @@ popd
|
|||||||
|
|
||||||
REM Tests
|
REM Tests
|
||||||
REM ===========================================================================
|
REM ===========================================================================
|
||||||
set listing_0037=%build_dir%\listing_0037_single_register_mov
|
set listing_0037=listing_0037_single_register_mov
|
||||||
%build_dir%\sim8086.exe %listing_0037% > %listing_0037%_disassembled.asm
|
copy /Y %script_dir%\%listing_0037% %build_dir% 1>NUL
|
||||||
nasm %listing_0037%_disassembled.asm
|
set build_dir_listing_0037=%build_dir%\%listing_0037%
|
||||||
fc /B %listing_0037% %listing_0037%_disassembled || exit /b 1
|
%build_dir%\sim8086.exe %build_dir_listing_0037% > %build_dir_listing_0037%_disassembled.asm
|
||||||
|
nasm %build_dir_listing_0037%_disassembled.asm
|
||||||
|
fc /B %build_dir_listing_0037% %build_dir_listing_0037%_disassembled || exit /b 1
|
||||||
|
|
||||||
set listing_0038=%build_dir%\listing_0038_many_register_mov
|
set listing_0038=listing_0038_many_register_mov
|
||||||
%build_dir%\sim8086.exe %listing_0038% > %listing_0038%_disassembled.asm
|
copy /Y %script_dir%\%listing_0038% %build_dir% 1>NUL
|
||||||
nasm %listing_0038%_disassembled.asm
|
set build_dir_listing_0038=%build_dir%\%listing_0038%
|
||||||
fc /B %listing_0038% %listing_0038%_disassembled || exit /b 1
|
%build_dir%\sim8086.exe %build_dir_listing_0038% > %build_dir_listing_0038%_disassembled.asm
|
||||||
|
nasm %build_dir_listing_0038%_disassembled.asm
|
||||||
|
fc /B %build_dir_listing_0038% %build_dir_listing_0038%_disassembled || exit /b 1
|
||||||
|
|
||||||
set listing_0039=%build_dir%\listing_0039_more_movs
|
set listing_0039=listing_0039_more_movs
|
||||||
%build_dir%\sim8086.exe %listing_0039% > %listing_0039%_disassembled.asm
|
copy /Y %script_dir%\%listing_0039% %build_dir% 1>NUL
|
||||||
nasm %listing_0039%_disassembled.asm
|
set build_dir_listing_0039=%build_dir%\%listing_0039%
|
||||||
fc /B %listing_0039% %listing_0039%_disassembled || exit /b 1
|
%build_dir%\sim8086.exe %build_dir_listing_0039% > %build_dir_listing_0039%_disassembled.asm
|
||||||
|
nasm %build_dir_listing_0039%_disassembled.asm
|
||||||
|
fc /B %build_dir_listing_0039% %build_dir_listing_0039%_disassembled || exit /b 1
|
||||||
|
|
||||||
set listing_0040=%build_dir%\listing_0040_challenge_movs
|
set listing_0040=listing_0040_challenge_movs
|
||||||
%build_dir%\sim8086.exe %listing_0040% > %listing_0040%_disassembled.asm
|
copy /Y %script_dir%\%listing_0040% %build_dir% 1>NUL
|
||||||
nasm %listing_0040%_disassembled.asm
|
set build_dir_listing_0040=%build_dir%\%listing_0040%
|
||||||
fc /B %listing_0040% %listing_0040%_disassembled || exit /b 1
|
%build_dir%\sim8086.exe %build_dir_listing_0040% > %build_dir_listing_0040%_disassembled.asm
|
||||||
|
nasm %build_dir_listing_0040%_disassembled.asm
|
||||||
|
fc /B %build_dir_listing_0040% %build_dir_listing_0040%_disassembled || exit /b 1
|
||||||
|
|
||||||
set listing_0041=%build_dir%\listing_0041_add_sub_cmp_jnz
|
set listing_0041=listing_0041_add_sub_cmp_jnz
|
||||||
%build_dir%\sim8086.exe %listing_0041% > %listing_0041%_disassembled.asm
|
copy /Y %script_dir%\%listing_0041% %build_dir% 1>NUL
|
||||||
nasm %listing_0041%_disassembled.asm
|
set build_dir_listing_0041=%build_dir%\%listing_0041%
|
||||||
fc /B %listing_0041% %listing_0041%_disassembled || exit /b 1
|
%build_dir%\sim8086.exe %build_dir_listing_0041% > %build_dir_listing_0041%_disassembled.asm
|
||||||
|
nasm %build_dir_listing_0041%_disassembled.asm
|
||||||
|
fc /B %build_dir_listing_0041% %build_dir_listing_0041%_disassembled || exit /b 1
|
||||||
|
|
||||||
set listing_0042=%build_dir%\listing_0042_completionist_decode
|
set listing_0042=listing_0042_completionist_decode
|
||||||
%build_dir%\sim8086.exe %listing_0042% > %listing_0042%_disassembled.asm
|
copy /Y %script_dir%\%listing_0042% %build_dir% 1>NUL
|
||||||
nasm %listing_0042%_disassembled.asm
|
set build_dir_listing_0042=%build_dir%\%listing_0042%
|
||||||
fc /B %listing_0042% %listing_0042%_disassembled || exit /b 1
|
%build_dir%\sim8086.exe %build_dir_listing_0042% > %build_dir_listing_0042%_disassembled.asm
|
||||||
|
nasm %build_dir_listing_0042%_disassembled.asm
|
||||||
|
fc /B %build_dir_listing_0042% %build_dir_listing_0042%_disassembled || exit /b 1
|
||||||
|
|
||||||
set listing_0043=%build_dir%\listing_0043_immediate_movs
|
set listing_0043=listing_0043_immediate_movs
|
||||||
%build_dir%\sim8086.exe --exec %listing_0043% > %listing_0043%_disassembled.txt
|
copy /Y %script_dir%\%listing_0043% %build_dir% 1>NUL
|
||||||
fc /N %listing_0043%.txt %listing_0043%_disassembled.txt || exit /b 1
|
copy /Y %script_dir%\%listing_0043%.txt %build_dir% 1>NUL
|
||||||
|
set build_dir_listing_0043=%build_dir%\%listing_0043%
|
||||||
|
%build_dir%\sim8086.exe --exec %build_dir_listing_0043% > %build_dir_listing_0043%_disassembled.txt
|
||||||
|
fc /N %build_dir_listing_0043%.txt %build_dir_listing_0043%_disassembled.txt || exit /b 1
|
||||||
|
|
||||||
|
set listing_0044=listing_0044_register_movs
|
||||||
|
copy /Y %script_dir%\%listing_0044% %build_dir% 1>NUL
|
||||||
|
copy /Y %script_dir%\%listing_0044%.txt %build_dir% 1>NUL
|
||||||
|
set build_dir_listing_0044=%build_dir%\%listing_0044%
|
||||||
|
%build_dir%\sim8086.exe --exec %build_dir_listing_0044% > %build_dir_listing_0044%_disassembled.txt
|
||||||
|
fc /N %build_dir_listing_0044%.txt %build_dir_listing_0044%_disassembled.txt || exit /b 1
|
||||||
|
BIN
part1/listing_0044_register_movs
Normal file
BIN
part1/listing_0044_register_movs
Normal file
Binary file not shown.
32
part1/listing_0044_register_movs.asm
Normal file
32
part1/listing_0044_register_movs.asm
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
; ========================================================================
|
||||||
|
;
|
||||||
|
; (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 44
|
||||||
|
; ========================================================================
|
||||||
|
|
||||||
|
bits 16
|
||||||
|
|
||||||
|
mov ax, 1
|
||||||
|
mov bx, 2
|
||||||
|
mov cx, 3
|
||||||
|
mov dx, 4
|
||||||
|
|
||||||
|
mov sp, ax
|
||||||
|
mov bp, bx
|
||||||
|
mov si, cx
|
||||||
|
mov di, dx
|
||||||
|
|
||||||
|
mov dx, sp
|
||||||
|
mov cx, bp
|
||||||
|
mov bx, si
|
||||||
|
mov ax, di
|
24
part1/listing_0044_register_movs.txt
Normal file
24
part1/listing_0044_register_movs.txt
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
--- test\listing_0044_register_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, ax ; sp:0x0->0x1
|
||||||
|
mov bp, bx ; bp:0x0->0x2
|
||||||
|
mov si, cx ; si:0x0->0x3
|
||||||
|
mov di, dx ; di:0x0->0x4
|
||||||
|
mov dx, sp ; dx:0x4->0x1
|
||||||
|
mov cx, bp ; cx:0x3->0x2
|
||||||
|
mov bx, si ; bx:0x2->0x3
|
||||||
|
mov ax, di ; ax:0x1->0x4
|
||||||
|
|
||||||
|
Final registers:
|
||||||
|
ax: 0x0004 (4)
|
||||||
|
bx: 0x0003 (3)
|
||||||
|
cx: 0x0002 (2)
|
||||||
|
dx: 0x0001 (1)
|
||||||
|
sp: 0x0001 (1)
|
||||||
|
bp: 0x0002 (2)
|
||||||
|
si: 0x0003 (3)
|
||||||
|
di: 0x0004 (4)
|
||||||
|
|
@ -1172,6 +1172,18 @@ int main(int argc, char **argv)
|
|||||||
S86_Str8 mnemonic_op = S86_MnemonicOpStr8(dest_map->mnemonic_op);
|
S86_Str8 mnemonic_op = S86_MnemonicOpStr8(dest_map->mnemonic_op);
|
||||||
S86_PrintFmt(" ; %.*s:0x%x->0x%x ", S86_STR8_FMT(mnemonic_op), *dest, opcode.immediate);
|
S86_PrintFmt(" ; %.*s:0x%x->0x%x ", S86_STR8_FMT(mnemonic_op), *dest, opcode.immediate);
|
||||||
*dest = (uint16_t)opcode.immediate;
|
*dest = (uint16_t)opcode.immediate;
|
||||||
|
} else if (opcode.src >= S86_MnemonicOp_AX && opcode.src <= S86_MnemonicOp_DI) {
|
||||||
|
MnemonicOpToRegisterFileMap const *src_map = NULL;
|
||||||
|
for (size_t index = 0; !src_map && index < S86_ARRAY_UCOUNT(mnemonic_op_to_register_file_map); index++) {
|
||||||
|
MnemonicOpToRegisterFileMap const *item = mnemonic_op_to_register_file_map + index;
|
||||||
|
if (item->mnemonic_op == opcode.src)
|
||||||
|
src_map = item;
|
||||||
|
}
|
||||||
|
|
||||||
|
S86_Str8 dest_op = S86_MnemonicOpStr8(dest_map->mnemonic_op);
|
||||||
|
uint16_t *src = src_map->reg;
|
||||||
|
S86_PrintFmt(" ; %.*s:0x%x->0x%x ", S86_STR8_FMT(dest_op), *dest, *src);
|
||||||
|
*dest = *src;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1186,7 +1198,8 @@ int main(int argc, char **argv)
|
|||||||
S86_PrintLnFmt(" dx: 0x%04x (%u)", register_file.dx, register_file.dx);
|
S86_PrintLnFmt(" dx: 0x%04x (%u)", register_file.dx, register_file.dx);
|
||||||
S86_PrintLnFmt(" sp: 0x%04x (%u)", register_file.sp, register_file.sp);
|
S86_PrintLnFmt(" sp: 0x%04x (%u)", register_file.sp, register_file.sp);
|
||||||
S86_PrintLnFmt(" bp: 0x%04x (%u)", register_file.bp, register_file.bp);
|
S86_PrintLnFmt(" bp: 0x%04x (%u)", register_file.bp, register_file.bp);
|
||||||
S86_PrintLnFmt(" si: 0x%04x (%u)", register_file.si, register_file.si); S86_PrintLnFmt(" di: 0x%04x (%u)", register_file.di, register_file.di);
|
S86_PrintLnFmt(" si: 0x%04x (%u)", register_file.si, register_file.si);
|
||||||
|
S86_PrintLnFmt(" di: 0x%04x (%u)", register_file.di, register_file.di);
|
||||||
S86_Print(S86_STR8("\n"));
|
S86_Print(S86_STR8("\n"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user