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/013immediate_addressing.cc.html | 103 ++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) (limited to 'html/subx/013immediate_addressing.cc.html') 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