Tuesday, 5 March 2013

assembly pi

.data
.align 2 scan_format: .asciz "%d" .align 2 out_format: .asciz "Sum: %d Difference: %d Product: %d\n" .align 2 instr1: .asciz "Enter first integer." instr2: .asciz "Enter second integer." .align 2 num1: .word 0 num2: .word 0 .text .global main main: push {ip, lr} @Used with pop at end of main, allowing program to end. ldr r0, =instr1 bl puts ldr r1, =num1 ldr r0, =scan_format bl scanf ldr r0, =instr2 bl puts ldr r1, =num2 ldr r0, =scan_format bl scanf ldr r6, =num1 @load address of num1 into r6 ldr r4, [r6] @load value of num1 into r4 ldr r6, =num2 ldr r5, [r6] add r1, r4, r5 sub r2, r4, r5 mul r3, r4, r5 ldr r0, =out_format bl printf pop {ip, pc} @Used with push at start of Main, allowing program to end.


No comments:

Post a Comment