Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

.ORIG x3000 LEA R1, HELLO AGAIN LDR R2, R1, #0 BRz NEXT ADD R1, R1, #1 BR AGAIN

ID: 3691580 • 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, an assembler program that take a store String that contains “Hello, World”

Explanation / Answer

The fallowing Assembly code will help you to Store String like "“Hello, World”

section   .text
   global_start   ;must be declared for linker (ld)
  
_start:              ;tells linker entry point
   mov   edx,len   ;message length
   mov   ecx,msg   ;message to write
   mov   ebx,1     ;file descriptor (stdout)
   mov   eax,4     ;system call number (sys_write)
   int   0x80      ;call kernel
  
   mov   eax,1     ;system call number (sys_exit)
   int   0x80      ;call kernel

section   .data
msg db 'Hello, world!', 0xa ;our dear string
len equ $ - msg    ;length of our dear string