From c67ca4b92674620f3cae3b9301471e0321a7936c Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sat, 14 Oct 2017 22:53:18 -0700 Subject: 4065 subx: 'compare' Hopefully I've implemented the 'sense' of comparisons right.. --- html/subx/011direct_addressing.cc.html | 45 +++++++++++++ html/subx/012indirect_addressing.cc.html | 80 +++++++++++++++++++++++ html/subx/013immediate_addressing.cc.html | 103 ++++++++++++++++++++++++++++++ 3 files changed, 228 insertions(+) (limited to 'html') diff --git a/html/subx/011direct_addressing.cc.html b/html/subx/011direct_addressing.cc.html index a74072e6..8638ecfe 100644 --- a/html/subx/011direct_addressing.cc.html +++ b/html/subx/011direct_addressing.cc.html @@ -213,6 +213,51 @@ if ('onhashchange' in window) { 148 OF = false; 149 break; 150 } +151 +152 //:: compare +153 +154 :(scenario compare_r32_with_r32_greater) +155 % Reg[0].i = 0x0a0b0c0d; +156 % Reg[3].i = 0x0a0b0c07; +157 # op ModRM SIB displacement immediate +158 39 d8 # compare EBX (reg 3) with EAX (reg 0) +159 +run: compare reg 3 with effective address +160 +run: effective address is reg 0 +161 +run: SF=0; ZF=0; OF=0 +162 +163 :(before "End Single-Byte Opcodes") +164 case 0x39: { // compare r32 with r/m32 +165 uint8_t modrm = next(); +166 uint8_t reg2 = (modrm>>3)&0x7; +167 trace(2, "run") << "compare reg " << NUM(reg2) << " with effective address" << end(); +168 int32_t* arg1 = effective_address(modrm); +169 int32_t arg2 = Reg[reg2].i; +170 int32_t tmp1 = *arg1 - arg2; +171 SF = (tmp1 < 0); +172 ZF = (tmp1 == 0); +173 int64_t tmp2 = *arg1 - arg2; +174 OF = (tmp1 != tmp2); +175 trace(2, "run") << "SF=" << SF << "; ZF=" << ZF << "; OF=" << OF << end(); +176 break; +177 } +178 +179 :(scenario compare_r32_with_r32_lesser) +180 % Reg[0].i = 0x0a0b0c07; +181 % Reg[3].i = 0x0a0b0c0d; +182 # op ModRM SIB displacement immediate +183 39 d8 # compare EBX (reg 3) with EAX (reg 0) +184 +run: compare reg 3 with effective address +185 +run: effective address is reg 0 +186 +run: SF=1; ZF=0; OF=0 +187 +188 :(scenario compare_r32_with_r32_equal) +189 % Reg[0].i = 0x0a0b0c0d; +190 % Reg[3].i = 0x0a0b0c0d; +191 # op ModRM SIB displacement immediate +192 39 d8 # compare EBX (reg 3) with EAX (reg 0) +193 +run: compare reg 3 with effective address +194 +run: effective address is reg 0 +195 +run: SF=0; ZF=1; OF=0 diff --git a/html/subx/012indirect_addressing.cc.html b/html/subx/012indirect_addressing.cc.html index c6b76529..72211ce3 100644 --- a/html/subx/012indirect_addressing.cc.html +++ b/html/subx/012indirect_addressing.cc.html @@ -256,6 +256,86 @@ if ('onhashchange' in window) { 192 +run: 'not' of effective address 193 +run: effective address is mem at address 0x60 (reg 3) 194 +run: storing 0xf0f0ff00 +195 +196 //:: compare +197 +198 :(scenario compare_mem_at_r32_with_r32_greater) +199 % Reg[0].i = 0x60; +200 % SET_WORD_IN_MEM(0x60, 0x0a0b0c0d); +201 % Reg[3].i = 0x0a0b0c07; +202 # op ModRM SIB displacement immediate +203 39 18 # compare EBX (reg 3) with *EAX (reg 0) +204 +run: compare reg 3 with effective address +205 +run: effective address is mem at address 0x60 (reg 0) +206 +run: SF=0; ZF=0; OF=0 +207 +208 :(scenario compare_mem_at_r32_with_r32_lesser) +209 % Reg[0].i = 0x60; +210 % SET_WORD_IN_MEM(0x60, 0x0a0b0c07); +211 % Reg[3].i = 0x0a0b0c0d; +212 # op ModRM SIB displacement immediate +213 39 18 # compare EBX (reg 3) with *EAX (reg 0) +214 +run: compare reg 3 with effective address +215 +run: effective address is mem at address 0x60 (reg 0) +216 +run: SF=1; ZF=0; OF=0 +217 +218 :(scenario compare_mem_at_r32_with_r32_equal) +219 % Reg[0].i = 0x60; +220 % SET_WORD_IN_MEM(0x60, 0x0a0b0c0d); +221 % Reg[3].i = 0x0a0b0c0d; +222 # op ModRM SIB displacement immediate +223 39 18 # compare EBX (reg 3) with *EAX (reg 0) +224 +run: compare reg 3 with effective address +225 +run: effective address is mem at address 0x60 (reg 0) +226 +run: SF=0; ZF=1; OF=0 +227 +228 //: +229 +230 :(scenario compare_r32_with_mem_at_r32_greater) +231 % Reg[0].i = 0x60; +232 % SET_WORD_IN_MEM(0x60, 0x0a0b0c07); +233 % Reg[3].i = 0x0a0b0c0d; +234 # op ModRM SIB displacement immediate +235 3b 18 # compare *EAX (reg 0) with EBX (reg 3) +236 +run: compare effective address with reg 3 +237 +run: effective address is mem at address 0x60 (reg 0) +238 +run: SF=0; ZF=0; OF=0 +239 +240 :(before "End Single-Byte Opcodes") +241 case 0x3b: { // compare r/m32 with r32 +242 uint8_t modrm = next(); +243 uint8_t reg1 = (modrm>>3)&0x7; +244 trace(2, "run") << "compare effective address with reg " << NUM(reg1) << end(); +245 int32_t arg1 = Reg[reg1].i; +246 int32_t* arg2 = effective_address(modrm); +247 int32_t tmp1 = arg1 - *arg2; +248 SF = (tmp1 < 0); +249 ZF = (tmp1 == 0); +250 int64_t tmp2 = arg1 - *arg2; +251 OF = (tmp1 != tmp2); +252 trace(2, "run") << "SF=" << SF << "; ZF=" << ZF << "; OF=" << OF << end(); +253 break; +254 } +255 +256 :(scenario compare_r32_with_mem_at_r32_lesser) +257 % Reg[0].i = 0x60; +258 % SET_WORD_IN_MEM(0x60, 0x0a0b0c0d); +259 % Reg[3].i = 0x0a0b0c07; +260 # op ModRM SIB displacement immediate +261 3b 18 # compare *EAX (reg 0) with EBX (reg 3) +262 +run: compare effective address with reg 3 +263 +run: effective address is mem at address 0x60 (reg 0) +264 +run: SF=1; ZF=0; OF=0 +265 +266 :(scenario compare_r32_with_mem_at_r32_equal) +267 % Reg[0].i = 0x60; +268 % SET_WORD_IN_MEM(0x60, 0x0a0b0c0d); +269 % Reg[3].i = 0x0a0b0c0d; +270 # op ModRM SIB displacement immediate +271 3b 18 # compare *EAX (reg 0) with EBX (reg 3) +272 +run: compare effective address with reg 3 +273 +run: effective address is mem at address 0x60 (reg 0) +274 +run: SF=0; ZF=1; OF=0 diff --git a/html/subx/013immediate_addressing.cc.html b/html/subx/013immediate_addressing.cc.html index 609c32d3..50164e5e 100644 --- a/html/subx/013immediate_addressing.cc.html +++ b/html/subx/013immediate_addressing.cc.html @@ -292,6 +292,109 @@ if ('onhashchange' in window) { 228 BINARY_BITWISE_OP(^, *arg1, arg2); 229 break; 230 } +231 +232 //:: compare +233 +234 :(scenario compare_imm32_with_eax_greater) +235 % Reg[0].i = 0x0d0c0b0a; +236 # op ModRM SIB displacement immediate +237 3d 07 0b 0c 0d # compare 0x0d0c0b07 with EAX (reg 0) +238 +run: compare reg EAX and imm32 0x0d0c0b07 +239 +run: SF=0; ZF=0; OF=0 +240 +241 :(before "End Single-Byte Opcodes") +242 case 0x3d: { // subtract imm32 from EAX +243 int32_t arg1 = Reg[EAX].i; +244 int32_t arg2 = imm32(); +245 trace(2, "run") << "compare reg EAX and imm32 0x" << HEXWORD << arg2 << end(); +246 int32_t tmp1 = arg1 - arg2; +247 SF = (tmp1 < 0); +248 ZF = (tmp1 == 0); +249 int64_t tmp2 = arg1 - arg2; +250 OF = (tmp1 != tmp2); +251 trace(2, "run") << "SF=" << SF << "; ZF=" << ZF << "; OF=" << OF << end(); +252 break; +253 } +254 +255 :(scenario compare_imm32_with_eax_lesser) +256 % Reg[0].i = 0x0d0c0b07; +257 # op ModRM SIB displacement immediate +258 3d 0a 0b 0c 0d # compare 0x0d0c0b0a with EAX (reg 0) +259 +run: compare reg EAX and imm32 0x0d0c0b0a +260 +run: SF=1; ZF=0; OF=0 +261 +262 :(scenario compare_imm32_with_eax_equal) +263 % Reg[0].i = 0x0d0c0b0a; +264 # op ModRM SIB displacement immediate +265 3d 0a 0b 0c 0d # compare 0x0d0c0b0a with EAX (reg 0) +266 +run: compare reg EAX and imm32 0x0d0c0b0a +267 +run: SF=0; ZF=1; OF=0 +268 +269 //: +270 +271 :(scenario compare_imm32_with_r32_greater) +272 % Reg[3].i = 0x0d0c0b0a; +273 # op ModRM SIB displacement immediate +274 81 fb 07 0b 0c 0d # compare 0x0d0c0b07 with EBX (reg 3) +275 +run: combine imm32 0x0d0c0b07 with effective address +276 +run: effective address is reg 3 +277 +run: SF=0; ZF=0; OF=0 +278 +279 :(before "End Op 81 Subops") +280 case 7: { +281 trace(2, "run") << "subop compare" << end(); +282 int32_t tmp1 = *arg1 - arg2; +283 SF = (tmp1 < 0); +284 ZF = (tmp1 == 0); +285 int64_t tmp2 = *arg1 - arg2; +286 OF = (tmp1 != tmp2); +287 trace(2, "run") << "SF=" << SF << "; ZF=" << ZF << "; OF=" << OF << end(); +288 break; +289 } +290 +291 :(scenario compare_imm32_with_r32_lesser) +292 % Reg[3].i = 0x0d0c0b07; +293 # op ModRM SIB displacement immediate +294 81 fb 0a 0b 0c 0d # compare 0x0d0c0b0a with EBX (reg 3) +295 +run: combine imm32 0x0d0c0b0a with effective address +296 +run: effective address is reg 3 +297 +run: SF=1; ZF=0; OF=0 +298 +299 :(scenario compare_imm32_with_r32_equal) +300 % Reg[3].i = 0x0d0c0b0a; +301 # op ModRM SIB displacement immediate +302 81 fb 0a 0b 0c 0d # compare 0x0d0c0b0a with EBX (reg 3) +303 +run: combine imm32 0x0d0c0b0a with effective address +304 +run: effective address is reg 3 +305 +run: SF=0; ZF=1; OF=0 +306 +307 :(scenario compare_imm32_with_mem_at_r32_greater) +308 % Reg[3].i = 0x60; +309 % SET_WORD_IN_MEM(0x60, 0x0d0c0b0a); +310 # op ModRM SIB displacement immediate +311 81 3b 07 0b 0c 0d # compare 0x0d0c0b07 with *EBX (reg 3) +312 +run: combine imm32 0x0d0c0b07 with effective address +313 +run: effective address is mem at address 0x60 (reg 3) +314 +run: SF=0; ZF=0; OF=0 +315 +316 :(scenario compare_imm32_with_mem_at_r32_lesser) +317 % Reg[3].i = 0x60; +318 % SET_WORD_IN_MEM(0x60, 0x0d0c0b07); +319 # op ModRM SIB displacement immediate +320 81 3b 0a 0b 0c 0d # compare 0x0d0c0b0a with *EBX (reg 3) +321 +run: combine imm32 0x0d0c0b0a with effective address +322 +run: effective address is mem at address 0x60 (reg 3) +323 +run: SF=1; ZF=0; OF=0 +324 +325 :(scenario compare_imm32_with_mem_at_r32_equal) +326 % Reg[3].i = 0x0d0c0b0a; +327 % Reg[3].i = 0x60; +328 % SET_WORD_IN_MEM(0x60, 0x0d0c0b0a); +329 # op ModRM SIB displacement immediate +330 81 3b 0a 0b 0c 0d # compare 0x0d0c0b0a with *EBX (reg 3) +331 +run: combine imm32 0x0d0c0b0a with effective address +332 +run: effective address is mem at address 0x60 (reg 3) +333 +run: SF=0; ZF=1; OF=0 -- cgit 1.4.1-2-gfad0