TINY.ASM:http 提交

  • w4_645859
    了解作者
  • 27.2KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-04-15 04:27
    上传日期
小ASM 我对提交: Tiny 是一种非常简单的虚构计算机架构,由具有 16 个助记符和 37 个唯一操作码的汇编语言编程。 该系统基于哈佛架构,非常简单:程序内存与工作内存不同,机器一次只执行一条指令,内存是从索引0到索引255(含)的字节数组,以及没有任何相对寻址模式。 您的目标是为 Tiny 编写一个汇编程序:虽然您不需要模拟代码或机器组件,但您必须使用给定的汇编语言源代码并生成一个十六进制操作码列表。 您实际上是在编写将最低级的人类可读语言转换为机器可读语言的代码! 用法 将 .asm 文件转换为官方语法(参见) : python assembler.py --pp-only <filename> 将 .asm 文件解析为十六进制代码: python assembler.py <filename> 在虚拟机中运行一个 .asm 文件: python virtualmach
TINY_ASM-master.zip
  • TINY.ASM-master
  • lib
  • math
  • divide.asm
    593B
  • multiply.asm
    676B
  • binary
  • shift.asm
    2.5KB
  • preprocessor
  • imports.py
    1.6KB
  • comments.py
    651B
  • labels.py
    1.9KB
  • subroutine.py
    4.2KB
  • __init__.py
    1.3KB
  • chars.py
    1.2KB
  • constants.py
    2.3KB
  • test
  • test_assembler.py
    6.5KB
  • test_lib_binary.py
    1KB
  • test_vm.py
    596B
  • __init__.py
    22B
  • test_lib_math.py
    1.3KB
  • prototypes
  • float_math.cpp
    5.5KB
  • float_convert2float.cpp
    2.8KB
  • float_convert2int.cpp
    1.3KB
  • float_print.cpp
    3.7KB
  • math_divide.cpp
    731B
  • math_multiply.cpp
    550B
  • config.py
    383B
  • helpers.py
    2KB
  • opcodes.py
    7.4KB
  • assembler.py
    3.7KB
  • pi.asm
    3.3KB
  • vm.bat
    38B
  • README.md
    3.4KB
  • virtualmachine.py
    8KB
  • .gitignore
    328B
内容介绍
# TINY.ASM My submission for http://redd.it/1kqxz9: > Tiny, a very simple fictional computer architecture, is programmed by an assembly language that has 16 mnemonics, with 37 unique op-codes. The system is based on Harvard architecture, and is very straight-forward: program memory is different from working memory, the machine only executes one instruction at a time, memory is an array of bytes from index 0 to index 255 (inclusive), and doesn't have any relative addressing modes. > Your goal will be to write an assembler for Tiny: though you don't need to simulate the code or machine components, you must take given assembly-language source code and produce a list of hex op-codes. You are essentially writing code that converts the lowest human-readable language to machine-readable language! ## Usage - **Convert an .asm file to the official syntax (see [here](http://redd.it/1kqxz9))**: `python assembler.py --pp-only <filename>` - **Parse an .asm file to hex code**: `python assembler.py <filename>` - **Run an .asm file in the virtual machine**: `python virtualmachine.py <filename>` ## About `pi.asm` `pi.asm` computes the value of π using a stochastic algorithm: > Another Monte Carlo method for computing π is to draw a circle inscribed in a square, and randomly place dots in the square. The ratio of dots inside the circle to the total number of dots will approximately equal π/4. <small>From [Wikipedia](http://en.wikipedia.org/wiki/Pi#Geometry_and_trigonometry)</small> Because of the random values and the word size of 8 bit, the result will have a very low precision and vary between runs. In addition, due to the lack of float point arithmetics, `pi.asm` will only output the equation to get π (e.g. `78/100*4`). ~~I'm still working on implementing 16bit float point arithmetics for Tiny, so `pi.asm` might output the actual result.~~ I wanted to implement 16bit float point arithmetics for Tiny, but the 8 bit word size limits me in the programm size as the return address would start overflowing. ## Syntax Additions **Comments** ; This is a comment **Labels** label: JMP :label **Constants** $mem_addr = [0] $some_const = 5 MOV $mem_addr $some_const **Imports** #import file_name.asm **Char Constants** APRINT '!' ; Prints: ! APRINT '\n' ; Prints a newline ## LICENSE The MIT License (MIT) Copyright (c) 2013 Markus Siemens Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
评论
    相关推荐