perfware/part1: Handle 8088 cycle counter exercise in listing 56
This commit is contained in:
parent
fb286c7f11
commit
56cc90c57b
@ -278,9 +278,9 @@ copy /Y %script_dir%\%listing_0056% %build_dir% 1>NUL
|
|||||||
copy /Y %script_dir%\%listing_0056%.txt %build_dir% 1>NUL
|
copy /Y %script_dir%\%listing_0056%.txt %build_dir% 1>NUL
|
||||||
|
|
||||||
pushd %build_dir%
|
pushd %build_dir%
|
||||||
%build_dir%\sim8086.exe --exec --log-instruction-ptr --log-cycle-counts 8086 --dump %build_dir_listing_0056% > %build_dir_listing_0056%_disassembled.txt
|
%build_dir%\sim8086.exe --exec --log-instruction-ptr --log-cycle-counts 8086 %build_dir_listing_0056% > %build_dir_listing_0056%_disassembled.txt
|
||||||
%build_dir%\sim8086.exe %build_dir_listing_0056% > %build_dir_listing_0056%_disassembled.asm
|
%build_dir%\sim8086.exe %build_dir_listing_0056% > %build_dir_listing_0056%_disassembled.asm
|
||||||
%build_dir%\sim8086.exe --exec --log-instruction-ptr --log-cycle-counts 8088 --dump %build_dir_listing_0056% >> %build_dir_listing_0056%_disassembled.txt
|
%build_dir%\sim8086.exe --exec --log-instruction-ptr --log-cycle-counts 8088 %build_dir_listing_0056% >> %build_dir_listing_0056%_disassembled.txt
|
||||||
popd
|
popd
|
||||||
|
|
||||||
nasm %build_dir_listing_0056%_disassembled.asm
|
nasm %build_dir_listing_0056%_disassembled.asm
|
||||||
|
@ -34,7 +34,6 @@ Final registers:
|
|||||||
di: 0x0fa0 (4000)
|
di: 0x0fa0 (4000)
|
||||||
ip: 0x0037 (55)
|
ip: 0x0037 (55)
|
||||||
|
|
||||||
|
|
||||||
**************
|
**************
|
||||||
**** 8088 ****
|
**** 8088 ****
|
||||||
**************
|
**************
|
||||||
@ -44,24 +43,24 @@ They will be inaccurate, both because the manual clocks are estimates, and becau
|
|||||||
some of the entries in the manual look highly suspicious and are probably typos.
|
some of the entries in the manual look highly suspicious and are probably typos.
|
||||||
|
|
||||||
--- test\listing_0056_estimating_cycles execution ---
|
--- test\listing_0056_estimating_cycles execution ---
|
||||||
mov bx, 1000 ; Clocks: +4 = 4 | bx:0x0->0x3e8 ip:0x0->0x3
|
mov bx, 1000 ; Clocks: +4 = 4 | bx:0x0->0x3e8 ip:0x0->0x3
|
||||||
mov bp, 2000 ; Clocks: +4 = 8 | bp:0x0->0x7d0 ip:0x3->0x6
|
mov bp, 2000 ; Clocks: +4 = 8 | bp:0x0->0x7d0 ip:0x3->0x6
|
||||||
mov si, 3000 ; Clocks: +4 = 12 | si:0x0->0xbb8 ip:0x6->0x9
|
mov si, 3000 ; Clocks: +4 = 12 | si:0x0->0xbb8 ip:0x6->0x9
|
||||||
mov di, 4000 ; Clocks: +4 = 16 | di:0x0->0xfa0 ip:0x9->0xc
|
mov di, 4000 ; Clocks: +4 = 16 | di:0x0->0xfa0 ip:0x9->0xc
|
||||||
mov cx, bx ; Clocks: +2 = 18 | cx:0x0->0x3e8 ip:0xc->0xe
|
mov cx, bx ; Clocks: +2 = 18 | cx:0x0->0x3e8 ip:0xc->0xe
|
||||||
mov dx, 12 ; Clocks: +4 = 22 | dx:0x0->0xc ip:0xe->0x11
|
mov dx, 12 ; Clocks: +4 = 22 | dx:0x0->0xc ip:0xe->0x11
|
||||||
mov dx, [+1000] ; Clocks: +18 = 40 (8 + 6ea + 4p) | dx:0xc->0x0 ip:0x11->0x15
|
mov dx, [+1000] ; Clocks: +18 = 40 (8 + 6ea + 4p) | dx:0xc->0x0 ip:0x11->0x15
|
||||||
mov cx, [bx] ; Clocks: +17 = 57 (8 + 5ea + 4p) | cx:0x3e8->0x0 ip:0x15->0x17
|
mov cx, [bx] ; Clocks: +17 = 57 (8 + 5ea + 4p) | cx:0x3e8->0x0 ip:0x15->0x17
|
||||||
mov cx, [bp] ; Clocks: +17 = 74 (8 + 5ea + 4p) | ip:0x17->0x1a
|
mov cx, [bp] ; Clocks: +17 = 74 (8 + 5ea + 4p) | ip:0x17->0x1a
|
||||||
mov word [si], cx ; Clocks: +18 = 92 (9 + 5ea + 4p) | ip:0x1a->0x1c
|
mov word [si], cx ; Clocks: +18 = 92 (9 + 5ea + 4p) | ip:0x1a->0x1c
|
||||||
mov word [di], cx ; Clocks: +18 = 110 (9 + 5ea + 4p) | ip:0x1c->0x1e
|
mov word [di], cx ; Clocks: +18 = 110 (9 + 5ea + 4p) | ip:0x1c->0x1e
|
||||||
mov cx, [bx+1000] ; Clocks: +21 = 131 (8 + 9ea + 4p) | ip:0x1e->0x22
|
mov cx, [bx+1000] ; Clocks: +21 = 131 (8 + 9ea + 4p) | ip:0x1e->0x22
|
||||||
mov cx, [bp+1000] ; Clocks: +21 = 152 (8 + 9ea + 4p) | ip:0x22->0x26
|
mov cx, [bp+1000] ; Clocks: +21 = 152 (8 + 9ea + 4p) | ip:0x22->0x26
|
||||||
mov word [si+1000], cx ; Clocks: +22 = 174 (9 + 9ea + 4p) | ip:0x26->0x2a
|
mov word [si+1000], cx ; Clocks: +22 = 174 (9 + 9ea + 4p) | ip:0x26->0x2a
|
||||||
mov word [di+1000], cx ; Clocks: +22 = 196 (9 + 9ea + 4p) | ip:0x2a->0x2e
|
mov word [di+1000], cx ; Clocks: +22 = 196 (9 + 9ea + 4p) | ip:0x2a->0x2e
|
||||||
add cx, dx ; Clocks: +3 = 199 | ip:0x2e->0x30 flags:->PZ
|
add cx, dx ; Clocks: +3 = 199 | ip:0x2e->0x30 flags:->PZ
|
||||||
add word [di+1000], cx ; Clocks: +33 = 232 (16 + 9ea + 8p) | ip:0x30->0x34
|
add word [di+1000], cx ; Clocks: +33 = 232 (16 + 9ea + 8p) | ip:0x30->0x34
|
||||||
add dx, 50 ; Clocks: +4 = 236 | dx:0x0->0x32 ip:0x34->0x37 flags:PZ->
|
add dx, 50 ; Clocks: +4 = 236 | dx:0x0->0x32 ip:0x34->0x37 flags:PZ->
|
||||||
|
|
||||||
Final registers:
|
Final registers:
|
||||||
bx: 0x03e8 (1000)
|
bx: 0x03e8 (1000)
|
||||||
@ -70,3 +69,4 @@ Final registers:
|
|||||||
si: 0x0bb8 (3000)
|
si: 0x0bb8 (3000)
|
||||||
di: 0x0fa0 (4000)
|
di: 0x0fa0 (4000)
|
||||||
ip: 0x0037 (55)
|
ip: 0x0037 (55)
|
||||||
|
|
||||||
|
@ -869,12 +869,21 @@ S86_Opcode S86_DecodeOpcode(S86_BufferIterator *buffer_it,
|
|||||||
} else if (S86_MnemonicOpIsRegister(result.dest) && result.src == S86_MnemonicOp_DirectAddress && result.effective_addr_loads_mem && result.effective_addr == S86_EffectiveAddress_Src) {
|
} else if (S86_MnemonicOpIsRegister(result.dest) && result.src == S86_MnemonicOp_DirectAddress && result.effective_addr_loads_mem && result.effective_addr == S86_EffectiveAddress_Src) {
|
||||||
result.base_clocks = 8;
|
result.base_clocks = 8;
|
||||||
result.effective_address_clocks = 6;
|
result.effective_address_clocks = 6;
|
||||||
|
if (cycle_count_8088 && result.wide) {
|
||||||
|
result.transfer_penalty_clocks = 4;
|
||||||
|
}
|
||||||
} else if (S86_MnemonicOpIsRegister(result.dest) && S86_MnemonicOpIsRegister(result.src) && result.effective_addr_loads_mem && result.effective_addr == S86_EffectiveAddress_Src) {
|
} else if (S86_MnemonicOpIsRegister(result.dest) && S86_MnemonicOpIsRegister(result.src) && result.effective_addr_loads_mem && result.effective_addr == S86_EffectiveAddress_Src) {
|
||||||
result.base_clocks = 8;
|
result.base_clocks = 8;
|
||||||
result.effective_address_clocks = result.displacement ? 9 : 5;
|
result.effective_address_clocks = result.displacement ? 9 : 5;
|
||||||
|
if (cycle_count_8088 && result.wide) {
|
||||||
|
result.transfer_penalty_clocks = 4;
|
||||||
|
}
|
||||||
} else if (S86_MnemonicOpIsRegister(result.dest) && S86_MnemonicOpIsRegister(result.src) && result.effective_addr_loads_mem && result.effective_addr == S86_EffectiveAddress_Dest) {
|
} else if (S86_MnemonicOpIsRegister(result.dest) && S86_MnemonicOpIsRegister(result.src) && result.effective_addr_loads_mem && result.effective_addr == S86_EffectiveAddress_Dest) {
|
||||||
result.base_clocks = 9;
|
result.base_clocks = 9;
|
||||||
result.effective_address_clocks = result.displacement ? 9 : 5;
|
result.effective_address_clocks = result.displacement ? 9 : 5;
|
||||||
|
if (cycle_count_8088 && result.wide) {
|
||||||
|
result.transfer_penalty_clocks = 4;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (op_decode_type >= S86_OpDecodeType_ADDRegOrMemToOrFromReg && op_decode_type <= S86_OpDecodeType_ADDImmediateToAccum) {
|
} else if (op_decode_type >= S86_OpDecodeType_ADDRegOrMemToOrFromReg && op_decode_type <= S86_OpDecodeType_ADDImmediateToAccum) {
|
||||||
if (S86_MnemonicOpIsRegister(result.dest) && S86_MnemonicOpIsRegister(result.src) && result.effective_addr == S86_EffectiveAddress_None) {
|
if (S86_MnemonicOpIsRegister(result.dest) && S86_MnemonicOpIsRegister(result.src) && result.effective_addr == S86_EffectiveAddress_None) {
|
||||||
@ -882,13 +891,14 @@ S86_Opcode S86_DecodeOpcode(S86_BufferIterator *buffer_it,
|
|||||||
} else if (S86_MnemonicOpIsRegister(result.dest) && S86_MnemonicOpIsRegister(result.src) && result.effective_addr == S86_EffectiveAddress_Dest) {
|
} else if (S86_MnemonicOpIsRegister(result.dest) && S86_MnemonicOpIsRegister(result.src) && result.effective_addr == S86_EffectiveAddress_Dest) {
|
||||||
result.base_clocks = 16;
|
result.base_clocks = 16;
|
||||||
result.effective_address_clocks = result.displacement ? 9 : 5;
|
result.effective_address_clocks = result.displacement ? 9 : 5;
|
||||||
|
if (cycle_count_8088 && result.wide) {
|
||||||
|
result.transfer_penalty_clocks = 4 * 2;
|
||||||
|
}
|
||||||
} else if (S86_MnemonicOpIsRegister(result.dest) && result.src == S86_MnemonicOp_Immediate) {
|
} else if (S86_MnemonicOpIsRegister(result.dest) && result.src == S86_MnemonicOp_Immediate) {
|
||||||
result.base_clocks = 4;
|
result.base_clocks = 4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
(void)cycle_count_8088;
|
|
||||||
|
|
||||||
size_t buffer_end_index = buffer_it->index;
|
size_t buffer_end_index = buffer_it->index;
|
||||||
result.byte_size = S86_CAST(uint8_t)(buffer_end_index - buffer_start_index);
|
result.byte_size = S86_CAST(uint8_t)(buffer_end_index - buffer_start_index);
|
||||||
S86_ASSERT(result.immediate < S86_CAST(uint16_t)-1);
|
S86_ASSERT(result.immediate < S86_CAST(uint16_t)-1);
|
||||||
@ -1729,16 +1739,21 @@ int main(int argc, char **argv)
|
|||||||
register_file.instruction_ptr += S86_CAST(int16_t)opcode.displacement;
|
register_file.instruction_ptr += S86_CAST(int16_t)opcode.displacement;
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
clocks_counter += opcode.base_clocks + opcode.effective_address_clocks;
|
clocks_counter += opcode.base_clocks + opcode.effective_address_clocks + opcode.transfer_penalty_clocks;
|
||||||
|
|
||||||
// NOTE: Printing ==========================================================================
|
// NOTE: Printing ==========================================================================
|
||||||
S86_PrintFmt(" ; ");
|
S86_PrintFmt(" ; ");
|
||||||
|
|
||||||
// NOTE: Clocks
|
// NOTE: Clocks
|
||||||
if (log_cycle_counts) {
|
if (log_cycle_counts) {
|
||||||
S86_PrintFmt("Clocks: +%u = %u", opcode.base_clocks + opcode.effective_address_clocks, clocks_counter);
|
S86_PrintFmt("Clocks: +%u = %u", opcode.base_clocks + opcode.effective_address_clocks + opcode.transfer_penalty_clocks, clocks_counter);
|
||||||
if (opcode.effective_address_clocks) {
|
if (opcode.effective_address_clocks || opcode.transfer_penalty_clocks) {
|
||||||
S86_PrintFmt(" (%u + %uea)", opcode.base_clocks, opcode.effective_address_clocks);
|
S86_PrintFmt(" (%u", opcode.base_clocks);
|
||||||
|
if (opcode.effective_address_clocks)
|
||||||
|
S86_PrintFmt(" + %uea", opcode.effective_address_clocks);
|
||||||
|
if (opcode.transfer_penalty_clocks)
|
||||||
|
S86_PrintFmt(" + %up", opcode.transfer_penalty_clocks);
|
||||||
|
S86_PrintFmt(")");
|
||||||
}
|
}
|
||||||
S86_PrintFmt(" | ");
|
S86_PrintFmt(" | ");
|
||||||
}
|
}
|
||||||
|
BIN
project.rdbg
BIN
project.rdbg
Binary file not shown.
Loading…
Reference in New Issue
Block a user