assembly - 我应该如何使用命令提示符将文本文件(包含程序)组装到机器代码文件中?
问题描述
下面的程序有效。但是我需要把它变成机器代码文件,为此我尝试使用命令“jasm -a polled-io.txt”。然而,这是不被认可的。我相信这可能是由于这个命令不是最新的(或者我错过了一些东西)。为了做到这一点,我将不胜感激一些直接的步骤。提前致谢。
汇编代码 -> 汇编器 -> 机器代码
该文本文件称为“polled-io.txt”。
该程序从键盘读取 10 个字符,然后在输入后将它们全部打印出来。这是里面的内容:
OSR EQU $E3 * Output Status Register (OSR)
ODR EQU $E2 * Output Data Register (ODR)
ISR EQU $E1 * Input Status Register (ISR)
IDR EQU $E0 * Input Data Register (IDR)
ORG 0
MOVE #$00,B * count is storage for our
MOVE B,count * counter value
loop MOVE ISR,A * Get ISR
CMP #$00,A * is a char available?
BEQ loop * no - wait some more
MOVE IDR,A * read the char
MOVE count,B * the address to write the
ADD #data,B * value to is count+data
MOVE A,(B) * write the char in there
MOVE count,B * add 1 to count
ADD #$01,B *
CMP #$0A,B * and see if we have reached 10
BEQ gotchars * and move to next section if we have
MOVE B,count * otherwise write count back
JMP loop * and get another char
gotchars MOVE #$00,B * count is storage for our
MOVE B,count * counter value
write MOVE OSR,A * get OSR
CMP #$00,A * OSR 1 can print, OSR 0 can't print
BEQ write * not yet, wait some more
MOVE count,B * the address to read the
ADD #data,B * value from is count+data
MOVE (B),A * get the char in there
MOVE A,ODR * print the char
MOVE count,B * add 1 to count
ADD #$01,B *
CMP #$0A,B * and see if we have reached 10
BEQ done * and move to end if we have
MOVE B,count * otherwise write count back
JMP write * and write another char
done HALT * done
count DS.W $01 * the counter
data DS.W $0A * storage for our 10 characters
解决方案
推荐阅读
- xaml - 显示食物名称的应用程序
- r - R预测预期变量不在lm对象中
- mysql - 从 LAST_INSERT_ID() 声明变量的 mysql 通用语法错误 - 难以分析
- discord.js - 如何在 discord.js 富嵌入中使用本地图像?
- regex - 使用正则表达式与负前瞻部分匹配
- caching - Hazelcast 客户端和地图存储的不同(反)序列化
- angular - Jasmine:如何测试组件内的异常消息?
- arrays - 如何将普通 args 和数组都传递给 bash 脚本参数?
- sql - 插入后为当前时间戳更新创建触发器
- jquery - 1 行,2 个子 div。单击 div 将切换父行 - 但如果单击同级则不会