11
Website and Forum / Re: nasm.us certificate expired this morning
« Last post by netjunki on February 24, 2021, 12:59:00 AM »Seems to be fixed now! Thanks to whoever (or the bot) which cycled the cert. :-)
I didn't say it wasn't elementary. To get 3 you have to add 1. The question is where does the 1 come from? Up till this point in the author does not explain it.edx+2 * edx = 3edx-> This is my question, how is this possible?
EDX + 2*EDX = EDX * (1 + 2) = EDX * 3
Elementary arithmetic.QuoteBut earlier mov edx,ecx -> 0 was moved into edxYep... this code is obviously WRONG. Or, at least, is incomplete (and ECX is updated in a loop).
edx(0)+ 2*edx(0) =should equal to 0, right?
Do you understand what I am saying here?
edx+2 * edx = 3edx-> This is my question, how is this possible?
But earlier mov edx,ecx -> 0 was moved into edxYep... this code is obviously WRONG. Or, at least, is incomplete (and ECX is updated in a loop).
edx(0)+ 2*edx(0) =should equal to 0, right?
Do you understand what I am saying here?
Well... it's a "trick" using lea (load effective address) to "load" edx with edx plus edx times two... As you observe, zero times three is zero. You don't show it, but we then increment edx.. and ,,,I get its a trick but i don't see where the 3 is coming from...
I've never read "Step by Step"... I ASSume Jeff explains this...?
Best,
Frank
SECTION .bss
BUFFLEN equ 16 ; ----> Bufflen = 16
Buff: resb BUFFLEN ; ----> Buff will read 16 bytes from the buffer
SECTION .data ; Section containing initialised data
HexStr: db " 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00",10
HEXLEN equ $-HexStr ; ---->length of Hexstr
Digits: db "0123456789ABCDEF"
SECTION .text ; Section containing code
global _start ; Linker needs this to find the entry point!
_start:
nop ; This no-op keeps gdb happy...
; Read a buffer full of text from stdin:
Read:
mov eax,3 ; ----> syscall read
mov ebx,0 ; ----> read from standard input (keyboard)
mov ecx,Buff ; ----> where the string read is stored
mov edx,BUFFLEN ; ----> how many bytes is supposed to read
int 80h ; ----> sys call
mov ebp,eax ; ----> copy the number that where actually read into ebp
cmp eax,0 ; ----> sub 0 from eax and set the appropriate flag? (if user enters 0 shouldn't the program end?)
je Done ; ----> if the zero flag is set move tone the label done
; Set up the registers for the process buffer step:
mov esi,Buff ; ----> copy the content of Buff into esi
mov edi,HexStr ; ----> copy hexstr into edi
xor ecx,ecx ; ----> Clears ecx
; Go through the buffer and convert binary values to hex digits:
Scan:
s xor eax,eax ; ----> clears eax
; Here we calculate the offset into the line string, which is ecx X 3
mov edx,ecx ; ----> copy ecx which is 0 into edx
lea edx,[edx*2+edx] ; ----> This is where i am stuck. How are you able to multiply by 3 over here?
LEA = [BASE +( INDEX * SCALE) + DISP)]
if edx is 0, how are we able to multiply by 3