Author Topic: How many for loops are possible in nasm ?  (Read 12421 times)

Offline Roddy MacPhee

  • Jr. Member
  • *
  • Posts: 9
How many for loops are possible in nasm ?
« on: May 22, 2024, 11:41:08 PM »
I know of at least 40 different variants, but i'm wondering how many are useful (possible).
« Last Edit: May 23, 2024, 01:40:07 AM by Roddy MacPhee »

Offline debs3759

  • Global Moderator
  • Full Member
  • *****
  • Posts: 224
  • Country: gb
    • GPUZoo
Re: How many for loops are possible in nasm ?
« Reply #1 on: May 23, 2024, 11:15:34 AM »
I would think that you can use as many loops as you want. It's down to the programmer to write appropriate code and algorithms.
My graphics card database: www.gpuzoo.com

Offline Roddy MacPhee

  • Jr. Member
  • *
  • Posts: 9
Re: How many for loops are possible in nasm ?
« Reply #2 on: May 23, 2024, 02:56:33 PM »
Wish I knew modulo and printing numerical values to screen. Then I could make a prime sieve ... nasm compiler the code editor app uses is 2.14.02 and it has time limits.

Example of my attempt:


Code: [Select]
section .data
hw db "hello world,",0
section .text
global _start
_start:
    mov rdi,1
loop:
    mov eax,4
    mov ebx,1
    lea ecx,[hw]
    lea edx,[rdi]
    int 80H
    inc rdi
    cmp rdi,13
    jne loop
    mov eax,1
    xor ebx,ebx
    int 80H
« Last Edit: May 24, 2024, 05:51:38 PM by Roddy MacPhee »

Offline debs3759

  • Global Moderator
  • Full Member
  • *****
  • Posts: 224
  • Country: gb
    • GPUZoo
Re: How many for loops are possible in nasm ?
« Reply #3 on: May 23, 2024, 04:02:33 PM »
If the version of nasm you have is time limited, it's not an official version. nasm is 100% freeware with no restrictions or limitations.
My graphics card database: www.gpuzoo.com

Offline Roddy MacPhee

  • Jr. Member
  • *
  • Posts: 9
Re: How many for loops are possible in nasm ?
« Reply #4 on: May 23, 2024, 04:05:30 PM »
with no restrictions or limitations.
How do I print rdi to screen . I'm on android if that matters.
https://play.google.com/store/apps/details?id=com.rhmsoft.code

Found out how to print ascii characters using alt codes( yes I know I'm stupid). Now to either convert numbers to strings or use extern ...
« Last Edit: May 24, 2024, 12:24:54 AM by Roddy MacPhee »

Offline Roddy MacPhee

  • Jr. Member
  • *
  • Posts: 9
Re: How many for loops are possible in nasm ?
« Reply #5 on: May 24, 2024, 05:14:21 PM »
I would think that you can use as many loops as you want. It's down to the programmer to write appropriate code and algorithms.

Code: [Select]
    mov <register>,1
loop:
    inc <register>
    cmp <register> <limit>
    jne loop
Code: [Select]
    mov <register>,1
loop:
    add <register>,1
    cmp <register> <limit>
    jne loop

With 20+ registers and then some. Unlike what you thought they can't all be used at once( at least without complex additions) . Some have uses doing other things. You can also have a decreasing  version. Another factor is replacing jne with other conditional jumps ...
« Last Edit: May 24, 2024, 05:41:06 PM by Roddy MacPhee »