Skip to content

Instantly share code, notes, and snippets.

@foxiepaws
Last active May 4, 2016 20:16
Show Gist options
  • Save foxiepaws/5093927 to your computer and use it in GitHub Desktop.
Save foxiepaws/5093927 to your computer and use it in GitHub Desktop.
section .data
test: db 'testInG 123', 0Ah
testlen: equ $-test
section .bss
testr: resb 100
section .text
global main
main:
mov esi, 0 ; set the segment pointer to 0, (xor esi,esi would have also been valid)
loop:
movzx eax, byte [test+esi] ; move with zero extend a single byte from our char array using the index esi.
cmp al,96 ; see if its greater than 96.
jg stage2 ; jump to stage2 if its greater than
jmp storechar ; otherwise jump to storechar
stage2:
cmp al,123 ; see if its less than 123
jl xorlc ; jump to xorlc if its less than
jmp storechar ; otherwise jump to storechar
xorlc:
xor al, 32 ; xor a single byte from eax (using al, which points at the 8 bit register)
storechar:
mov [testr+esi],al ; store our byte into another array with the index esi
mov ebx,esi ; put our index in ebx (this is from some old code, I could pull this out)
cmp eax,0Ah ; compare eax with \0 to see if they are equal
jne set ; if they aren't equal jump to set
je done ; otherwise jump to done
set:
add esi,1 ; add 1 to our index esi
jmp loop ; jump to loop
done:
xor eax,eax ; set eax to 0
mov [testr+esi],al ; put our null terminator on the end of the string
print:
; we are calling syswrite() here.
mov ebx,1 ; move 1 into ebx (stdout)
mov eax,4 ; move 4 into eax (this calls syswrite)
mov ecx,testr ; point ecx to our memory location
mov edx,testlen ; set edx to the number of characters we are pulling from memory
int 0x80 ; actually call syswrite
quit:
mov eax,1 ; set eax to 1 ( i think exit)
int 0x80 ; call exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment