Ads

Friday 4 October 2013

Microprocessor Architecture Assignment Big Endian to Little Endian

Assignment Big Endian to Little Endian
section .data
number dq 0123456h
msg1 db " Big Endian = ",0Ah
len_msg1: equ $msg1
msg2 db " Little Endian = ",0Ah
len_msg2: equ $msg2
Section .bss
no resq 1
numb resb 8
%macro print 2
mov eax, 4
mov ebx, 1
mov ecx, %1
mov edx, %2
int 80h
%endmacro
%macro exit 0
mov eax, 1
mov ebx, 0
int 80h
%endmacro
section .text
global _start
_start:
print msg1, len_msg1
mov eax,[number]
call disp_proc
mov ebx, 0
mov edi,100H
mov eax, [number]
mov ecx, 4
next_byte:
shl ebx,8
mov edx,00
div edi
add ebx,edx
dec ecx
jnz next_byte
mov [no], ebx
print msg2, len_msg2
mov eax,[no]
call disp_proc
exit
disp_proc:
mov esi,numb+7
mov ecx,8
cnt: mov edx,0
mov ebx,10h
div ebx
cmp dl, 09h
jbe add30
add dl, 07h
add30:
add dl,30h
mov [esi],dl
dec esi
dec ecx
jnz cnt
print numb,8
ret

No comments:

Post a Comment