Jump to content

Array: Difference between revisions

→‎Encoding an Array's End: Added additional clarification
m (→‎Encoding an Array's End: Provided more fitting examples that actually relate to the text.)
(→‎Encoding an Array's End: Added additional clarification)
Line 138:
; input: [DS:SI] = string pointer
mov al,[ds:si]
cmp al,5Ch ;ascii for backslash, this is the escape character
;notice that the check for the escape character happens before the check for the terminator.
jz EscapeNextChar
cmp al,0h ;check the terminator
jz Terminated ;we've reached the terminator
call PrintChar ;call to hardware-specific printing routine
jmp PrintString
 
EscapeNextChar:
mov al,[ds:si] ;perform an additional read, except this read doesn't compare the fetched character to anything.
call PrintChar ;print that character as-is
jmp PrintString ;go back to the loop's beginning, skipping the terminator check entirely.
jmp PrintString
 
Terminated:
1,489

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.