一、实验目的:
1.掌握基于特定操作系统中调用API或者SYSTEMCALL的基本方法。
2.进一步理解高级语言中函数调用的相关规定和约定(stdcall,cdec,fastcall等)
3.IA-32架构下API参数在汇编中的实现方式和约定。
二、实验内容
1.在课程设定的VS2022社区版的汇编开发环境下,完成以下C语言代码的汇编语言改写
#include "stdafx.h"
#include <windows.h>
HANDLE hStdout, hStdin;
int main(void)
{
LPSTR lpszPrompt1 = "Type a line and press Enter, or q to quit: ";
CHAR chBuffer[256];
DWORD cRead, cWritten;
// Get handles to STDIN and STDOUT.
hStdin = GetStdHandle(STD_INPUT_HANDLE);
hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
if (hStdin == INVALID_HANDLE_VALUE ||
hStdout == INVALID_HANDLE_VALUE)
{
return 1;
}
// Write to STDOUT and read from STDIN by using the default
// modes. Input is echoed automatically, and ReadFile
// does not return until a carriage return is typed.
//
// The default input modes are line, processed, and echo.
// The default output modes are processed and wrap at EOL.
while (1)
{
if (!WriteFile(
hStdout, // output handle
lpszPrompt1, // prompt string
lstrlenA(lpszPrompt1), // string length
&cWritten, // bytes written
NULL)) // not overlapped
{
return 1;
}


803

被折叠的 条评论
为什么被折叠?



