.386.model flat,stdcall.stack 4096
ExitProcess PROTO,dwExitCode:DWORD.data
wordArray WORD 0500h,0400h,0300h,0200h,0100h.code
main PROCmov ax,0100hmov edi,OFFSET wordArraymov ecx,LENGTHOF wordArraycld repne scaswjne L1sub edi,TYPE wordArraymov eax,edijmp quit
L1:mov eax,0
quit:INVOKE ExitProcess,0
main ENDP
END main
2: STRUCT : 偽指令STRUCT 結構的使用
.386.model flat,stdcall.stack 4096
ExitProcess PROTO,dwExitCode:DWORD.data
;定義結構
COORD STRUCTX WORD ?Y WORD ?
COORD ENDS
Employee STRUCTIdNum BYTE "000000000";9字節LastName BYTE 30DUP(0);30字節ALIGN WORD ;加1個字節Years WORD 0;2ALIGN DWORD ;加2個字節SalaryHistory DWORD 0,0,0,0;16字節
Employee ENDS ;共60point1 COORD <5,10>;x=5,y=10
point2 COORD <20>;x=20,y=?
point3 COORD <>;x=?,y=?
worker Employee<>;默認初始值
person1 Employee<"555223333">;IdNum初始值,其他默認
person2 Employee <,,,2DUP(20000)>;只初始化SalaryHistory前兩個值,剩下兩個0;對齊結構變量
ALIGN DWORD ;要與結構中最大結構成員對齊
person Employee <>;結構數組
AllPoints COORD 3DUP(<0,0>);3個結構的X,Y都為0department Employee 5DUP(<>).code
main PROCmov eax,TYPE Employee ;60mov eax,SIZEOF Employee;60mov eax,SIZEOF worker ;60;引用成員mov dx,worker.Yearsmov worker.SalaryHistory,20000;第一個工資mov [worker.SalaryHistory+4],3000;第二個工資mov worker.SalaryHistory+4,4000;第二個工資mov edx,OFFSET worker.SalaryHistory ;得到字段的地址;間接尋址操作數mov esi,OFFSET workermov ax,(Employee PTR[esi]).Years;變址操作數可以訪問結構數組mov esi,TYPE Employee ;索引 =1mov department[esi].Years ,4INVOKE ExitProcess,0
main ENDP
END main
3:STRUCT_ALLPOINTS : 變址尋址操作數遍歷結構數組
include Irvine32.incNumPoints =3.data
ALIGN WORD
AllPoints COORD NumPoints DUP(<0,0>).code
main PROCmov edi,0;數組索引mov ecx,NumPointsmov ax,1;起始X,Y的值
L1:mov (COORD PTR AllPoints[edi]).X,axmov AllPoints[edi].Y,axadd edi,TYPE COORDinc axloop L1exit
main ENDP
END main
include Irvine32.incEmployeeBad STRUCTIdNum BYTE "000000000"LastName BYTE 30DUP(0)Years WORD 0SalaryHistory DWORD 0,0,0,0
EmployeeBad ENDSEmployee STRUCTIdNum BYTE "000000000"LastName BYTE 30DUP(0)ALIGN WORDYears WORD 0ALIGN DWORDSalaryHistory DWORD 0,0,0,0
Employee ENDS.data
ALIGN DWORD
startTime DWORD ?
emp Employee <>;或:EmployeeBad
.code
main PROCcall GetMSecondsmov startTime,eaxmov ecx,0FFFFFFFFh
L1:mov emp.Years,5mov emp.SalaryHistory,35000loop L1call GetMSecondssub eax,startTimecall WriteDecexit
main ENDP
END main
5: SYSTEMTIME : 使用結構獲取系統時間函數
include Irvine32.incCOMMENT %
COORD STRUCTX WORD ?Y WORD ?
COORD ENDS SYSTEMTIME STRUCTwYear WORD ?wMonth WORD ?wDayOfWeek WORD ?wDay WORD ?wHour WORD ?wMinute WORD ?wSecond WORD ?wMilliseconds WORD ?
SYSTEMTIME ENDS
%.data
sysTime SYSTEMTIME <>.code
main PROCINVOKE GetLocalTime ,ADDR sysTimemovzx eax,sysTime.wYearcall WriteDecexit
main ENDP
END main
6:結構內包括結構的使用
.386.model flat,stdcall.stack 4096
ExitProcess PROTO,dwExitCode:DWORDCOORD STRUCTX WORD ?Y WORD ?
COORD ENDS
Rectangle STRUCTUpperLeft COORD <>LowerRight COORD <>
Rectangle ENDS
.data
rect1 Rectangle <>
rect2 Rectangle {}
rect3 Rectangle {{10,10},{50,20}}
rect4 Rectangle <<10,10>,<50,20>>.code
main PROCmov rect1.UpperLeft.X ,10mov esi,OFFSET rect1mov (Rectangle PTR [esi]).UpperLeft.Y,10mov edi,OFFSET rect2.LowerRightmov (COORD PTR [edi]).X,50mov edi,OFFSET rect2.LowerRight.Xmov WORD PTR[edi],50INVOKE ExitProcess,0
main ENDP
END main
mcq 隊列Q1. What do you call the technique of storing encrypted user passwords in Linux? Q1。 您如何稱呼在Linux中存儲加密的用戶密碼的技術? System Password Management 系統密碼管理 Shadow Password 影子密碼 Encrypted Password 加密密碼 None of the…
kotlin 判斷數字Given a number N, we have to check whether it is EVEN or ODD. 給定數字N ,我們必須檢查它是偶數還是奇數 。 Example: 例: Input:N 13Output:"ODD"Input:N 24Output:"EVEN"程序在Kotlin檢查偶數或奇數 (Prog…
線性代數 向量長度Prerequisite: Defining a vector 先決條件: 定義向量 Linear algebra is the branch of mathematics concerning linear equations by using vector spaces and through matrices. In other words, a vector is a matrix in n-dimensional space…