72 lines
1.2 KiB
Plaintext
72 lines
1.2 KiB
Plaintext
|
|
.data
|
|
a:.long 12
|
|
b:.long 3
|
|
c:.long 2
|
|
d:.long 12
|
|
e:.long 12
|
|
.text
|
|
movl a,%eax 8T
|
|
movl b,%ebx 8T
|
|
movl d,%ecx 8T
|
|
addl $2,%eax 4T
|
|
addl $1,%ebx 4T
|
|
addl e,%ecx 9T
|
|
div c 159T = 200T #ok
|
|
|
|
Registerinhalte:
|
|
%eax = (a + 2) = 14/2 = 7
|
|
%ebx = b + 1 = 4
|
|
%ecx = d + e = 24
|
|
|
|
###OK
|
|
|
|
|
|
.data
|
|
a:.long 12
|
|
b:.long 3
|
|
c:.long 2
|
|
d:.long 12
|
|
e:.long 12
|
|
.text
|
|
movl a,%eax 8T
|
|
movl b,%ebx 8T
|
|
movl d,%ecx 8T
|
|
movl e,%edx 8T
|
|
addl $2,%eax 4T
|
|
incl %ebx 3T
|
|
addl %edx,%ecx 3T
|
|
shrl $1,%eax 2T = 44T #ok
|
|
|
|
Registerinhalte:
|
|
%eax = (a + 2) << 1 = 14 << 1 = 01110b << 1 = 11100b = 28
|
|
%ebx = b + 1 = 4
|
|
%ecx = d + e = 24
|
|
%edx = e = 12
|
|
|
|
###??? %eax !
|
|
|
|
Aufgabe C: Shiften! #ok
|
|
|
|
|
|
Aufgabe 2: #UNTERSCHIEDE, ABER GLEICHES PRINZIP
|
|
|
|
%eax << 4bit zahl >> %eax (5bit zahl)
|
|
|
|
movl %eax, %ebx # zahl kopieren
|
|
movl $0, %ecx # c = 0
|
|
andl 1000b, %ebx # b = 1 oder 0
|
|
addl %ebx, %ecx # c += b
|
|
movl %eax, %ebx # zahl kopieren
|
|
and 0100b, %ebx # b = 1 oder 0
|
|
addl %ebx, %ecx # c += b
|
|
and 0010b, %ebx # b = 1 oder 0
|
|
addl %ebx, %ecx # c += b
|
|
and 0001b, %ebx # b = 1 oder 0
|
|
addl %ebx, %ecx # c += b
|
|
|
|
and 0001b , %ecx #counter ungerade?
|
|
|
|
shrl $1, %eax #shifte zahl um 1
|
|
|
|
or %ecx, %eax #falls counter ungerade war setze 1 and 1. stelle. |