archi:y86
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
archi:y86 [2018/09/12 09:55] – orel | archi:y86 [2024/03/18 15:06] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 682: | Line 682: | ||
+ | ==== En vrac ==== | ||
+ | <code - td04_exo1.ys> | ||
+ | .pos 0 | ||
+ | |||
+ | irmovl stack, %esp | ||
+ | jmp main | ||
+ | |||
+ | # f(long *x, long y) | ||
+ | f: | ||
+ | mrmovl 4(%esp), | ||
+ | mrmovl 8(%esp), | ||
+ | rmmovl %ecx, | ||
+ | ret | ||
+ | |||
+ | # main | ||
+ | main: | ||
+ | |||
+ | mrmovl u, %eax | ||
+ | pushl %eax # empiler 2eme arg (u) | ||
+ | irmovl t, %eax | ||
+ | pushl %eax # empiler 1er arg (&t) | ||
+ | call f | ||
+ | iaddl 8, | ||
+ | |||
+ | halt | ||
+ | |||
+ | .pos 0x100 | ||
+ | t: .long 0 | ||
+ | u: .long 2 | ||
+ | |||
+ | .pos 0x200 | ||
+ | stack: | ||
+ | </ | ||
+ | |||
+ | <code - td04_exo2.ys> | ||
+ | .pos 0 | ||
+ | |||
+ | irmovl stack, %esp | ||
+ | jmp main | ||
+ | |||
+ | # f(long n, long * t) | ||
+ | f: | ||
+ | mrmovl 4(%esp), | ||
+ | mrmovl 8(%esp), | ||
+ | |||
+ | loop: | ||
+ | isubl 1, %ecx | ||
+ | jl end | ||
+ | mrmovl (%eax), | ||
+ | iaddl 1, %edx # inc | ||
+ | rmmovl %edx, (%eax) | ||
+ | iaddl 4, | ||
+ | jmp loop | ||
+ | |||
+ | end: | ||
+ | ret | ||
+ | |||
+ | # main | ||
+ | main: | ||
+ | irmovl t, %eax | ||
+ | pushl %eax # empiler 2eme arg (adresse t) | ||
+ | mrmovl n, %eax | ||
+ | pushl %eax # empiler 1er arg (valeur n) | ||
+ | call f | ||
+ | iaddl 8, | ||
+ | |||
+ | halt | ||
+ | |||
+ | .pos 0x100 | ||
+ | n: .long 4 | ||
+ | t: | ||
+ | .long 1 | ||
+ | .long 2 | ||
+ | .long 3 | ||
+ | .long 4 | ||
+ | |||
+ | |||
+ | .pos 0x200 | ||
+ | stack: | ||
+ | </ | ||
+ | |||
+ | <code - td04_exo3.ys> | ||
+ | .pos 0 | ||
+ | |||
+ | irmovl stack, %esp | ||
+ | jmp main | ||
+ | |||
+ | # sommme(long n, long v[0], long v[1], ...) | ||
+ | f: | ||
+ | pushl %ebx # save callee-saved registry | ||
+ | xorl %eax, | ||
+ | mrmovl 8(%esp), | ||
+ | rrmovl %esp,%ebx | ||
+ | iaddl 12, %ebx # v | ||
+ | |||
+ | loop: | ||
+ | isubl 1, %ecx | ||
+ | jl end | ||
+ | mrmovl (%ebx), | ||
+ | addl %edx, | ||
+ | rmmovl %edx, (%ebx) | ||
+ | iaddl 4, | ||
+ | jmp loop | ||
+ | end: | ||
+ | popl %ebx # restore callee-saved registry | ||
+ | ret # %eax | ||
+ | |||
+ | # main | ||
+ | main: | ||
+ | irmovl 3, %eax | ||
+ | pushl %eax # empiler v2 | ||
+ | irmovl 2, %eax | ||
+ | pushl %eax # empiler v1 | ||
+ | irmovl 1, %eax | ||
+ | pushl %eax # empiler v0 | ||
+ | irmovl 3, %eax | ||
+ | pushl %eax # empiler n | ||
+ | call f | ||
+ | iaddl 16, | ||
+ | |||
+ | halt | ||
+ | |||
+ | .pos 0x100 | ||
+ | n: .long 4 | ||
+ | |||
+ | |||
+ | .pos 0x200 | ||
+ | stack: | ||
+ | </ |
archi/y86.1536746145.txt.gz · Last modified: 2024/03/18 15:05 (external edit)