please suggest the highlevel control structures in asm

Started by Vineel Kumar Reddy Kovvuri, April 29, 2007, 03:09:15 AM

Previous topic - Next topic

Vineel Kumar Reddy Kovvuri



hi everybody

I am new to assembly , I know programming in C.
Can anyone suggest me some high level controls
like
if , else
and performing some operations like
if(x%3==1) ,if(x/3==4) e.t.c
in pure asm not using the .if or .else syntax please(that is using test,cmp,e.t.c instructions)

it is very helpfull for me if you can provide some source(URL) for know
these type of operations in ASM


thanks to everybody this forum is very nice for people like me
(forgive me for my bad english)



hutch--

vineel,

The pseudo high level constructions in MASM are documented in many places from MASM manuals to various help files. If you have downloaded masm32 the reference is already in the high level help file.


.if
.elseif
.else
.endif


There are also looping instructions if you want to use them but most don't and write loop code themselves manually.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Jimg

After re-reading the question several times, it sounds to me like you want to know how to do high level constructs using only opcodes, not using the high level constructs available in Masm.  The easiest way to see how these work is to assemble the high level code, .if, .repeat, etc.  and look at the output listing.
There are many possible forms of .if, for example-

.if eax
.if uMsg == WM_COMMAND
.If (AL>="0" && AL<="9") || AL=="-" || AL==VK_BACK
.If DWORD PTR [EDI]!='8FIG' || (WORD PTR [EDI+4]!='a7' && WORD PTR [EDI+4]!='a9')
.if Zero?
.if Carry?

most of them turn into simple
cmp a,b
jne @c0001
etc.

just add the option     /Fl  to the ml.exe call to get the output listing in a  .lst  file

Try some out and look at the results.

Feel free to ask any specific questions if you don't understand what you see.

dsouza123

Some low level (opcode) equivalents of high level control structures in asm,
in particular .if .endif using the quotient and remainder results after a div
as part of the comparisons.


.data
   x dd 4

.code
start:
   mov edx, 0
   mov eax, x
   mov ecx, 3
   div ecx
   
   ; .if (x%3 == 1)
   ; .endif
   cmp edx, 1
   jne PastMod
   nop
   nop
PastMod:

   ;.if (x/3 == 4)
   ;.endif
   cmp eax, 4
   jne PastDiv
   nop
   nop
PastDiv:

Vineel Kumar Reddy Kovvuri



thanks to everybody


/Fl with /Sa  switches to ml.exe helped me a lot(excellent for understanding asm semantics )

once again thx