nudt csapp 2025 finished
This commit is contained in:
40
Y86_as/input.txt
Normal file
40
Y86_as/input.txt
Normal file
@@ -0,0 +1,40 @@
|
||||
# Execution begins at address 0
|
||||
.pos 0
|
||||
irmovq stack, %rsp # Set up stack pointer
|
||||
call main # Execute main program
|
||||
halt # Terminate program
|
||||
|
||||
# Array of 4 elements
|
||||
.pos 0x18
|
||||
array:
|
||||
.quad 0xd000d000d000d
|
||||
.quad 0xc000c000c000c0
|
||||
.quad 0xb000b000b000b
|
||||
.quad 0xa000a000a000a
|
||||
|
||||
main:
|
||||
irmovq array, %rdi
|
||||
irmovq $4, %rsi
|
||||
call sum
|
||||
ret
|
||||
|
||||
# long sum(long *start, long count)
|
||||
# start in %rdi, count in %rsi
|
||||
sum:
|
||||
irmovq $8,%r8
|
||||
irmovq $1,%r9
|
||||
xorq %rax,%rax
|
||||
andq %rsi,%rsi
|
||||
jmp test
|
||||
loop:
|
||||
mrmovq (%rdi),%r10
|
||||
addq %r10,%rax
|
||||
addq %r8,%rdi # start++
|
||||
subq %r9,%rsi # count--
|
||||
# Set CC
|
||||
test:
|
||||
jne loop # Stop when 0
|
||||
ret # Return
|
||||
|
||||
.pos 0x200
|
||||
stack:
|
||||
Reference in New Issue
Block a user