Skip to main content

Posts

Showing posts from August 11, 2019

receives 5 numbers, and prints them back in reverse order assembly yasm/nasm/fasm

This program receives 5 numbers, and prints them back in reverse order. yasm - BITS 32 global main extern exit section .data     ; 5 dwords:     keep_nums  times 5  dd (12345678h)     section .text main:     mov ecx, 5   read_one_number:     dec     ecx     call    read_hex     mov     esi,ecx     ; Calculate the address of dword number ecx:     shl     esi,2 ; multiply by 4. Every dword is 4 bytes!     add     esi,keep_nums     ; Store the number inside dword number ecx:     mov     dword [esi],eax     test    ecx,ecx     jnz     read_one_number     mov   ...

dup (nasm) alternative times for yasm

 yasm ------- BITS 32 global main extern exit %include    'training.s'   ;=========================================== section .data     ; 5 dwords:      keep_nums  times 5  dd (12345678h)     section .text main:     mov ecx, 5   read_one_number:     dec     ecx     call    read_hex     mov     esi,ecx     ; Calculate the address of dword number ecx:     shl     esi,2 ; multiply by 4. Every dword is 4 bytes!     add     esi,keep_nums     ; Store the number inside dword number ecx:     mov     dword [esi],eax     test    ecx,ecx     jnz     read_one_number ...