It is astonishingly easy to get basically any LLM to output a simple iteration from one to ten function in all of those languages, and more.
newline db 0xA ; Newline character
section .bss
number resb 1 ; Reserve a byte for the number
section .text
global _start
_start:
mov ecx, 1 ; Start with 1
mov edx, 10 ; End with 10
loop_start:
cmp ecx, edx ; Compare ecx with edx
jg loop_end ; If ecx > edx, jump to loop_end
; Convert number to ASCII
add ecx, '0' ; Convert number to ASCII
mov [number], ecx ; Store the ASCII value in number
; Print the number
mov eax, 4 ; sys_write system call
mov ebx, 1 ; File descriptor 1 is stdout
mov ecx, number ; Pointer to the number
mov edx, 1 ; Number of bytes to write
int 0x80 ; Call kernel
; Print newline
mov eax, 4 ; sys_write system call
mov ebx, 1 ; File descriptor 1 is stdout
mov ecx, newline ; Pointer to the newline character
mov edx, 1 ; Number of bytes to write
int 0x80 ; Call kernel
sub ecx, '0' ; Convert ASCII back to number
inc ecx ; Increment the number
jmp loop_start ; Jump back to the start of the loop
loop_end:
; Exit the program
mov eax, 1 ; sys_exit system call
xor ebx, ebx ; Exit code 0
int 0x80 ; Call kernel
program iterate_from_one_to_ten
implicit none
integer :: i
! Loop from 1 to 10
do i = 1, 10
print *, i
end do
end program iterate_from_one_to_ten
PROGRAM-ID. IterateFromOneToTen.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-Counter PIC 9(2) VALUE 1.
PROCEDURE DIVISION.
PERFORM VARYING WS-Counter FROM 1 BY 1 UNTIL WS-Counter > 10
DISPLAY WS-Counter
END-PERFORM.
STOP RUN.