# Postfix calculator 31 ED # ebp = 0 xor r/m32, r32 31 /r 11 101 101 31 FF # edi = 0 (lenArr) xor r/m32, r32 31 /r 11 111 111 E9 800- # jump WORD jmp rel32 E9 cd 200: # Show # 31 DB # ebx = 0 (index) xor r/m32, r32 31 /r 11 011 011 E9 300- # jump .number jmp rel32 E9 cd 300: # .number # 3B DF # cmp ebx, edi cmp r32, r/m32 3B /r 11 011 111 7C 01 # jump +1 if < jl rel8 7C cb C3 # return ret C3 8B 04 9D B04+ # eax = [4*ebx+Arr] mov r32, r/m32 8B /r 00 000 100 10 011 101 50 # push eax push r32 50+rd S: num 85 C0 # cmp eax, 0 test r/m32, r32 85 /r 11 000 000 0F 8D 400- # jump .space if >= jge rel32 0F 8D cd F7 D8 # eax *= -1 neg r/m32 F7 /3 11 011 000 E9 400- # jump .space jmp rel32 E9 cd 400: # .space # B9 EE00+ # ecx = nbuf-1 mov r32, imm32 B8+rd id C6 01 20 # [ecx] = ' ' mov r/m8, imm8 C6 /0 ib 00 000 001 E9 500- # jump .numeral jmp rel32 E9 cd 500: # .numeral # div r/m32: Unsigned divide EDX:EAX by r/m32 -- EAX=quot EDX=rem 31 D2 # edx = 0 xor r/m32, r32 31 /r 11 010 010 F7 35 B00+ # divide by base div r/m32 F7 /6 00 110 101 8A 92 A00+ # dl = [edx+Ascii] mov r8, r/m8 8A /r 10 010 010 49 88 11 # [--ecx] = dl dec; mov r/m8, r8 88 /r 00 010 001 85 C0 # cmp eax, 0 test r/m32, r32 85 /r 11 000 000 0F 85 500- # jump .numeral if != jne rel32 0F 85 cd # .sign: 58 # pop eax pop r32 58+rd S: 85 C0 # cmp eax, 0 test r/m32, r32 85 /r 11 000 000 0F 8D 600- # jump .write if >= jge rel32 0F 8D cd 49 # ecx-- dec r32 48+rd C6 01 2D # [ecx] = '-' mov r/m8, imm8 C6 /0 ib 00 000 001 E9 600- # jump .write jmp rel32 E9 cd 600: # .write # BA EE01+ # edx = nbuf mov r32, imm32 B8+rd 29 CA # edx -= ecx sub r/m32, r32 29 /r 11 001 010 53 # push ebx push r32 50+rd S: index E8 54- # call PutOut call rel32 E8 cd 0F 8C 7F- # jump Exit+1 if < jl rel32 0F 8C cd 5B # pop ebx pop r32 58+rd S: 43 # ebx++ inc r32 40+rd E9 300- # jump .number jmp rel32 E9 cd A00: 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 46 # numeral to Ascii A30: 0 1 2 3 4 5 6 7 8 9 A41: A B C D E F A61: A B C D E F # Ascii to numeral B00: 10 # base B04: # Arr 800: # WORD # BB 00 00 00 80 # ebx = null (acc) mov r32, imm32 B8+rd id E9 900- # jump CHAR jmp rel32 E9 cd 900: # CHAR # B9 FF00+ # ecx = ibuf mov r32, imm32 B8+rd id BA 00 01 00 00 # edx = count mov r32, imm32 B8+rd id 53 # push ebx push r32 50+rd S: acc E8 67- # call TakeIn call rel32 E8 cd 0F 8C 7F- # jump Exit+1 if < jl rel32 0F 8C cd 0F 8E 7A- # jump Exit if <= jle rel32 0F 8E cd 5B # pop ebx pop r32 58+rd S: 31 C0 # eax = 0 xor r/m32, r32 31 /r 11 000 000 8A 06 # al = [esi] mov r8, r/m8 8A /r 00 000 110 8A 80 C00+ # al = [eax+Char>Act] mov r8, r/m8 8A /r 10 000 000 FF A0 D00+ # jump [eax+Act>Doer] jmp r/m32 FF /4 10 100 000 # C00: Char>Act D00: Act>Doer D00: E00+ # numeral C09: 04 # TAB whSpace C0A: 04 # LF whSpace C20: 04 D04: E20+ # SPACE whSpace C23: 08 D08: E60+ # # C2A: 0C D0C: EC0+ # * C2B: 10 D10: E90+ # + C2D: 14 D14: EA0+ # - C2F: 18 D18: EE0+ # / C68: 1C D1C: F60+ # h C74: 20 D20: F20+ # t C78: 24 D24: F40+ # x C7E: 28 D28: F00+ # ~ E00: # Do numeral 31 C0 # eax = 0 xor r/m32, r32 31 /r 11 000 000 8A 06 # al = [esi] mov r8, r/m8 8A /r 00 000 110 8A 80 A00+ # al = [eax+Ascii] mov r8, r/m8 8A /r 10 000 000 0F AF 1D B00+ # ebx *= base imul r32, r/m32 0F AF /r 00 011 101 01 C3 # ebx += eax add r/m32, r32 01 /r 11 000 011 E9 900- # jump CHAR jmp rel32 E9 cd E20: # Do whSpace 85 DB # cmp ebx, 0 test r/m32, r32 85 /r 11 011 011 0F 8C E40- # jump .show if < jl rel32 0F 8C cd 89 1C BD B04+ # [4*edi+Arr] = ebx mov r/m32, r32 89 /r 00 011 100 10 111 101 47 # edi++ inc r32 40+rd E9 E40- # jump .show jmp rel32 E9 cd E40: # .show: # (if end of line) 80 3E 0A # cmp [esi], '\n' cmp r/m8, imm8 80 /7 ib 00 111 110 0F 85 800- # jump WORD if != jne rel32 0F 85 cd E8 200- # call Show call rel32 E8 cd E9 800- # jump WORD jmp rel32 E9 cd E60: # Do # (drop) 4F # edi-- dec r32 48+rd E9 800- # jump WORD jmp rel32 E9 cd E70: # Pop # y z -- y EBX=z ECX=&y 4F # edi-- dec r32 48+rd 8D 0C BD B04+ # ecx = 4*edi+Arr lea r32, m 8D /r 00 001 100 10 111 101 8B 19 # ebx = [ecx] (=z) mov r32, r/m32 8B /r 00 011 001 83 E9 04 # ecx -= 4 sub r/m32, imm8 83 /5 ib 11 101 001 C3 # return ret C3 E90: # Do + # E8 E70- # call Pop call rel32 E8 cd 01 19 # [ecx] += ebx add r/m32, r32 01 /r 00 011 001 E9 800- # jump WORD jmp rel32 E9 cd EA0: # Do - # E8 E70- # call Pop call rel32 E8 cd 29 19 # [ecx] -= ebx sub r/m32, r32 29 /r 00 011 001 E9 800- # jump WORD jmp rel32 E9 cd EC0: # Do * # E8 E70- # call Pop call rel32 E8 cd 0F AF 19 # ebx *= [ecx] imul r32, r/m32 0F AF /r 00 011 001 89 19 # [ecx] = ebx mov r/m32, r32 89 /r 00 011 001 E9 800- # jump WORD jmp rel32 E9 cd EE0: # Do / # IDIV: Signed divide EDX:EAX by r/m32 -- EAX=quot EDX=rem E8 E70- # call Pop call rel32 E8 cd 8B 01 # eax = [ecx] mov r32, r/m32 8B /r 00 000 001 99 # signExtend EAX to EDX cdq 99 F7 FB # signed div by ebx idiv r/m32 F7 /7 11 111 011 89 01 # [ecx] = eax mov r/m32, r32 89 /r 00 000 001 E9 800- # jump WORD jmp rel32 E9 cd F00: # Do ~ # F7 1C BD B00+ # [4*edi+Arr-4] *= -1 neg r/m32 F7 /3 00 011 100 10 111 101 E9 800- # jump WORD jmp rel32 E9 cd F20: # Do t # C6 05 B00+ 02 # base = 2 (two) mov r/m8, imm8 C6 /0 ib 00 000 101 E9 800- # jump WORD jmp rel32 E9 cd F40: # Do x # C6 05 B00+ 0A # base = A (X Roman) mov r/m8, imm8 C6 /0 ib 00 000 101 E9 800- # jump WORD jmp rel32 E9 cd F60: # Do h # C6 05 B00+ 10 # base = 10 (hexadec.) mov r/m8, imm8 C6 /0 ib 00 000 101 E9 800- # jump WORD jmp rel32 E9 cd