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.

Advertisements
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s