unit::alu_branch::add_sub: x86 CF and AF are used as borrow flags for subtraction

This commit is contained in:
Jacob Lifshay 2026-05-25 18:44:07 -07:00
parent 5558763718
commit 67abfa2f5d
Signed by: programmerjake
SSH key fingerprint: SHA256:HnFTLGpSm4Q4Fj502oCFisjZSoakwEuTsJJMSke63RQ
2 changed files with 5 additions and 7 deletions

View file

@ -114,7 +114,7 @@ fn add_sub<C: PhantomConstCpuConfig, SrcCount: KnownSize>(
let x86_cf = wire(); let x86_cf = wire();
#[hdl] #[hdl]
let x86_af = wire(); let x86_af = wire();
connect(x86_af, carries[&4]); connect(x86_af, carries[&4] ^ invert_src0);
#[hdl] #[hdl]
let x86_of = wire(); let x86_of = wire();
#[hdl] #[hdl]
@ -125,7 +125,7 @@ fn add_sub<C: PhantomConstCpuConfig, SrcCount: KnownSize>(
#[hdl] #[hdl]
let x86_zf = wire(); let x86_zf = wire();
let set_x86_flags = |width| { let set_x86_flags = |width| {
connect(x86_cf, carries[&width]); connect(x86_cf, carries[&width] ^ invert_src0);
connect(x86_of, carries[&width].cmp_ne(carries[&(width - 1)])); connect(x86_of, carries[&width].cmp_ne(carries[&(width - 1)]));
connect(x86_sf, sum[width - 1]); connect(x86_sf, sum[width - 1]);
connect(x86_zf, sum[..width].cmp_eq(0u8)); connect(x86_zf, sum[..width].cmp_eq(0u8));

View file

@ -87513,6 +87513,8 @@ b1111111111111111111111111111111111111111111111111111111111110001 Z<_QG
b1111111111111111111111111111111111111111111111111111111111111111 `cG{N" b1111111111111111111111111111111111111111111111111111111111111111 `cG{N"
b1111111111111111111111111111111111111111111111111111100000000001 6-Q>d" b1111111111111111111111111111111111111111111111111111100000000001 6-Q>d"
b1111111111111111111110000000000111111111111111111111100000000001 Z<_QG" b1111111111111111111110000000000111111111111111111111100000000001 Z<_QG"
0t/pUF"
0NCFTu"
1q=,:m" 1q=,:m"
1c)52)" 1c)52)"
0fa7hn" 0fa7hn"
@ -87924,7 +87926,7 @@ b1100000000000 6-Q>d"
0rruTn" 0rruTn"
0<#SlY" 0<#SlY"
b1100000000000 Z<_QG" b1100000000000 Z<_QG"
0t/pUF" 1NCFTu"
0q=,:m" 0q=,:m"
1`(dU(" 1`(dU("
0YQaZZ" 0YQaZZ"
@ -170291,8 +170293,6 @@ b1111111111111111111111111111111111111111111111111111100000110000 LirfL"
1FIp"#" 1FIp"#"
1KUwM{" 1KUwM{"
b1111111111111111111110000011000011111111111111111111100000110000 $ru{a" b1111111111111111111110000011000011111111111111111111100000110000 $ru{a"
1R+kd["
1AvcH="
1oOiyJ" 1oOiyJ"
0e"l`;" 0e"l`;"
1cq($'" 1cq($'"
@ -170466,8 +170466,6 @@ b11111100000000 LirfL"
0FIp"#" 0FIp"#"
0KUwM{" 0KUwM{"
b11111100000000 $ru{a" b11111100000000 $ru{a"
0R+kd["
0AvcH="
0oOiyJ" 0oOiyJ"
0cq($'" 0cq($'"
0cBAjc" 0cBAjc"