Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #demo program to show how to use diffrent data types in assembly
- .data
- HelloWorld:
- .ascii "Hello World!"
- ByteLocation:#8bits
- .byte 10
- Int32:#32bits
- .int 2
- Int16:#16bits interger or single 32bit floating point
- .short 3
- float:
- .float 10.23
- IntergerArray:
- .int 10,20,30,40,50
- .bss
- .comm LargeBuffer, 10000
- .text
- .globl _start
- _start:
- nop # no operation flag
- # 1 MOV immeditate value into the register
- movl $10, %eax
- # 2 Mov immediate value into memory location
- movw $50, Int16 # note movw w=word 16bits
- # 3 MOV data between registers
- movl %eax, %ebx
- # 4 mov data from (all.data is loaded into mem first)memory to register
- movl Int32,%eax
- # 5 MOV data from register to memory
- movb $3, %al # using al as it's an 8bit register
- movb %al, ByteLocation #moving %al to ByteLocation
- # 6 Move data into an indexed memroy location
- # Location is decided byBaseAddress(Offset,index,Datasize)
- #Offset and index MUST be registers, Datasize can be a numerical value
- movl $0, %ecx#offsert
- movl $2, %edi#index (0,1,2) so pointint to 30
- movl $22,IntergerArray(%ecx,%edi,4) #
- # 7 Indirect addressing using registers
- movl $Int32, %eax # address of int32 copied to eax
- movl (%eax) , %ebx # using the addres of eax int32 is coptied to ebx(2)
- # copying 9 into the memoery location %eax thats pointing to Int32
- movl $9, (%eax)
- # Exit the programmmmmmm
- movl $1, %eax
- movl $0, %ebx
- int $0x80
- # http://stackoverflow.com/questions/1898834/why-would-one-use-movl-1-eax-as-opposed-to-say-movb-1-eax
- # http://hackipedia.org/Books/Other/Programming%20From%20the%20Ground%20Up/ProgrammingGroundUp-1-0-booksize.pdf
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement