Need code to run this program .ORIG x3000 LEA R1, HELLO AGAIN LDR R2, R1, #0 BRz
ID: 3694558 • Letter: N
Question
Need code to run this program
.ORIG x3000
LEA R1, HELLO
AGAIN LDR R2, R1, #0
BRz NEXT
ADD R1, R1, #1
BR AGAIN
NEXT LEA R0, PROMPT
TRAP x22 ; PUTS
LD R3, NEGENTER
AGAIN2 TRAP x20 ; GETC
TRAP x21 ; OUT
ADD R2, R0, R3
BRz CONT
STR R0, R1, #0
ADD R1, R1, #1
BR AGAIN2
CONT ADD R2, R2, #0
STR R2, R2, #0
LEA R0, HELLO
TRAP x22 ; PUTS
TRAP x25 ; HALT
NEGENTER .FILL xFFF6 ; -x0A
PROMPT .STRINGZ “Please enter your name: “
HELLO.STRINGZ “Hello, “
.BLKW #25
.END
1.) “Area of a rectangle” Write, compile and execute an assembler program that prompts the user ( via the screen ) to enter the length and width of a rectangle ( via the keyboard )and prints
need code to run this program
Explanation / Answer
Answer:
The assembly language program is given as below :
.Ltext0:
.local _ZStL8__ioinit
.comm _ZStL8__ioinit,1,1
.section .rodata
.LC0:
0000 20456E74 .string " Enter Height : "
.LC1:
0011 20456E74 .string " Enter Width : "
.LC2:
0022 20417265 .string " Area of Rectangle : "
.text
.globl main
main:
.LFB1021:
.cfi_startproc
0000 55 pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
0001 4889E5 movq %rsp, %rbp
.cfi_def_cfa_register 6
0004 4883EC30 subq $48, %rsp
0008 64488B04 movq %fs:40, %rax
0011 488945F8 movq %rax, -8(%rbp)
0015 31C0 xorl %eax, %eax
0017 BE000000 movl $.LC0, %esi
001c BF000000 movl $_ZSt4cout, %edi
0021 E8000000 call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
0026 488D45EC leaq -20(%rbp), %rax
002a 4889C6 movq %rax, %rsi
002d BF000000 movl $_ZSt3cin, %edi
0032 E8000000 call _ZNSirsERf
0037 BE000000 movl $.LC1, %esi
003c BF000000 movl $_ZSt4cout, %edi
0041 E8000000 call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
0046 488D45E8 leaq -24(%rbp), %rax
004a 4889C6 movq %rax, %rsi
004d BF000000 movl $_ZSt3cin, %edi
0052 E8000000 call _ZNSirsERf
0057 F30F104D movss -24(%rbp), %xmm1
005c F30F1045 movss -20(%rbp), %xmm0
0061 F30F59C1 mulss %xmm1, %xmm0
0065 F30F5AD0 cvtss2sd %xmm0, %xmm2
0069 F20F1155 movsd %xmm2, -16(%rbp)
006e BE000000 movl $.LC2, %esi
0073 BF000000 movl $_ZSt4cout, %edi
0078 E8000000 call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
007d 4889C2 movq %rax, %rdx
0080 488B45F0 movq -16(%rbp), %rax
0084 488945D8 movq %rax, -40(%rbp)
0088 F20F1045 movsd -40(%rbp), %xmm0
008d 4889D7 movq %rdx, %rdi
0090 E8000000 call _ZNSolsEd
0095 BE000000 movl $_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_, %esi
009a 4889C7 movq %rax, %rdi
009d E8000000 call _ZNSolsEPFRSoS_E
00a2 B8000000 movl $0, %eax
00a7 488B4DF8 movq -8(%rbp), %rcx
00ab 6448330C xorq %fs:40, %rcx
00b4 7405 je .L3
00b6 E8000000 call __stack_chk_fail
.L3:
00bb C9 leave
.cfi_def_cfa 7, 8
00bc C3 ret
.cfi_endproc
.LFE1021:
_Z41__static_initialization_and_destruction_0ii:
.LFB1032:
00da BF000000 movl $_ZStL8__ioinit, %edi
00df E8000000 call _ZNSt8ios_base4InitC1Ev
00e4 BA000000 movl $__dso_handle, %edx
00e9 BE000000 movl $_ZStL8__ioinit, %esi
00ee BF000000 movl $_ZNSt8ios_base4InitD1Ev, %edi
00f3 E8000000 call __cxa_atexit
.cfi_startproc
00bd 55 pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
00be 4889E5 movq %rsp, %rbp
.cfi_def_cfa_register 6
00c1 4883EC10 subq $16, %rsp
00c5 897DFC movl %edi, -4(%rbp)
00c8 8975F8 movl %esi, -8(%rbp)
00cb 837DFC01 cmpl $1, -4(%rbp)
00cf 7527 jne .L6
00d1 817DF8FF cmpl $65535, -8(%rbp)
00d8 751E jne .L6
.L6:
00f8 90 nop
00f9 C9 leave
.cfi_def_cfa 7, 8
00fa C3 ret
.cfi_endproc
.LFE1032:
_GLOBAL__sub_I_main:
.LFB1033:
.cfi_startproc
00fb 55 pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
00fc 4889E5 movq %rsp, %rbp
.cfi_def_cfa_register 6
00ff BEFFFF00 movl $65535, %esi
0104 BF010000 movl $1, %edi
0109 E8AFFFFF call _Z41__static_initialization_and_destruction_0ii
010e5D popq %rbp
.cfi_def_cfa 7, 8
010f C3 ret
.cfi_endproc
.LFE1033:
.section .init_array,"aw"
.align 8
0000 00000000 .quad _GLOBAL__sub_I_main
.text
.Letext0:
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.