1
1

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.

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

Last updated at Posted at 2016-03-23
MAIN    START
        LD     GR0,A          ; GR0 ← A
        LAD    GR1,B          ; GR1 ← Bのアドレス
        LD     GR2,=10        ; GR2 ← n
        LAD    GR3,C          ; GR3 ← Cのアドレス
        CALL   BITINS
        RET
A       DC     #5E96
B       DC     #EF18
C       DS     2

BITINS  START
        RPUSH
        LD     GR6,=16
        SUBA   GR6,GR2        ; GR6 ← シフト数
        LD     GR1,0,GR1      ; GR1 ← ビット列 B
        LD     GR4,GR1        ; GR4 ← ビット列 B
        LD     GR5,GR0        ; GR5 ← ビット列 A
        SRL    GR1,0,GR6
        SLL    GR1,0,GR6      ; GR1 ← ビット列 B の左 n ビット(b1)
        SLL    GR4,0,GR2
        SRL    GR4,0,GR2      ; GR4 ← ビット列 B の右(16-n)ビット(b2)
        SRL    GR0,0,GR2      ; GR0 ← ビット列 A の左(16-n) ビット(a1)
        SLL    GR5,0,GR6      ; GR5 ← ビット列 A の右 n ビット(a2)
        OR     GR1,GR0        ; C1 ← b1+a1
        OR     GR4,GR5        ; C2 ← a2+b2
        ST     GR1,0,GR3
        ST     GR4,1,GR3
        RPOP
        RET
        END

A:a1,a2 → 00a1,a200
B:b1,b2 → b100,00b2
C:c1,c2 = b1a1,a2b2
b1,a2:n桁
b2,a1:(16-n)桁

1
1
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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?