+ 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
24 Answers
+ 20
@Jamie that was super quick 😊👍
+ 15
I'm working in a small operating system :) github.com/Andres0b0100/Panda
+ 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...👍
+ 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
+ 6
thanks @Jamie
+ 6
I wrote a small operating system in x86 assembly.
https://github.com/SplittyDev/Plain/tree/master/asm
+ 4
@ Jamie you're needed here
https://www.sololearn.com/discuss/1031820/?ref=app
+ 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.
+ 4
i got a playlist of asm on youtube
https://youtu.be/SL--qoiu7yA
+ 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.
+ 2
what's ASM?
+ 2
The GETN procedure reads digits until a character that is not a number. I will update the code on github
+ 2
Error found: I should clear the dx register before a 16-bit division!
+ 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
+ 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
+ 1
Nope, it's the same. Is anything wrong there? Thanks