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

This is an assembly program, we are tasked with converting a string to a int, th

ID: 3751099 • Letter: T

Question

This is an assembly program, we are tasked with converting a string to a int, the string has values base 14, and the integer will be base 10.

I have the following code but i get this error, error: label or instruction expected at start of line in line 49 with the jae 9lp. How do i fix this or why does it happen?

section .data
; -----
; Define constants
NULL equ 0
EXIT_SUCCESS equ 0
; successful operation
SYS_exit equ    60
SPACE equ     " "
max_length   dd 10

rsum dd 0
dig     dd 0
ten db 10
intNum dd   0
fourteen dd 14
strNum   db "1a7C",NULL
  
   section .text
global _start
_start:


   mov ecx, dword[max_length]
   ;; get string address
   mov al ,       strNum
   ;; i = 0
   mov rsi, 0
   mov rbx, 0
  
Nxtchr:             ;gets next character
   mov al, byte[rbx    + rsi *1] ; chr (ch = str[i])
   cmp al, SPACE              ;if (ch != " "), go to Nxtstp
   jne Nxtstp

   inc rsi           ;i++
   loop Nxtchr       ;go to Nxtchr

   mov ecx, dword[max_length]
   mov r8d, 0
  
Nxtstp:               ;next step to get int value
   mov al, byte[rbx    + rsi *1]   ;chr (ch = str[i])
   mov bl, NULL
   cmp al ,bl
   je Exitlp; if ( ch == NULL), exit l
   cmp al , "0"       ;if (ch is between "0" and "9")
   jae 9lp

9lp:
   cmp al , "9"
   ja aLP
   sub al, "0"
   mov byte[ dig], al   ; dig = ch - "0"

aLP:
   cmp al ,"a"       ;if (ch is between "a" and "d")
   jae dLP

dLP:
   cmp al, "d"
   ja ALP
   sub al, "a"
   add al,byte[ ten]   ;dig = ch -"a" +10
   mov byte[ dig], al

ALP:
   cmp al , "A"          ;;if (ch is between "A" and "D"
   jge DLP

DLP:
   sub al, "A"       ;;dig = ch -"A" +10
   add al,byte [ ten]
   mov byte[dig], al

   mov eax, dword [ rsum]   ;running sum = rsum * 14
   mul fourteen
   movzx   eax, byte[dig]
   add eax,byte[ dig]   ;running sum = rsum +dig
   mov dword[ rsum], eax

   inc r8d
   loop Nxtstp

Exitlp:  
   mov eax,dword[ rsum]
   mov dword[intNum], eax


  

last:
mov rax, SYS_exit
mov rdi, EXIT_SUCCESS
syscall

Explanation / Answer

Everything is fine in Code.

Change name of 9lp to something else like elp and then exeute.

You will not face the error

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote