Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
87
Task/Loops-Continue/X86-Assembly/loops-continue.x86
Normal file
87
Task/Loops-Continue/X86-Assembly/loops-continue.x86
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
extern _printf
|
||||
|
||||
section .data
|
||||
output db 0,0,0,0
|
||||
reversedOutput db 0,0
|
||||
|
||||
section .text
|
||||
global _main
|
||||
_main:
|
||||
mov ecx, 0
|
||||
looping:
|
||||
inc ecx
|
||||
mov eax, ecx
|
||||
push ecx
|
||||
cmp ecx, 5
|
||||
je do5
|
||||
cmp ecx, 10
|
||||
je do10
|
||||
don:
|
||||
call createOutput
|
||||
mov [eax+1], byte 0x2c
|
||||
mov [eax+2], byte 0x20
|
||||
push eax
|
||||
call _printf
|
||||
add esp, 4
|
||||
pop ecx
|
||||
jmp looping
|
||||
do5:
|
||||
call createOutput
|
||||
mov [eax+1], byte 0x0a
|
||||
push eax
|
||||
call _printf
|
||||
add esp, 4
|
||||
pop ecx
|
||||
jmp looping
|
||||
do10:
|
||||
call createOutput
|
||||
mov [eax+2], byte 0x0a
|
||||
push eax
|
||||
call _printf
|
||||
add esp, 4
|
||||
pop ecx
|
||||
xor eax, eax
|
||||
ret
|
||||
|
||||
|
||||
createOutput: ;parameter in eax
|
||||
;eax between 1 and 99
|
||||
push ebx
|
||||
mov ecx, 0
|
||||
clearOutput:
|
||||
mov [output+ecx], byte 0
|
||||
cmp ecx, 3
|
||||
je next
|
||||
inc ecx
|
||||
jmp clearOutput
|
||||
next:
|
||||
mov ecx, 0
|
||||
mov ebx, 10
|
||||
cOlooping:
|
||||
xor edx, edx
|
||||
div ebx
|
||||
mov [reversedOutput+ecx], dl
|
||||
add [reversedOutput+ecx], byte 0x30
|
||||
cmp eax, 0
|
||||
je reverse
|
||||
cmp ecx, 1
|
||||
je reverse
|
||||
inc ecx
|
||||
jmp cOlooping
|
||||
reverse:
|
||||
mov ecx, -1
|
||||
mov ebx, 0
|
||||
name:
|
||||
inc ecx
|
||||
neg ecx
|
||||
mov dl, [reversedOutput+ecx+1]
|
||||
neg ecx
|
||||
cmp dl, 0
|
||||
je name
|
||||
mov [output + ebx], dl
|
||||
inc ebx
|
||||
cmp ecx, 1
|
||||
jl name
|
||||
mov eax, output
|
||||
pop ebx
|
||||
ret
|
||||
Loading…
Add table
Add a link
Reference in a new issue