.ORIG x3000 LEA R1, HELLO AGAIN LDR R2, R1, #0 BRz NEXT ADD R1, R1, #1 BR AGAIN
ID: 3690773 • Letter: #
Question
.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.) “Hello, World” Write, compile and execute an assembler program that take a store String that contains “Hello, World”
Explanation / Answer
section .text ;section declaration ;we must export the entry point to the ELF linker or global _start ;loader. They conventionally recognize _start as their ;entry point. Use ld -e foo to override the default. _start: ;write our string to stdout mov edx,len ;third argument: message length mov ecx,msg ;second argument: pointer to message to write mov ebx,1 ;first argument: file handle (stdout) mov eax,4 ;system call number (sys_write) int 0x80 ;call kernel ;and exit mov ebx,0 ;first syscall argument: exit code mov eax,1 ;system call number (sys_exit) int 0x80 ;call kernel section .data ;section declaration msg db "Hello, world!",0xa ;our dear string len equ $ - msg ;length of our dear string
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.