NASM x86 Ubuntu broken simple code

ساخت وبلاگ

Vote count: 0

i know the title i gave this question doesn't fit convention but i've only been writing NASM for my 32bit Ubuntu machine for a couple of hours. Below i have included the code that doesn't work, it is supposed to loop incrementing ecx and then checking if it is equal or more than 10, if it is the it should print out 10. I am completely new to actually writing assembly code and have only studied miniscule MASM32 and whats included in the GCSE computer science course. I am eager to learn and hoping that someone with some spare time is able to explain what im doing wrong constructively so that i may progress. Thank you for your time.

tenloop.asm:

section .text
global _start ;proto main
_start: ;start lbl mov ecx, 0 ;ecx = 0 jmp loop ;call loop
loop: add ecx, 1 ;ecx++ cmp ecx, 10 jl loop ;loop if ecx < 10 jge prt ;call prt if ecx >= 10
prt: mov ecx, [1] ;[1] = ecx mov edx, 2 ;arg3, length push [1] ;[1] -> S pop ecx ;ecx <- S mov ebx, 1 ;ebx = 1, write() outputs to stdout mov eax, 4 ;sys_call 4 to call, write() int 0x80 ;interupt to call kernel, this handles sys_calls mov ebx, 0 ;ebx = 0; exit() same as return 0 int 0x80 ;call kernel
asked 21 secs ago

back soft...
ما را در سایت back soft دنبال می کنید

برچسب : نویسنده : استخدام کار backsoft بازدید : 297 تاريخ : پنجشنبه 21 مرداد 1395 ساعت: 4:39