News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Few Questions..

Started by Xycron, December 27, 2012, 11:21:19 AM

Previous topic - Next topic

Xycron

Would someone mind double checking my anwesers for there two? I'm nearly positive the first one is correct, not as sure about the second.

Does a jump occur?
Quote
mov al,255       
cmp al,2;   
jnle xyz 
xyz: ; a label
I put yes. jnle jumps if al is not less than or equal to (greater than)  2, which is is. correct, right?

Next one is:

Quote
mov al,255       
cmp al,2   

begin1:  jnl end1
mov ah, 10
end1:jl  end2
mov ah 20
end2

The above stores ___   in ah.
I believe it enters the first part, and not the second, which means it stores 10 in ah?

jj2007

Quote from: Xycron on December 29, 2012, 09:28:00 PM
Does a jump occur?

Who knows ::)

include \masm32\include\masm32rt.inc

.code
start:
; Does a jump occur?
   mov al,255
   cmp al,2;   
   jnle xyz
   inkey "NO"
   exit
xyz:       ; a label
   inkey "YES"
   exit
   
end start

Seriously: At a certain point you must decide how you want to learn. I suggest that you install the Masm32 package and learn how to use \Masm32\qeditor.exe ... and read the tips & tricks in my signature :icon14:

dedndave

if you
mov al,255
the high bit is set (sign bit in context where signed numbers are used)

JL, JNL, JNLE are used for signed comparison
so, 255 is treated as -1

now see if you can figure it out without executing it   :P

Xycron

Thanks for the help from both of you. I was trying to get both of them to compile to check myself but they wouldn't compile in VS and I wasn't sure why, perhaps THATS what I should have asked about.

i tried adding the include line, and that made the first one compile(although i lost the ability to use the debugger for some reason) but the second one still does not compile.

I'm trying the link in your signature but am having trouble installing the MASM32 SDK... Getting errors when installing about ordinal 200 AcGenral.DLL.  and 202 AcLayers.dll.  not being able to be located. I think it may be a windows 8 issue, but I will google further...

And thanks for the tip on signed numbers and how 255 is really -1. I would have been confused as to why it did not jump.

jj2007

The AcLayers thing is a known issue with Win8, see here.

Using VS for simple Masm examples is an overkill; it may work, of course, but you also may run into setup problems. And it is so incredibly slow.... better try \Masm32\qeditor.exe with the Console assemble & link.

My own editor comes with MasmBasic and sits, after extraction, at \Masm32\RichMasm\RichMasm.exe - it looks very different 8), but among the useful features is that you can open practically all examples in \Masm32\examples, hit F6 and see the result immediately.

Xycron

I seem to finally have the SDK installed and running. I am able to compile the same things i could compile in visualstudio, but the second example posted below (and a few posts above) still does not compile:

mov al,255       
cmp al,2   

begin1:  jnl end1
mov ah, 10
end1:jl  end2
mov ah 20
end2


syntax error : in instruction
syntax error: end2
undefined symbol : end2

I don't really understand what the end2's are doing. Can anyone point me in the right direction for this?

jj2007

If there is a jump to end2, then logically end2 must be a label:

end2:

And don't forget at the end of a program there must be
end start
or
end Main
or whatever the entry point was called.

Magnum

Quote from: Xycron on December 30, 2012, 08:58:38 AM
I seem to finally have the SDK installed and running. I am able to compile the same things i could compile in visualstudio, but the second example posted below (and a few posts above) still does not compile:

mov al,255       
cmp al,2   

begin1:  jnl end1
mov ah, 10
end1:jl  end2
mov ah 20
end2


syntax error : in instruction
syntax error: end2
undefined symbol : end2

I don't really understand what the end2's are doing. Can anyone point me in the right direction for this?

When you have a label, it's a good idea to start your code on the next line.

Where is end1 at ?

Do you mean end2: ?

Another idea is to comment your code in some places.


Take care,
                   Andy

Ubuntu-mate-18.04-desktop-amd64

http://www.goodnewsnetwork.org

Xycron

Quote from: Magnum on December 30, 2012, 09:05:03 AM
Quote from: Xycron on December 30, 2012, 08:58:38 AM
I seem to finally have the SDK installed and running. I am able to compile the same things i could compile in visualstudio, but the second example posted below (and a few posts above) still does not compile:

mov al,255       
cmp al,2   

begin1:  jnl end1
mov ah, 10
end1:jl  end2
mov ah 20
end2


syntax error : in instruction
syntax error: end2
undefined symbol : end2

I don't really understand what the end2's are doing. Can anyone point me in the right direction for this?

When you have a label, it's a good idea to start your code on the next line.

Where is end1 at ?

Do you mean end2: ?

Another idea is to comment your code in some places.

This is code the teacher gave us. I have no idea what he meant, perhaps he gave us code with an error...

Here is my entire code for how I'm trying to compile it...


Quote.486
.MODEL FLAT
.data
.code
main PROC

mov al,255       
cmp al,2   

begin1:  jnl end1
mov ah, 10
end1:jl  end2
mov ah 20
end2

main ENDP

END main

jj2007

Quote from: jj2007 on December 30, 2012, 09:02:56 AM
If there is a jump to end2, then logically end2 must be a label:

end2:

.486
.MODEL FLAT
.data
.code
main PROC

mov al,255       
cmp al,2   

begin1:  jnl end1
mov ah, 10
end1:jl  end2
mov ah, 20   ; <<<<<<<<<<<
end2:   ; <<<<<<<<<<<
ret   ; <<<<<<<<<<<
main ENDP

END main

Gunther

Hi Xycron,

so, you've the answer from Jochen. But please have a look at the forum rules: http://masm32.com/board/index.php?topic=4.0, especially the The NO HOMEWORK Rule.

Gunther
You have to know the facts before you can distort them.