1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

H26年秋期 基本情報技術者 午後問12 解説 設問2

Posted at
MAIN    START
        LAD    GR1,A          ; ソート対象
        LD     GR2,n          ; 要素数
        CALL   SORT
        RET
A       DC     2              ; #2
        DC     4              ; #4
        DC     1              ; #1
        DC     3              ; #3
N       DC     4

SORT    START
        RPUSH
        SUBA   GR2,=1         ; ループのカウンタ 1 を設定
LOOP1   LD     GR3,GR2        ; ループのカウンタ 2 を設定
        LD     GR4,GR1        ; GR4←比較する要素のアドレス
LOOP2   LD     GR5,0,GR4
        CPL    GR5,1,GR4      ; 二つの要素を比較
        JMI    CONT
        LD     GR6,1,GR4      ; 二つの要素を入れ替え
        ST     GR5,1,GR4
        ST     GR6,0,GR4
CONT    ADDA   GR4,=1
        SUBA   GR3,=1
        JPL    LOOP2
        SUBA   GR2,=1
        JPL    LOOP1
        RPOP
        RET
        END

解説

2 - 4 - 1 - 3
2 - 4
    1 - 4
        3 - 4
1 - 2
    2 - 3
1 - 2
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?