WinAsm Studio, The Assembly IDE - Free Downloads, Source Code
Sponsors
Articles
Programming Quick Start
32-bit Assembler is Easy
Porting Iczelion tutorials
What is FASM
Hard Drive Recovery
Wiring your own LAN
Personal menu
Welcome Guest
User:
Pass:
Register!
Resend Validation Email
 
Forum
 

Getting away with coding murder, have you ever seen code like this?

AvidStudent
Quote Post


Extremely Active Member
******

Group: Members
Posts: 234
Member No.: 17238
Joined: 10-January 09


Example Snip:
CODE
  mov  esi, eax          ; Update source index.
  mov [edi].spEnd, esi    ; Store current source index into destination (end.)
 
  cmp  ecx, dwSliceNumber    ; See if this is the slice requested.
      jne @B              ; if not requested slice, re-enter loop.

  sub  eax, [edi].spBegin    ; Calculate destination (length.)
 
  mov [edi].spLen, eax    ; Store destination (length.)

  .IF eax == 0          ; This is a zero width element
     inc [edi].spLen        ; Zero size would not be useful for allocation of an item
                     ; and may raise an error. EAX is still zero.
                       
     mov [edi].spFlag, ZTSLICEFLAG[ZTSLICE_ZERO_WIDTH]
     
  .endif


This is some code from my ZTSS SDK v 3.2 B current release is 2.0 A. Why do I say "Getting away with coding murder" ? This particular procedure has no local variables, checks for and flags six different errors, contains a loop, calls two different procedures (which both require two parameters) and only uses four registers directly. (if you count eax.)

If you are interested in learning these high level addressing techniques download the ZTSS SDK from the projects source code section here @ WinASM.net laugh.gif If we are going to share source code, we should all write "better" code. No?

P.S. the code pointed to by EDI is a MASM STRUCT. ZTSLICEFLAG is an ENUM.

cheers.gif coder.gif

PMEmail PosterUsers WebsiteYahoo
Top
JimG
Quote Post


Extremely Active Member
******

Group: Moderators
Posts: 725
Member No.: 11
Joined: 16-May 04


I don't see anything unusual about the snippet you posted, other than it's really messy. And it does none of the things you mentioned. ?

CODE
   mov esi,eax          ; Update source index.
   mov [edi].spEnd,esi  ; Store current source index into destination (end.)
   cmp ecx,dwSliceNumber; See if this is the slice requested.
   jne @B               ; if not requested slice, re-enter loop.
   sub eax,[edi].spBegin; Calculate destination (length.)
   mov [edi].spLen, eax ; Store destination (length.)
   .IF eax == 0         ; This is a zero width element
       inc [edi].spLen  ; Zero size would not be useful for allocation of an item
                        ; and may raise an error. EAX is still zero.
       mov [edi].spFlag, ZTSLICEFLAG[ZTSLICE_ZERO_WIDTH]
   .endif
PMEmail Poster
Top
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

Topic Options Reply to this topicStart new topicStart Poll

 

Sponsors
Computer Science

Internet
C/C++
Hardware & PC maintenance

HiEditor

General Discussions
Suggestions/Bug Reports
WinAsm Studio

General Discussions
Suggestions/Bug Reports
WinAsm Studio FAQ
Multilingual User Interface
Add-Ins
Assembly Programming

Main
Newbies
Projects
Custom Controls
Snippets
Announcements & Rules

Announcements

General

Online Degrees - Distance Learning
The Heap
Russian
Google