Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
lecture6-1
;File: index1.asm ; ;This program demonstrates the use of an indexed addressing mode ;to access array elements ; ;This program has no I/O. Use the debugger to examine its effects ; ;nasm -felf64 -g index1.asm -o index1.o ;ld -o index1 index1.o ; section .data arr: dd 0,1,2,3,4,5,6,7,8,9 ; ten 32-bit words base: equ arr - 4 section .text global _start _start: ;Add 5 to each element of the array stored in arr ;Simulate ; ; for (i=0; i<10l i++) { ; arr[i] += 5; ; } init: mov rcx,0 ;rcx simulates i loop1: cmp rcx,10 ; i<10 jge done1 add [rcx*4+arr], dword 5 ; arr[i] += 5 inc rcx ; i++ jmp loop1 done1: ;another way init2: mov rcx,9 ; i=9 loop2: add [rcx*4+arr], dword 5 ; arr[i] += 5 dec rcx ; i-- jge loop2 ; loop while rcx >= 0 ;another way init3: mov rdi,base ; base computed by ld mov rcx,10 ; i = 10 loop3: add [rdi+rcx*4], dword 5 ; arr[i] += 5 loop loop3 ; loop = dec rcx, jne alldone: mov rax,60 xor rdi,rdi syscall
run
|
edit
|
history
|
help
0
fdsfdafdsafdsafds
dfdffdfdfdfdfdfd
Block traspher
ASCII TO HEX (Accept and Display)
CMSC313_L1
BranchesLab_mSmith_bBrownV1
studenthello
fdsfsfsdafs
learning assembly with rextester
Input and Display a number