It is currently Wed Jan 27, 2021 5:35 am

All times are UTC + 1 hour

Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: PUSHALL/POPALL (PUSHAD/POPAD and flags for both x86 and x64)
PostPosted: Thu Jun 04, 2015 8:24 am 
User avatar

Joined: Thu Jun 04, 2015 7:10 am
Posts: 1678
On 64bit we dont have the PUSHAD/POPAD instructions so here is hopefully a manual solution. Im new to Purebasic so i welcome any feedback and hope i havent screwed this up!
As PUSHF/POPF are still supported perhaps its better to leave them out of this!
Macro pushall       ;assumes EnableASM already set
    pushf           ;db 0x9C
  CompilerIf #PB_Compiler_Processor = #PB_Processor_x86
    pushad          ;db 0x60
  CompilerElseIf #PB_Compiler_Processor = #PB_Processor_x64   
    push rax        ;db 0x50
    push rcx        ;db 0x51
    push rdx        ;db 0x52               
    push rbx        ;db 0x53               
    push rbp        ;db 0x55               
    push rsi        ;db 0x56               
    push rdi        ;db 0x57               
    push r8         ;db 0x41,0x50         
    push r9         ;db 0x41,0x51         
    push r10        ;db 0x41,0x52         
    push r11        ;db 0x41,0x53         
    push r12        ;db 0x41,0x54         
    push r13        ;db 0x41,0x55         
    push r14        ;db 0x41,0x56         
    push r15        ;db 0x41,0x57           

Macro popall        ;assumes EnableASM already set
  CompilerIf #PB_Compiler_Processor = #PB_Processor_x64
    pop r15         ;db 0x41,0x5F         
    pop r14         ;db 0x41,0x5E         
    pop r13         ;db 0x41,0x5D         
    pop r12         ;db 0x41,0x5C         
    pop r11         ;db 0x41,0x5B         
    pop r10         ;db 0x41,0x5A         
    pop r9          ;db 0x41,0x59         
    pop r8          ;db 0x41,0x58         
    pop rdi         ;db 0x5F               
    pop rsi         ;db 0x5E               
    pop rbp         ;db 0x5D               
    pop rbx         ;db 0x5B               
    pop rdx         ;db 0x5A               
    pop rcx         ;db 0x59               
    pop rax         ;db 0x58               
  CompilerElseIf #PB_Compiler_Processor = #PB_Processor_x86
    popad           ;db 0x61
    popf            ;db 0x9D               

MessageRequester ("PUSHAD","Ready...")
;db 0xCC
;db 0xCC

Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC + 1 hour

Who is online

Users browsing this forum: No registered users and 2 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye