Skip to content

Instantly share code, notes, and snippets.

@matthewholliday
Created October 20, 2019 00:33
Show Gist options
  • Save matthewholliday/3114b3ea583d79b3c665c1121d7e15b6 to your computer and use it in GitHub Desktop.
Save matthewholliday/3114b3ea583d79b3c665c1121d7e15b6 to your computer and use it in GitHub Desktop.
ASSEMBLY Calculate String Length
section .data
msg db 'This is a test message.',0Ah
SECTION .text
global _start
_start:
mov ebx, msg
mov eax, ebx
gotonextchar:
cmp byte [eax], 0
jz calculatelength
inc eax
jmp gotonextchar
calculatelength:
sub eax, ebx
mov edx, eax
writemessage:
mov ecx, msg
mov ebx, 1
mov eax, 4
int 80h
mov ebx, 0
mov eax, 1
int 80h
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment