Commits

insolor  committed 358b6c6

Reformatting and annotation of mach_strlen()

  • Participants
  • Parent commits aa0ad7b
  • Branches call_hook

Comments (0)

Files changed (1)

 
 include disasm.e
 
+constant MAX_LEN = 80 -- ќграничение дл€ аварийного выхода из strlen()
 function mach_strlen(sequence ins)
     return {
         PUSH_REG + ECX, -- push ecx
         -- @@:
         #80, #3c, #08, #00, -- cmp byte [eax+ecx], 0
         #74, #0B, -- jz success
-        #81,#F9,80,#00,#00,#00, -- cmp ecx, N
-        JCC_SHORT+COND_G,#03+length(ins), -- jg skip
+        #81, #F9, MAX_LEN, #00, #00, #00, -- cmp ecx, MAX_LEN
+        JCC_SHORT+COND_G, #03+length(ins), -- jg skip
         INC_REG + ECX, -- inc ecx
         JMP_SHORT, #EF -- jmp @b
         -- success:
-    } & ins
+    } &
+    ins & -- ; some code
     -- skip:
-    & POP_REG+ECX
+    POP_REG+ECX -- pop ecx
 end function
 
 function find_instruction(sequence aft, integer instruct)