{"title":"使用通用 Lisp 语言的元编程工具开发仿真器系统","authors":"А. А. Chaplygin","doi":"10.21869/2223-1536-2023-13-3-135-145","DOIUrl":null,"url":null,"abstract":"The purpose of research is to analyze and use metaprogramming in the Common Lisp language when designing and implementing emulators that simulate computer system hardware. The metaprogramming, the macro tools of the Common Lisp language and the use of macros for metaprogramming are considered.Methods. The Lisp language is characterized by its use of uniform S-expressions to represent data and programs. Thus, data can be part of a program and vice versa: a program can be data. Common Lisp macro tools allow you to directly modify the abstract syntax tree of a program, and thus it is possible to create new syntactic constructs to solve a given problem. When implementing emulator functions, macro tools of the Common Lisp language can be used to generate functions, where the common part of the functions is included in the macro, and the differences between the functions are specified in the parameters when calling the macros. Examples of this macros are: bit status register macros, generation of ariphmetic commands, comparation commands, memory commands. Using that you can significantly reduce the size of the program.Results. As a result of computer modeling, a simulator of the NES architecture (MOS 6502 processor) was developed and implemented in the conventional object-orientied C# programming language and in the Common Lisp metaprogramming language. As a result, the simulator written in a language with metaprogramming support turned out to be more than 2 times smaller than the simulator written in C#.Conclusion. The use of metaprogramming (using the example of creating emulators) can significantly reduce the size of a program, simplify and improve the program architecture, reduce the number of errors and improve the quality of programs. The use of domain specific languages lets reduce code size even more.","PeriodicalId":166124,"journal":{"name":"Proceedings of the Southwest State University. Series: IT Management, Computer Science, Computer Engineering. Medical Equipment Engineering","volume":"3 2","pages":""},"PeriodicalIF":0.0000,"publicationDate":"2024-01-27","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"0","resultStr":"{\"title\":\"Using Metaprogramming Tools of the Common Lisp Language for the Development of Emulator Systems\",\"authors\":\"А. А. Chaplygin\",\"doi\":\"10.21869/2223-1536-2023-13-3-135-145\",\"DOIUrl\":null,\"url\":null,\"abstract\":\"The purpose of research is to analyze and use metaprogramming in the Common Lisp language when designing and implementing emulators that simulate computer system hardware. The metaprogramming, the macro tools of the Common Lisp language and the use of macros for metaprogramming are considered.Methods. The Lisp language is characterized by its use of uniform S-expressions to represent data and programs. Thus, data can be part of a program and vice versa: a program can be data. Common Lisp macro tools allow you to directly modify the abstract syntax tree of a program, and thus it is possible to create new syntactic constructs to solve a given problem. When implementing emulator functions, macro tools of the Common Lisp language can be used to generate functions, where the common part of the functions is included in the macro, and the differences between the functions are specified in the parameters when calling the macros. Examples of this macros are: bit status register macros, generation of ariphmetic commands, comparation commands, memory commands. Using that you can significantly reduce the size of the program.Results. As a result of computer modeling, a simulator of the NES architecture (MOS 6502 processor) was developed and implemented in the conventional object-orientied C# programming language and in the Common Lisp metaprogramming language. As a result, the simulator written in a language with metaprogramming support turned out to be more than 2 times smaller than the simulator written in C#.Conclusion. The use of metaprogramming (using the example of creating emulators) can significantly reduce the size of a program, simplify and improve the program architecture, reduce the number of errors and improve the quality of programs. The use of domain specific languages lets reduce code size even more.\",\"PeriodicalId\":166124,\"journal\":{\"name\":\"Proceedings of the Southwest State University. Series: IT Management, Computer Science, Computer Engineering. Medical Equipment Engineering\",\"volume\":\"3 2\",\"pages\":\"\"},\"PeriodicalIF\":0.0000,\"publicationDate\":\"2024-01-27\",\"publicationTypes\":\"Journal Article\",\"fieldsOfStudy\":null,\"isOpenAccess\":false,\"openAccessPdf\":\"\",\"citationCount\":\"0\",\"resultStr\":null,\"platform\":\"Semanticscholar\",\"paperid\":null,\"PeriodicalName\":\"Proceedings of the Southwest State University. Series: IT Management, Computer Science, Computer Engineering. Medical Equipment Engineering\",\"FirstCategoryId\":\"1085\",\"ListUrlMain\":\"https://doi.org/10.21869/2223-1536-2023-13-3-135-145\",\"RegionNum\":0,\"RegionCategory\":null,\"ArticlePicture\":[],\"TitleCN\":null,\"AbstractTextCN\":null,\"PMCID\":null,\"EPubDate\":\"\",\"PubModel\":\"\",\"JCR\":\"\",\"JCRName\":\"\",\"Score\":null,\"Total\":0}","platform":"Semanticscholar","paperid":null,"PeriodicalName":"Proceedings of the Southwest State University. Series: IT Management, Computer Science, Computer Engineering. Medical Equipment Engineering","FirstCategoryId":"1085","ListUrlMain":"https://doi.org/10.21869/2223-1536-2023-13-3-135-145","RegionNum":0,"RegionCategory":null,"ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"","JCRName":"","Score":null,"Total":0}
引用次数: 0
摘要
研究目的是在设计和实施模拟计算机系统硬件的仿真器时,分析和使用 Common Lisp 语言中的元编程。研究考虑了元编程、Common Lisp 语言的宏工具以及宏在元编程中的使用。Lisp 语言的特点是使用统一的 S 表达式来表示数据和程序。因此,数据可以是程序的一部分,反之亦然:程序可以是数据。常用的 Lisp 宏工具可以直接修改程序的抽象语法树,因此可以创建新的语法结构来解决给定的问题。在实现仿真器函数时,可以使用 Common Lisp 语言的宏工具来生成函数,函数的共同部分包含在宏中,函数之间的差异则在调用宏时在参数中指定。这种宏的例子有:位状态寄存器宏、生成非线性命令、比较命令和内存命令。使用这些宏可以大大减少程序的大小。作为计算机建模的结果,开发了一个 NES 架构(MOS 6502 处理器)模拟器,并用传统的面向对象的 C# 编程语言和 Common Lisp 元编程语言实现了该模拟器。结果,用支持元编程的语言编写的模拟器比用 C# 语言编写的模拟器小 2 倍多。使用元编程(以创建模拟器为例)可以大大缩小程序的规模,简化和改进程序结构,减少错误数量,提高程序质量。使用特定领域语言可以进一步减少代码量。
Using Metaprogramming Tools of the Common Lisp Language for the Development of Emulator Systems
The purpose of research is to analyze and use metaprogramming in the Common Lisp language when designing and implementing emulators that simulate computer system hardware. The metaprogramming, the macro tools of the Common Lisp language and the use of macros for metaprogramming are considered.Methods. The Lisp language is characterized by its use of uniform S-expressions to represent data and programs. Thus, data can be part of a program and vice versa: a program can be data. Common Lisp macro tools allow you to directly modify the abstract syntax tree of a program, and thus it is possible to create new syntactic constructs to solve a given problem. When implementing emulator functions, macro tools of the Common Lisp language can be used to generate functions, where the common part of the functions is included in the macro, and the differences between the functions are specified in the parameters when calling the macros. Examples of this macros are: bit status register macros, generation of ariphmetic commands, comparation commands, memory commands. Using that you can significantly reduce the size of the program.Results. As a result of computer modeling, a simulator of the NES architecture (MOS 6502 processor) was developed and implemented in the conventional object-orientied C# programming language and in the Common Lisp metaprogramming language. As a result, the simulator written in a language with metaprogramming support turned out to be more than 2 times smaller than the simulator written in C#.Conclusion. The use of metaprogramming (using the example of creating emulators) can significantly reduce the size of a program, simplify and improve the program architecture, reduce the number of errors and improve the quality of programs. The use of domain specific languages lets reduce code size even more.