This lecture was delivered by Mr. Gurpreet Verma at Cochin University of Science and Technology for Assembly Language Programming course. It includes: Debug, Execution, Commands, Statement, Exceed, Mnemonic, Label, Assembler, Files, BIOS, Interrupt
Download Debug-Assembly Language Programming-Lecture Slides and more Slides Assembly Language Programming in PDF only on Docsity!
Debug^ ^ A program included with DOS that allowsa programmer to monitor the execution ofa program for debugging purposes.^ ^ Using Debug:^ ^ Enter Debug^ A:>DEBUG-^ ^ Exit Debug^ -QA:>
Debug ^ Displaying registers^ -RAX=0000 BX=0000 CX=0000 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000DS=0D00 ES=0D00 SS=0D00 CS=0D00 IP=0100 NV UP DI PL NZ NA PO NC0D00:0100 B
Debug^ ^ Unassemble command - allows theprogrammer to display the machine codein memory along with their assemblylanguage instructions.^ -U 100 L10B3C:0100 B80100 MOVAX,1-U 100 1030B3C:0100 B80100 MOVAX,10B3C:0103 BB0200 MOVBX,2-
Debug Go command – allows the programmerto execute instructions found betweentwo given addresses.-G=100 108AX=0004 BX=0003 CX=0000 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000DS=0B3C ES=0B3C SS=0B3C CS=0B3C IP=0108 NV UP EI PL NZ NA PO NC0B3C:0108 CC INT
Debug ^ Loading programs from a specific filerequires two commands, the Namecommand, N, and the Loadcommand, L. -N A:\PROG1.EXE-L ^ Loading programs upon enteringDebug. C:\DEBUG A:\PROG1.EXE
Assembly LanguageProgram ^ Series of statements which are eitherassembly language instructions ordirectives.^ ^ Instructions are statements like ADDAX,BX which are translated intomachine code.^ ^ Directives or pseudo-instructions arestatements used by the programmer todirect the assembler on how to proceedin the assembly process.
Assembly LanguageProgram ^ Statement format:^ ^ [label:] mnemonic [operands][;comments] ^ Label:^ ^ Cannot exceed 31 characters.^ ^ Consists:^ ^ Alphabetic characters both upper and lowercase.^ ^ Digits 0 through 9.^ ^ Special characters (? ), (. ), ( @ ), ( _ ), and ($ ).^ ^ The first character cannot be a digit.^ ^ The period can only be used as the firstcharacter, but its use is notrecommended Several reserved words
Assembly LanguageProgram ^ Comments:^ ^ Begin with a “;”.^ ^ Ignored by the assembler.^ ^ Maybe be on a line by itself or at the endof a line:^ ^ ;My first comment^ ^ MOV AX,1234H ;Initializing….^ ^ Indispensable to the programmersbecause they make it easier forsomeone to read and understand theprogram.
Segment Definition ^ The CPU has several segment registers:^ ^ CS (code segment).^ ^ SS (stack segment).^ ^ DS (data segment).^ ^ ES (extra segment).^ ^ FS, GS (supplemental segments available on386s, 486s and Pentiums. ^ Every instruction and directive mustcorrespond to a segment. ^ Normally a program consists of threesegments: the stack, the data, and thecode segments.
Segment Definition ^ .MODEL LARGE^ ^ Both code and data can exceed 64k.^ ^ No single set of data can exceed 64k. ^ .MODEL HUGE^ ^ Both code and data can exceed 64k.^ ^ A single set of data can exceed 64k. ^ .MODEL TINY^ ^ Used with COM files.^ ^ Both code and data must fir in a single64k segment.
Segment Definition ^ Segment definition formats:^ ^ Simplified segment definition.^ ^ Full segment definition. ^ The Simplified segment definitionuses the following directives todefine the segments:^ ^ .STACK^ ^ .DATA^ ^ .CODE^ ^ These directives mark the beginning ofthe segments they represent.
Segment Definition ; S I M P L I F I E D^ S E G M^ E N^ T^ D E F I N
I T I O^ N^ ; F U^ L L^ S E G M^ E N T
D E F I N^ I T I O N
. M^ O D E L^ S M^ A^ L L. S T A C K^ 6 4^
S T S E G^ S E G M^ E N TD B^ 6 4^ D U P (? )S T S E G^ E N D S
. D A T A^
D T S E G^ S E G M^ E N T
N 1^ D W^ 1 4 3 2 H^
N 1^ D W^ 1 4 3 2 H
N 2^ D W^ 4 3 6 5 H^
N 2^ D W^ 4 3 6 5 H
S U M^ D W^ 0 H^
S U M^ D W^ 0 HD T S E G^ E N D S
. C O D E^
C D S E G^ S E G M^ E N T
B E G^ I N^ P R O C^ F A R
B E G^ I N^
P R O C^ F A RA S S U M^ E^ C S : C D S E G , D S : D T S E G , S S : S T S E G
M^ O V^ A X , @^ D A T A^
M^ O V^ A X , D T S E G
M^ O V^ D S , A X^
M^ O V^ D S , A X
M^ O V^ A X , N 1^
M^ O V A X , N 1
A D D^ A X , N 2^
A D D^ A X , N 2
M^ O V^ S U M^ , A X^
M^ O V^ S U M^ , A X
M^ O V^ A H , 4 C H^
M^ O V^ A H , 4 C H
I N^ T^ 2 1 H^
I N^ T^ 2 1 H
B E G^ I N^ E N D P^
B E G^ I N^ E N D P
E N D^ B E G^ I N^
C D S E G^ E N D SE N D^ B E G^
I N
Program Termination ^ With PC:^ ^ MOV AH,4CHINT 21H^ ^ Always return control to the OS.