首页 > 解决方案 > 我应该如何使用命令提示符将文本文件(包含程序)组装到机器代码文件中?

问题描述

下面的程序有效。但是我需要把它变成机器代码文件,为此我尝试使用命令“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

标签: assemblysystemcommand-promptcpu-architecturemachine-code

解决方案


推荐阅读