Saturday, 19 October 2013

Debugging a masm program


click project->rebuild all->debug program
there are many windows.

  • mnemonic codes
  • registers
  • memory
more windows can be obtained from windows menu
click F8 to trace each step
click F4 to see the output at that time






Helps to write string manipulation programs using MASM 6.14

masm is very easy language if we understand every instruction used in the program and how these instructions executes. most of the instructions are same as intel 8086 microprocessor  instructions other than 8086 instruction set is not a BIG thing. masm helps us to do string operations much easlier than in 8086 kit ( i don't know even they are possible in that kit).
this post is only a try to give my knowledge to readers. just try debugging one program and you fill understand what each instruction performs. even i don't know each and every word in this masm.

lets try to understand the following program
.MODEL SMALL
.STACK
.DATA

MSG1 DB 'ENTER A STRING:$'
MSG2 DB 'REVERSED STRING:$'
CRLF DB 13,10,'$'
ARR DB 100 DUP(?)

PUTS MACRO STR
MOV AH,09H
MOV DX,OFFSET STR
INT 21H
ENDM

.CODE
.STARTUP

PUTS CRLF

PUTS MSG1
MOV ARR,127
MOV AH,0AH
MOV DX,OFFSET ARR
INT 21H
MOV SI,1
MOV AL,ARR[SI]
MOV AH,0
MOV SI,AX
INC SI
PUTS CRLF
PUTS MSG2

PRINT:
MOV DL,ARR[SI]
MOV AH,02
INT 21H
DEC SI
CMP SI,1
JNZ PRINT
.EXIT
END


explanation

.MODEL SMALL                                              
.STACK
.DATA

//defining model and segments

MSG1 DB 'ENTER A STRING:$                                //defining msg1.
MSG2 DB 'REVERSED STRING:$'                             //defining msg2.

//they stores in memory in DS.each string is terminated using a $ sign. its to make understand the compiler that string ended there.

CRLF DB 13,10,'$'               //crlf is a string which contains characters to go next line
ARR DB 100 DUP(?)       // arr is an array of length that initialised to 00 in DS to store words from keyboard

after allocating these strings in memory,
msg1(000E-001D)
MSG2(001E-002E)
CRLF(002F-0031)
ARR(0032-0095)

PUTS MACRO STR                                 //starts a macro. str is a variable
MOV AH,09H                                         //interrupt identification to print a string
MOV DX,OFFSET STR                         //offset address of required string is copied into dx
INT 21H                                                 // interrupted the processor to print the characters.
ENDM                                                      // end a macro

this macro is to print different strings. just like using functions.puts is a function name
int 21h is a interrupt that checks the AH and performs depending upon value of AH.



Saturday, 26 November 2011

Barball download

hey ,this is my simple game created in c++ when i'm studing +2.
system requirements:
windows xp or lower versions
2mb ram
500kb hard disk space

installation will take only 5sec,

everybody should download and install and comment

click here to download

tips to download:
>>click download now
>>click on slow download
>>wait for download link

tips to play:
>>use up&down key to move bar and post
>>press enter to proceed
>>esc key to close game