+ 35

[OFF-TOPIC] ASM

Post your asm codes here..learn and help others learn as well I will() be updating constantly.. Here's a basic example 👇 for the learners..😊 https://code.sololearn.com/cGD367IuT7Y1/?ref=app

25th Jan 2018, 7:46 PM
Daljeet Singh
Daljeet Singh - avatar
24 Answers
+ 20
@Jamie that was super quick 😊👍
26th Jan 2018, 11:48 AM
Daljeet Singh
Daljeet Singh - avatar
+ 15
I'm working in a small operating system :) github.com/Andres0b0100/Panda
25th Jan 2018, 9:07 PM
Andres0b0100
Andres0b0100 - avatar
+ 15
@jacob well precisely that's the reason why I started this thread! and named it ASM(So that it covers everything ),as you can see I covered introduction,jumps,push😉etc.(very basics) I am not editing because I am waiting for mails from SL...once done I will post the codes that covers and includes all the profiles (those who are practicing asm), will be helpful to everyone interested...👍
30th Jan 2018, 6:43 AM
Daljeet Singh
Daljeet Singh - avatar
+ 7
Here's some code I wrote to convert an integer to a string in x86 assembly language in protected mode: ; ; Conversion table for __itoa. ; Works for bases [2 ... 36]. ; __itoacvt: db '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ' section .text ; ; Routine to convert a 32-bit integer to a string. ; Registers are preserved. ; ; EAX: Source integer ; EBX: Target address ; ECX: Base ; EDX: Sign extend ; ; Internal register layout: ; start: ; EAX: Source integer ; ECX: Target address ; EDX: Base ; checknegative: ; EAX: Source integer ; EBX: Target address (original) ; ECX: Target address (active) ; EDX: Sign extend (temporary) ; divrem: ; EAX: Source integer ; ECX: Target address (active) ; EDX: Base / Result ; reverse: ; EBX: Target address (original) ; ECX: Target address (active) ; EDX: Target address (temporary) ; __itoa: .start: push eax push ebx push ecx push edx mov edx, ecx mov ecx, ebx .checknegative: push edx mov dword edx, [esp + 32] test edx, edx pop edx jz .divrem test eax, eax jns .divrem mov byte [ecx], 0x2D inc ecx mov ebx, ecx neg eax .divrem: push edx push ecx mov ecx, edx xor edx, edx div ecx mov byte dl, [__itoacvt + edx] pop ecx mov byte [ecx], dl pop edx inc ecx cmp eax, 0x00 jne .divrem mov byte [ecx], 0x00 dec ecx .reverse: cmp ebx, ecx jge .end mov byte dl, [ebx] mov byte al, [ecx] mov byte [ebx], al mov byte [ecx], dl inc ebx dec ecx jmp .reverse .end: pop edx pop ecx pop ebx pop eax ret
26th Jan 2018, 2:43 PM
SplittyDev
SplittyDev - avatar
+ 6
thanks @Jamie
26th Jan 2018, 12:32 PM
Ogbuagu Beloved Francis
Ogbuagu Beloved Francis - avatar
+ 6
I wrote a small operating system in x86 assembly. https://github.com/SplittyDev/Plain/tree/master/asm
26th Jan 2018, 2:40 PM
SplittyDev
SplittyDev - avatar
27th Jan 2018, 2:54 AM
Ogbuagu Beloved Francis
Ogbuagu Beloved Francis - avatar
+ 4
Please upvote to have asm tutorial: https://www.sololearn.com/Discuss/1037926/?ref=app Not just trying to get xp, I didn’t even post it. Just want it to happen.
29th Jan 2018, 9:50 PM
Jacob Pembleton
Jacob Pembleton - avatar
+ 4
i got a playlist of asm on youtube https://youtu.be/SL--qoiu7yA
14th Feb 2018, 4:14 PM
DEEPENDU PANDIT
DEEPENDU PANDIT - avatar
+ 3
@Andreas TEST sets the zero flag if the bitwise and of the operands is zero. Maybe use CMP and then do a conditional jump if zero (jz) or if not zero (jnz). If you use TEST, you need to test the divisor like that: MOV the divisor into eax, then do TEST %EAX, %EAX and then do the conditional jump (jz) if the divisor is zero.
27th Jan 2018, 12:15 AM
SplittyDev
SplittyDev - avatar
+ 2
what's ASM?
26th Jan 2018, 11:42 AM
Ogbuagu Beloved Francis
Ogbuagu Beloved Francis - avatar
+ 2
The GETN procedure reads digits until a character that is not a number. I will update the code on github
27th Jan 2018, 11:54 AM
Andres0b0100
Andres0b0100 - avatar
+ 2
Error found: I should clear the dx register before a 16-bit division!
28th Jan 2018, 12:55 AM
Andres0b0100
Andres0b0100 - avatar
+ 1
I used TEST to check if a register is zero before a division, but the system stops even if the number is not zero. Why? It works fine with OR
27th Jan 2018, 12:10 AM
Andres0b0100
Andres0b0100 - avatar
+ 1
xor cx,cx ; should be 0 call procedures.getn ; get a number from keyboard test cx,cx ; (or cx,cx) jz .error ; prints an error message pop ax ; the first operand div cx ; divide push ax ; result jmp .end ; print the result
27th Jan 2018, 12:28 AM
Andres0b0100
Andres0b0100 - avatar
+ 1
Nope, it's the same. Is anything wrong there? Thanks
27th Jan 2018, 1:00 AM
Andres0b0100
Andres0b0100 - avatar