E-mail: xq_xiu@yahoo.com.cn - PowerPoint PPT Presentation

1 / 22
About This Presentation
Title:

E-mail: xq_xiu@yahoo.com.cn

Description:

Title: Author: X.Q.Xiu Last modified by: sxx Created Date: 2/24/2006 2:30:45 PM Document presentation format: Company: bnu – PowerPoint PPT presentation

Number of Views:162
Avg rating:3.0/5.0
Slides: 23
Provided by: XQX
Category:
Tags: com | mail | xqxiu | yahoo

less

Transcript and Presenter's Notes

Title: E-mail: xq_xiu@yahoo.com.cn


1
????
  • ???????????????

??? ???????????? E-mail xq_xiu_at_yahoo.com.cn
2
  • ?5? ??

3
????
  • ??(stack)??????????(LIFO structure, last-in,
    first-out),????????????????????
  • ?????????????????????????,???????????????

4
  • ????(runtime stack)??CPU?????????,????????????????
    ???????
  • ??????CPU?????????,????????SS?ESP???????,SS??????
    ?????,???????????????ESP???????????????????32?????
  • ??????????ESP??,??,ESP?????????CALL,RET,PUSH?POP??
    ???????

NASM???????PUSH??????????,?EAX?
5
  • ?????????

6
  • ??????????????
  • ?????????????,???????????????,??????????,????????
  • CALL???????,CPU???????????????
  • ???????,???????????(??)?
  • ???????????????,?????,????????

7
  • PUSH?POP??
  • PUSH??????ESP??,?????16??32???????????????16????,E
    SP???2??32????,ESP???4?PUSH?????????
  • ???????????32??????????,?????.386(???)??????,?????
    ??16???
  • POP?????ESP??????????16??32????????,????ESP???????
    ??16??,ESP???2??????32??,ESP???4??????

PUSH r/m16 PUSH r/m32 PUSH imm32
POP r/m16 POP r/m32
8
  • PUSHFD,PUSHF,POPFD?POPF??
  • PUSHFD????????32??EFLAGS?????,POPFD??????????????E
    FLAGS???
  • ?????????PUSHF????????16??FLAGS?????,??POPF???????
    ??16?????FLAGS???

PUSHFD POPFD
PUSHF POPF
9
  • PUSHAD,PUSHA,POPAD?POPA??
  • PUSHAD????????????????32??????EAX,ECX,EDX,EBX,ESP
    ????,EBP,ESI?EDIPOPAD??????????????????????
  • ????,80286??????PUSHA?????????????16????(AX,CX,DX,
    BX,SP????,BP,SI?DI)POPA????????????????
  • ???????RevStr.asm?

10
????????
  • PROC???
  • ????PROC?ENDP??????,?????????????(????????)???????
    ??????????????RET??,???CPU????????????
  • ????????
  • ???????????????????EAX,EBX?ECX?????,????EAX??????
    ?

SumOf PROC add eax,ebx add eax,ecx ret SumOf
ENDP
11
  • CALL?RET??
  • CALL??????????????????,????????????????RET(return
    from procedure)????????????????????????
  • ?????????,CALL???????????????????????????????????
    ???,RET??????????????????????CPU???????????EIP(?16
    ?????IP)?????????????
  • ????????

SumOf PROC 00000040 add eax,ebx add
eax,ecx ret SumOf ENDP
main PROC 00000020 call SumOf 00000025 mov
ebx,eax
ESP
EIP
ESP
EIP
00000025
00000040
00000025
00000025
12
  • ?????????
  • ?????,????(???????)??????,???????????????,????????
    ???????????????????????,????????????????????,?????
    ?????????????,?????????????

main PROC jmp L2 ??! L1 ???? exit main
ENDP sub PROC L2 ???? jmp L1 ?? ret sub
ENDP
13
  • ??????????
  • ???????????????????????,??????????????????????????
    ???????,???????????????
  • ??????????????????,??????????????????????????(argu
    ments)?????(input arguments)???????,??????????????
  • ??

.data theSum DWORD ? .code main PROC mov
eax,10000h ?? mov ebx,20000h ?? mov
ecx,30000h ?? call SumOf EAX(EAXEBXECX) mo
v theSum,eax ??? exit ?????? main ENDP
14
  • ?????????

-------------------------------------------------
---- ArraySum PROC Calculates the sum of an
array of 32-bit integers. Receives ESI points
to the array, ECX array size Returns EAX
sum of the array elements -----------------------
------------------------------ push
esi ??ESI?ECX?? push ecx mov
eax,0 ?????0 L1 add eax,esi ???????? add
esi,4 ??????? loop L1 ?? pop
ecx ??ECX?ESI?? pop esi ret ??EAX???? Arra
ySum ENDP
??ArraySum
.data Array DWORD 0000h,20000h,30000h,40000h theSu
m DWORD .code main PROC mov esi,OFFSET
array mov ecx,LENGTHOF array call ArraySum mov
theSum,eax exit main ENDP
15
  • ????????
  • ArraySum??????ECX?ESI?????,???????????,???????????
    ???????????????????????????????,??????????????????
    ?
  • ?PROC????????USES??????????????????,????????????,
    ?????????PUSH??????????????,?????????POP?????????
    ??USES??????PROC???,??????????(????)?????????
  • ???????????????????,???????????????????,?????????
    ?????

16
  • USES?????

ArraySum PROC USES esi ecx mov
eax,0 L1 add eax,esi add esi,4 loop
L1 ret ArraySum ENDP
ArraySum PROC push esi push ecx mov
eax,0 L1 add eax,esi add esi,4 loop
L1 L2 pop ecx pop esi ret ArraySum ENDP
17
??????
  • ???(link library)?????????????????????????????????
    ????????????,???????????????
  • ?????????WriteString?????????????,???????????PROTO
    ?????????????Irvine32.inc??????????
  • WriteString PROTO
  • ???,???CALL????WriteString??
  • call WriteString
  • ?????????,????CALL???????????,????????????????????
    ??WriteString????,????????????????????????,??Write
    String??????CALL????

18
  • Irvine32.lib?????????
  • Irvine32.inc
  • Irvine32.asm

19
??????????
  • ??????????????????????????????????????????????,???
    ???????????,???????????????????????????????????,??
    ???????
  • ??????,??????????????????????????,????????????????
    ?????????,???????????
  • ????????????????????????,?????????????????????????
    ??????????(functional decomposition),????????(up-d
    own design)?

20
  • ????????????????
  • ?????????????
  • ???????????????,?????????
  • ??????????????????????
  • ??????????,?????????????????????????

21
  • ??????(??)
  • ????????????????32???,????????,????????????????

22
?????
  • ??Irvine32.asm????,????3???,?????????,????????????
    ???3?????
Write a Comment
User Comments (0)
About PowerShow.com