Computer & Interfacing Chapter 3
Computer & Interfacing Chapter 3
DA M B I DO A PY T ER
C oET
DEP A R T M EN T O F EL EC T R IC A L A N D C O M P U T ER
EN G IN EER IN G
M IC R O C O M P U T ER A N D IN T ER F A C IN G
( EC EG 4 1 6 1 )
C H A P T ER T H R EE
Intel8 0 8 6 P R O C ESSO R P R O G R A M IN G & IN ST R U C T IO N SET S
BY MERSIBON M.
DaDU, CoET, Department Of Electrical And Computer Engineering 1
IN T R O DU C T IO N
§ T h e 8 0 8 6 h asabout1 1 7 differentinstructionswith about3 0 0
opcodes.
§ T h e 8 0 8 6 instructionsetscancontainno operand, singl
e operand,
and two operand instructions.
§ T h e 8 0 8 6 instructionsdo notpermitmemory to memory operations
exceptforstringinstructionswh ich invol ve array operations.
§ T h e processorcanaccessmemory indifferentwaysth atare
col lectivel
y cal
led addressingmode.
§ T h e addressingmodesdescribe th e typesofoperandsand th e way
th ey are accessed forexecutinganinstruction.
§ T h e numberofaddressingmodesisdetermined wh enth e
microprocessorisdesigned and cannotbe ch anged.
§ T h e 8 0 8 8 / 8 6 processorsupportsmany datatypes.
ü Datatypescanbe 8 - or1 6 - bit, positive ornegative.
ü A numberl essth an8 bitswide mustbe coded asan8 - bitregister
with th e h igh erdigitsasz ero.
ü A numberisl essth an1 6 bitswide mustuse al
l1 6 bits.
§ O R G isused to indicate th e beginningofth e offsetaddress.
ü T h e numberafterO R G canbe eith erinh exorindecimal .
ü Ifth e numberisnotfol lowed by H , itisdecimaland th e
assemblerwil lconvertitto h ex.
§ DB Define B yte:
ü O ne ofth e mostwidel y used datadirectives, ital l
owsal location
ofmemory inbyte- siz ed ch unks.
ü T h isisth e smal
lestal locationunitpermitted.
ü DB candefine numbersindecimal , binary, h ex, & A SC II.
• D afterth e decimalnumberisoptional .
• B ( binary) and H ( h exadecimal ) isrequired.
• T o indicate A SC II, place th e stringinsingl e quotationmarks.
§ DB isth e only directive th atcanbe used to define A SC II strings
l
argerth antwo ch aracters.
ü Itsh oul d be used foral lA SC II datadefinitions.
§ Som e exam pl
es:
§ L istfil
e for DB exam pl
es
§ DU P dupl
icate:
ü DU P willduplicate agivennumberofch aracters.
ü T wo meth odsoffillingsixmemory l
ocationswith F F H .
§ L istfil
e ofDU P exampl
e:
§ DW Define W ord:
ü DW isused to al
locate memory 2 bytes( one word) atatime:
§ DW Define W ord:
ü L istfil
e forDW exampl
es.
§ EQ U canal
so be used inth e datasegment:
ü L istfil
e forDD exampl
es.
§ DQ define quadword:
ü DQ isused to allocate memory 8 bytes( fourwords) insiz e, to
representany variable upto 6 4 bitswide:
ü L istfil
e forDQ exampl
es.
ü DT canalso be used to al
locate 1 0 - byte integersby usingth e " D"
option:
MAIN ENDP
END MAIN
63
M O R E SA M P L E P R O G R A M S
§ Exam pl e2 : - W rite and runaprogram th ataddsfourwordsofdataand
savesth e resul t. T h e val
ueswil
lbe 2 3 4 DH , 1 DE6 H , 3 B C 7 H , and
5 6 6 A H . U se DEB U G to verify th e sum isD3 6 4 .
§ Sol
ution:
§ PU SH F ; copiesth e contentsofth e fl
agregisterto th e stack.
DaDU, CoET, Department Of Electrical And Computer Engineering 78
DA T A T R A N SF ER IN ST R U C T IO N S( cont. . )
P O P DEST IN A T IO N :
§ T h e PO P instructionisused to perform th e reverse ofaPU SH .
§ C opiesaword from th e stack locationpointed to by th e stack pointer
to adestinationspecified inth e Instruction.
§ T h e stack pointerisused to read 2 bytesofdataand copy th em into
th e locationspecified inth e operand fiel
d.
§ T h e destinationcanbe :
ü A general
- purpose register,
ü A segmentregisterexceptC S and IP
ü A memory l
ocation.
§ T h e datainth e stack isnotch anged.