Professional Documents
Culture Documents
1)IF ELSE
You can actually use the much loved if else statements in masm.
.IF condition
statement body for executing
.ELSE condition
.REPEAT
statement 1
statement 2
...........
statement n
.UNTIL condition
eg:
.REPEAT
;assuming cl as the count
mov ah,01h
int 21h
sub al,30h
mov dl,al
mov ah,02h
int 21h
dec cl
.UNTIL CL==00
So you always hoped that there was an extra register out there other than al,ah,
bl,bh,cl,ch.. Well we can't make extra registers to hold values.. :(
Declaration is simple
variable_name byte ?
if you want more than 1 byte , u can use word instead of byte
So next time you wanted to keep a back up copy of that register you badly wants
to clear, just copy it to your variable
4) DEBUG
Worst case : You have got an .exe file out there somewhere hidden in your system
. All you now need is the program code..
/***** DEBUG IS pretty cool... We can understand our simple mistakes by debuggin
g... So try it out...
/**** We can see exactly what content of registers are after each instruction.
This way we will never get lost on what we have to do :)
scenario: you need to take two digits and do some operation with that
problem : masm allows you only to take one digit at a time, since the max an al
could hold is 8 bits
Solution : Packing
Now that we have 0d in al, let's unpack it for printing. Remember for printing a
s decimal number we need to unpack this.
;assuming al has 0dh(13)
mov bl,0ah
div bl
;after this statement al has quotient 1 and ah has remainder 3
;so it's just a matter of printing them by moving to dl
6)