以下程序有效。但是,我需要将其转换为机器代码文件,为此,我尝试使用命令“ 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,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 * 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